]> Pileus Git - ~andy/linux/blobdiff - drivers/media/v4l2-core/videobuf-vmalloc.c
Staging: btmtk_usb: Fix incorrect brace placement
[~andy/linux] / drivers / media / v4l2-core / videobuf-vmalloc.c
index 2ff7fcc77b1104fe7d1ca1a2a9d5738ede27acb7..1365c651c1777bd5f7973281f26baccdad6c8995 100644 (file)
@@ -54,11 +54,14 @@ MODULE_LICENSE("GPL");
 static void videobuf_vm_open(struct vm_area_struct *vma)
 {
        struct videobuf_mapping *map = vma->vm_private_data;
+       struct videobuf_queue *q = map->q;
 
        dprintk(2, "vm_open %p [count=%u,vma=%08lx-%08lx]\n", map,
                map->count, vma->vm_start, vma->vm_end);
 
+       videobuf_queue_lock(q);
        map->count++;
+       videobuf_queue_unlock(q);
 }
 
 static void videobuf_vm_close(struct vm_area_struct *vma)
@@ -70,12 +73,11 @@ static void videobuf_vm_close(struct vm_area_struct *vma)
        dprintk(2, "vm_close %p [count=%u,vma=%08lx-%08lx]\n", map,
                map->count, vma->vm_start, vma->vm_end);
 
-       map->count--;
-       if (0 == map->count) {
+       videobuf_queue_lock(q);
+       if (!--map->count) {
                struct videobuf_vmalloc_memory *mem;
 
                dprintk(1, "munmap %p q=%p\n", map, q);
-               videobuf_queue_lock(q);
 
                /* We need first to cancel streams, before unmapping */
                if (q->streaming)
@@ -114,8 +116,8 @@ static void videobuf_vm_close(struct vm_area_struct *vma)
 
                kfree(map);
 
-               videobuf_queue_unlock(q);
        }
+       videobuf_queue_unlock(q);
 
        return;
 }