aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@infradead.org>2008-01-31 11:57:53 -0500
committerMauro Carvalho Chehab <mchehab@infradead.org>2008-02-18 09:15:12 -0500
commit64f9477f95bf5d4ba49dc3988d47a15bc06bb5da (patch)
treef5ff902b731ead3984eb9f9e971289161336f4ba /drivers
parentce3a35d3c00918296e552af5ecc7b771af766436 (diff)
V4L/DVB (7121): Renames videobuf lock to vb_lock
This helps to identify where vb_lock is being used, and find missusages of the locks. Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/video/bt8xx/bttv-driver.c50
-rw-r--r--drivers/media/video/bt8xx/bttv-vbi.c4
-rw-r--r--drivers/media/video/saa7134/saa7134-empress.c8
-rw-r--r--drivers/media/video/saa7134/saa7134-video.c20
-rw-r--r--drivers/media/video/videobuf-core.c78
-rw-r--r--drivers/media/video/videobuf-dma-sg.c4
-rw-r--r--drivers/media/video/videobuf-vmalloc.c4
7 files changed, 83 insertions, 85 deletions
diff --git a/drivers/media/video/bt8xx/bttv-driver.c b/drivers/media/video/bt8xx/bttv-driver.c
index 907dc62c1783..d9ce9a48ef59 100644
--- a/drivers/media/video/bt8xx/bttv-driver.c
+++ b/drivers/media/video/bt8xx/bttv-driver.c
@@ -2354,8 +2354,8 @@ static int setup_window(struct bttv_fh *fh, struct bttv *btv,
2354 BUG(); 2354 BUG();
2355 } 2355 }
2356 2356
2357 mutex_lock(&fh->cap.lock); 2357 mutex_lock(&fh->cap.vb_lock);
2358 kfree(fh->ov.clips); 2358 kfree(fh->ov.clips);
2359 fh->ov.clips = clips; 2359 fh->ov.clips = clips;
2360 fh->ov.nclips = n; 2360 fh->ov.nclips = n;
2361 2361
@@ -2376,7 +2376,7 @@ static int setup_window(struct bttv_fh *fh, struct bttv *btv,
2376 bttv_overlay_risc(btv, &fh->ov, fh->ovfmt, new); 2376 bttv_overlay_risc(btv, &fh->ov, fh->ovfmt, new);
2377 retval = bttv_switch_overlay(btv,fh,new); 2377 retval = bttv_switch_overlay(btv,fh,new);
2378 } 2378 }
2379 mutex_unlock(&fh->cap.lock); 2379 mutex_unlock(&fh->cap.vb_lock);
2380 return retval; 2380 return retval;
2381} 2381}
2382 2382
@@ -2576,7 +2576,7 @@ static int bttv_s_fmt_cap(struct file *file, void *priv,
2576 fmt = format_by_fourcc(f->fmt.pix.pixelformat); 2576 fmt = format_by_fourcc(f->fmt.pix.pixelformat);
2577 2577
2578 /* update our state informations */ 2578 /* update our state informations */
2579 mutex_lock(&fh->cap.lock); 2579 mutex_lock(&fh->cap.vb_lock);
2580 fh->fmt = fmt; 2580 fh->fmt = fmt;
2581 fh->cap.field = f->fmt.pix.field; 2581 fh->cap.field = f->fmt.pix.field;
2582 fh->cap.last = V4L2_FIELD_NONE; 2582 fh->cap.last = V4L2_FIELD_NONE;
@@ -2585,7 +2585,7 @@ static int bttv_s_fmt_cap(struct file *file, void *priv,
2585 btv->init.fmt = fmt; 2585 btv->init.fmt = fmt;
2586 btv->init.width = f->fmt.pix.width; 2586 btv->init.width = f->fmt.pix.width;
2587 btv->init.height = f->fmt.pix.height; 2587 btv->init.height = f->fmt.pix.height;
2588 mutex_unlock(&fh->cap.lock); 2588 mutex_unlock(&fh->cap.vb_lock);
2589 2589
2590 return 0; 2590 return 0;
2591} 2591}
@@ -2611,11 +2611,11 @@ static int vidiocgmbuf(struct file *file, void *priv, struct video_mbuf *mbuf)
2611 unsigned int i; 2611 unsigned int i;
2612 struct bttv_fh *fh = priv; 2612 struct bttv_fh *fh = priv;
2613 2613
2614 mutex_lock(&fh->cap.lock); 2614 mutex_lock(&fh->cap.vb_lock);
2615 retval = videobuf_mmap_setup(&fh->cap, gbuffers, gbufsize, 2615 retval = videobuf_mmap_setup(&fh->cap, gbuffers, gbufsize,
2616 V4L2_MEMORY_MMAP); 2616 V4L2_MEMORY_MMAP);
2617 if (retval < 0) { 2617 if (retval < 0) {
2618 mutex_unlock(&fh->cap.lock); 2618 mutex_unlock(&fh->cap.vb_lock);
2619 return retval; 2619 return retval;
2620 } 2620 }
2621 2621
@@ -2627,7 +2627,7 @@ static int vidiocgmbuf(struct file *file, void *priv, struct video_mbuf *mbuf)
2627 for (i = 0; i < gbuffers; i++) 2627 for (i = 0; i < gbuffers; i++)
2628 mbuf->offsets[i] = i * gbufsize; 2628 mbuf->offsets[i] = i * gbufsize;
2629 2629
2630 mutex_unlock(&fh->cap.lock); 2630 mutex_unlock(&fh->cap.vb_lock);
2631 return 0; 2631 return 0;
2632} 2632}
2633#endif 2633#endif
@@ -2756,7 +2756,7 @@ static int bttv_overlay(struct file *file, void *f, unsigned int on)
2756 if (!check_alloc_btres(btv, fh, RESOURCE_OVERLAY)) 2756 if (!check_alloc_btres(btv, fh, RESOURCE_OVERLAY))
2757 return -EBUSY; 2757 return -EBUSY;
2758 2758
2759 mutex_lock(&fh->cap.lock); 2759 mutex_lock(&fh->cap.vb_lock);
2760 if (on) { 2760 if (on) {
2761 fh->ov.tvnorm = btv->tvnorm; 2761 fh->ov.tvnorm = btv->tvnorm;
2762 new = videobuf_pci_alloc(sizeof(*new)); 2762 new = videobuf_pci_alloc(sizeof(*new));
@@ -2767,7 +2767,7 @@ static int bttv_overlay(struct file *file, void *f, unsigned int on)
2767 2767
2768 /* switch over */ 2768 /* switch over */
2769 retval = bttv_switch_overlay(btv, fh, new); 2769 retval = bttv_switch_overlay(btv, fh, new);
2770 mutex_unlock(&fh->cap.lock); 2770 mutex_unlock(&fh->cap.vb_lock);
2771 return retval; 2771 return retval;
2772} 2772}
2773 2773
@@ -2806,7 +2806,7 @@ static int bttv_s_fbuf(struct file *file, void *f,
2806 } 2806 }
2807 2807
2808 /* ok, accept it */ 2808 /* ok, accept it */
2809 mutex_lock(&fh->cap.lock); 2809 mutex_lock(&fh->cap.vb_lock);
2810 btv->fbuf.base = fb->base; 2810 btv->fbuf.base = fb->base;
2811 btv->fbuf.fmt.width = fb->fmt.width; 2811 btv->fbuf.fmt.width = fb->fmt.width;
2812 btv->fbuf.fmt.height = fb->fmt.height; 2812 btv->fbuf.fmt.height = fb->fmt.height;
@@ -2838,7 +2838,7 @@ static int bttv_s_fbuf(struct file *file, void *f,
2838 retval = bttv_switch_overlay(btv, fh, new); 2838 retval = bttv_switch_overlay(btv, fh, new);
2839 } 2839 }
2840 } 2840 }
2841 mutex_unlock(&fh->cap.lock); 2841 mutex_unlock(&fh->cap.vb_lock);
2842 return retval; 2842 return retval;
2843} 2843}
2844 2844
@@ -3090,7 +3090,7 @@ static int bttv_s_crop(struct file *file, void *f, struct v4l2_crop *crop)
3090 3090
3091 fh->do_crop = 1; 3091 fh->do_crop = 1;
3092 3092
3093 mutex_lock(&fh->cap.lock); 3093 mutex_lock(&fh->cap.vb_lock);
3094 3094
3095 if (fh->width < c.min_scaled_width) { 3095 if (fh->width < c.min_scaled_width) {
3096 fh->width = c.min_scaled_width; 3096 fh->width = c.min_scaled_width;
@@ -3108,7 +3108,7 @@ static int bttv_s_crop(struct file *file, void *f, struct v4l2_crop *crop)
3108 btv->init.height = c.max_scaled_height; 3108 btv->init.height = c.max_scaled_height;
3109 } 3109 }
3110 3110
3111 mutex_unlock(&fh->cap.lock); 3111 mutex_unlock(&fh->cap.vb_lock);
3112 3112
3113 return 0; 3113 return 0;
3114} 3114}
@@ -3177,30 +3177,25 @@ static unsigned int bttv_poll(struct file *file, poll_table *wait)
3177 buf = list_entry(fh->cap.stream.next,struct bttv_buffer,vb.stream); 3177 buf = list_entry(fh->cap.stream.next,struct bttv_buffer,vb.stream);
3178 } else { 3178 } else {
3179 /* read() capture */ 3179 /* read() capture */
3180 mutex_lock(&fh->cap.lock); 3180 mutex_lock(&fh->cap.vb_lock);
3181 if (NULL == fh->cap.read_buf) { 3181 if (NULL == fh->cap.read_buf) {
3182 /* need to capture a new frame */ 3182 /* need to capture a new frame */
3183 if (locked_btres(fh->btv,RESOURCE_VIDEO_STREAM)) { 3183 if (locked_btres(fh->btv,RESOURCE_VIDEO_STREAM))
3184 mutex_unlock(&fh->cap.lock); 3184 goto err;
3185 return POLLERR;
3186 }
3187 fh->cap.read_buf = videobuf_pci_alloc(fh->cap.msize); 3185 fh->cap.read_buf = videobuf_pci_alloc(fh->cap.msize);
3188 if (NULL == fh->cap.read_buf) { 3186 if (NULL == fh->cap.read_buf)
3189 mutex_unlock(&fh->cap.lock); 3187 goto err;
3190 return POLLERR;
3191 }
3192 fh->cap.read_buf->memory = V4L2_MEMORY_USERPTR; 3188 fh->cap.read_buf->memory = V4L2_MEMORY_USERPTR;
3193 field = videobuf_next_field(&fh->cap); 3189 field = videobuf_next_field(&fh->cap);
3194 if (0 != fh->cap.ops->buf_prepare(&fh->cap,fh->cap.read_buf,field)) { 3190 if (0 != fh->cap.ops->buf_prepare(&fh->cap,fh->cap.read_buf,field)) {
3195 kfree (fh->cap.read_buf); 3191 kfree (fh->cap.read_buf);
3196 fh->cap.read_buf = NULL; 3192 fh->cap.read_buf = NULL;
3197 mutex_unlock(&fh->cap.lock); 3193 goto err;
3198 return POLLERR;
3199 } 3194 }
3200 fh->cap.ops->buf_queue(&fh->cap,fh->cap.read_buf); 3195 fh->cap.ops->buf_queue(&fh->cap,fh->cap.read_buf);
3201 fh->cap.read_off = 0; 3196 fh->cap.read_off = 0;
3202 } 3197 }
3203 mutex_unlock(&fh->cap.lock); 3198 mutex_unlock(&fh->cap.vb_lock);
3204 buf = (struct bttv_buffer*)fh->cap.read_buf; 3199 buf = (struct bttv_buffer*)fh->cap.read_buf;
3205 } 3200 }
3206 3201
@@ -3209,6 +3204,9 @@ static unsigned int bttv_poll(struct file *file, poll_table *wait)
3209 buf->vb.state == VIDEOBUF_ERROR) 3204 buf->vb.state == VIDEOBUF_ERROR)
3210 return POLLIN|POLLRDNORM; 3205 return POLLIN|POLLRDNORM;
3211 return 0; 3206 return 0;
3207err:
3208 mutex_unlock(&fh->cap.vb_lock);
3209 return POLLERR;
3212} 3210}
3213 3211
3214static int bttv_open(struct inode *inode, struct file *file) 3212static int bttv_open(struct inode *inode, struct file *file)
diff --git a/drivers/media/video/bt8xx/bttv-vbi.c b/drivers/media/video/bt8xx/bttv-vbi.c
index 1f0cc79e2a33..75fa82c7c735 100644
--- a/drivers/media/video/bt8xx/bttv-vbi.c
+++ b/drivers/media/video/bt8xx/bttv-vbi.c
@@ -352,13 +352,13 @@ int bttv_s_fmt_vbi(struct file *file, void *f, struct v4l2_format *frt)
352 because vbi_fmt.end counts field lines times two. */ 352 because vbi_fmt.end counts field lines times two. */
353 end = max(frt->fmt.vbi.start[0], start1) * 2 + 2; 353 end = max(frt->fmt.vbi.start[0], start1) * 2 + 2;
354 354
355 mutex_lock(&fh->vbi.lock); 355 mutex_lock(&fh->vbi.vb_lock);
356 356
357 fh->vbi_fmt.fmt = frt->fmt.vbi; 357 fh->vbi_fmt.fmt = frt->fmt.vbi;
358 fh->vbi_fmt.tvnorm = tvnorm; 358 fh->vbi_fmt.tvnorm = tvnorm;
359 fh->vbi_fmt.end = end; 359 fh->vbi_fmt.end = end;
360 360
361 mutex_unlock(&fh->vbi.lock); 361 mutex_unlock(&fh->vbi.vb_lock);
362 362
363 rc = 0; 363 rc = 0;
364 364
diff --git a/drivers/media/video/saa7134/saa7134-empress.c b/drivers/media/video/saa7134/saa7134-empress.c
index b1b01fa86720..94b81e1a7530 100644
--- a/drivers/media/video/saa7134/saa7134-empress.c
+++ b/drivers/media/video/saa7134/saa7134-empress.c
@@ -87,7 +87,7 @@ static int ts_open(struct inode *inode, struct file *file)
87 87
88 dprintk("open minor=%d\n",minor); 88 dprintk("open minor=%d\n",minor);
89 err = -EBUSY; 89 err = -EBUSY;
90 if (!mutex_trylock(&dev->empress_tsq.lock)) 90 if (!mutex_trylock(&dev->empress_tsq.vb_lock))
91 goto done; 91 goto done;
92 if (dev->empress_users) 92 if (dev->empress_users)
93 goto done_up; 93 goto done_up;
@@ -101,7 +101,7 @@ static int ts_open(struct inode *inode, struct file *file)
101 err = 0; 101 err = 0;
102 102
103done_up: 103done_up:
104 mutex_unlock(&dev->empress_tsq.lock); 104 mutex_unlock(&dev->empress_tsq.vb_lock);
105done: 105done:
106 return err; 106 return err;
107} 107}
@@ -110,7 +110,7 @@ static int ts_release(struct inode *inode, struct file *file)
110{ 110{
111 struct saa7134_dev *dev = file->private_data; 111 struct saa7134_dev *dev = file->private_data;
112 112
113 mutex_lock(&dev->empress_tsq.lock); 113 mutex_lock(&dev->empress_tsq.vb_lock);
114 videobuf_stop(&dev->empress_tsq); 114 videobuf_stop(&dev->empress_tsq);
115 videobuf_mmap_free(&dev->empress_tsq); 115 videobuf_mmap_free(&dev->empress_tsq);
116 dev->empress_users--; 116 dev->empress_users--;
@@ -122,7 +122,7 @@ static int ts_release(struct inode *inode, struct file *file)
122 saa_writeb(SAA7134_AUDIO_MUTE_CTRL, 122 saa_writeb(SAA7134_AUDIO_MUTE_CTRL,
123 saa_readb(SAA7134_AUDIO_MUTE_CTRL) | (1 << 6)); 123 saa_readb(SAA7134_AUDIO_MUTE_CTRL) | (1 << 6));
124 124
125 mutex_unlock(&dev->empress_tsq.lock); 125 mutex_unlock(&dev->empress_tsq.vb_lock);
126 return 0; 126 return 0;
127} 127}
128 128
diff --git a/drivers/media/video/saa7134/saa7134-video.c b/drivers/media/video/saa7134/saa7134-video.c
index 1184d359e848..39c41ad97d0e 100644
--- a/drivers/media/video/saa7134/saa7134-video.c
+++ b/drivers/media/video/saa7134/saa7134-video.c
@@ -1414,21 +1414,17 @@ video_poll(struct file *file, struct poll_table_struct *wait)
1414 if (!list_empty(&fh->cap.stream)) 1414 if (!list_empty(&fh->cap.stream))
1415 buf = list_entry(fh->cap.stream.next, struct videobuf_buffer, stream); 1415 buf = list_entry(fh->cap.stream.next, struct videobuf_buffer, stream);
1416 } else { 1416 } else {
1417 mutex_lock(&fh->cap.lock); 1417 mutex_lock(&fh->cap.vb_lock);
1418 if (UNSET == fh->cap.read_off) { 1418 if (UNSET == fh->cap.read_off) {
1419 /* need to capture a new frame */ 1419 /* need to capture a new frame */
1420 if (res_locked(fh->dev,RESOURCE_VIDEO)) { 1420 if (res_locked(fh->dev,RESOURCE_VIDEO))
1421 mutex_unlock(&fh->cap.lock); 1421 goto err;
1422 return POLLERR; 1422 if (0 != fh->cap.ops->buf_prepare(&fh->cap,fh->cap.read_buf,fh->cap.field))
1423 } 1423 goto err;
1424 if (0 != fh->cap.ops->buf_prepare(&fh->cap,fh->cap.read_buf,fh->cap.field)) {
1425 mutex_unlock(&fh->cap.lock);
1426 return POLLERR;
1427 }
1428 fh->cap.ops->buf_queue(&fh->cap,fh->cap.read_buf); 1424 fh->cap.ops->buf_queue(&fh->cap,fh->cap.read_buf);
1429 fh->cap.read_off = 0; 1425 fh->cap.read_off = 0;
1430 } 1426 }
1431 mutex_unlock(&fh->cap.lock); 1427 mutex_unlock(&fh->cap.vb_lock);
1432 buf = fh->cap.read_buf; 1428 buf = fh->cap.read_buf;
1433 } 1429 }
1434 1430
@@ -1440,6 +1436,10 @@ video_poll(struct file *file, struct poll_table_struct *wait)
1440 buf->state == VIDEOBUF_ERROR) 1436 buf->state == VIDEOBUF_ERROR)
1441 return POLLIN|POLLRDNORM; 1437 return POLLIN|POLLRDNORM;
1442 return 0; 1438 return 0;
1439
1440err:
1441 mutex_unlock(&fh->cap.vb_lock);
1442 return POLLERR;
1443} 1443}
1444 1444
1445static int video_release(struct inode *inode, struct file *file) 1445static int video_release(struct inode *inode, struct file *file)
diff --git a/drivers/media/video/videobuf-core.c b/drivers/media/video/videobuf-core.c
index 80a14da9acef..eab79ffdf56a 100644
--- a/drivers/media/video/videobuf-core.c
+++ b/drivers/media/video/videobuf-core.c
@@ -147,7 +147,7 @@ void videobuf_queue_core_init(struct videobuf_queue *q,
147 /* Having implementations for abstract methods are mandatory */ 147 /* Having implementations for abstract methods are mandatory */
148 BUG_ON(!q->int_ops); 148 BUG_ON(!q->int_ops);
149 149
150 mutex_init(&q->lock); 150 mutex_init(&q->vb_lock);
151 INIT_LIST_HEAD(&q->stream); 151 INIT_LIST_HEAD(&q->stream);
152} 152}
153 153
@@ -189,7 +189,7 @@ int videobuf_queue_is_busy(struct videobuf_queue *q)
189 return 0; 189 return 0;
190} 190}
191 191
192/* Locking: Caller holds q->lock */ 192/* Locking: Caller holds q->vb_lock */
193void videobuf_queue_cancel(struct videobuf_queue *q) 193void videobuf_queue_cancel(struct videobuf_queue *q)
194{ 194{
195 unsigned long flags = 0; 195 unsigned long flags = 0;
@@ -220,7 +220,7 @@ void videobuf_queue_cancel(struct videobuf_queue *q)
220 220
221/* --------------------------------------------------------------------- */ 221/* --------------------------------------------------------------------- */
222 222
223/* Locking: Caller holds q->lock */ 223/* Locking: Caller holds q->vb_lock */
224enum v4l2_field videobuf_next_field(struct videobuf_queue *q) 224enum v4l2_field videobuf_next_field(struct videobuf_queue *q)
225{ 225{
226 enum v4l2_field field = q->field; 226 enum v4l2_field field = q->field;
@@ -239,7 +239,7 @@ enum v4l2_field videobuf_next_field(struct videobuf_queue *q)
239 return field; 239 return field;
240} 240}
241 241
242/* Locking: Caller holds q->lock */ 242/* Locking: Caller holds q->vb_lock */
243static void videobuf_status(struct videobuf_queue *q, struct v4l2_buffer *b, 243static void videobuf_status(struct videobuf_queue *q, struct v4l2_buffer *b,
244 struct videobuf_buffer *vb, enum v4l2_buf_type type) 244 struct videobuf_buffer *vb, enum v4l2_buf_type type)
245{ 245{
@@ -295,7 +295,7 @@ static void videobuf_status(struct videobuf_queue *q, struct v4l2_buffer *b,
295 b->sequence = vb->field_count >> 1; 295 b->sequence = vb->field_count >> 1;
296} 296}
297 297
298/* Locking: Caller holds q->lock */ 298/* Locking: Caller holds q->vb_lock */
299static int __videobuf_mmap_free(struct videobuf_queue *q) 299static int __videobuf_mmap_free(struct videobuf_queue *q)
300{ 300{
301 int i; 301 int i;
@@ -328,13 +328,13 @@ static int __videobuf_mmap_free(struct videobuf_queue *q)
328int videobuf_mmap_free(struct videobuf_queue *q) 328int videobuf_mmap_free(struct videobuf_queue *q)
329{ 329{
330 int ret; 330 int ret;
331 mutex_lock(&q->lock); 331 mutex_lock(&q->vb_lock);
332 ret = __videobuf_mmap_free(q); 332 ret = __videobuf_mmap_free(q);
333 mutex_unlock(&q->lock); 333 mutex_unlock(&q->vb_lock);
334 return ret; 334 return ret;
335} 335}
336 336
337/* Locking: Caller holds q->lock */ 337/* Locking: Caller holds q->vb_lock */
338static int __videobuf_mmap_setup(struct videobuf_queue *q, 338static int __videobuf_mmap_setup(struct videobuf_queue *q,
339 unsigned int bcount, unsigned int bsize, 339 unsigned int bcount, unsigned int bsize,
340 enum v4l2_memory memory) 340 enum v4l2_memory memory)
@@ -384,9 +384,9 @@ int videobuf_mmap_setup(struct videobuf_queue *q,
384 enum v4l2_memory memory) 384 enum v4l2_memory memory)
385{ 385{
386 int ret; 386 int ret;
387 mutex_lock(&q->lock); 387 mutex_lock(&q->vb_lock);
388 ret = __videobuf_mmap_setup(q, bcount, bsize, memory); 388 ret = __videobuf_mmap_setup(q, bcount, bsize, memory);
389 mutex_unlock(&q->lock); 389 mutex_unlock(&q->vb_lock);
390 return ret; 390 return ret;
391} 391}
392 392
@@ -408,7 +408,7 @@ int videobuf_reqbufs(struct videobuf_queue *q,
408 return -EINVAL; 408 return -EINVAL;
409 } 409 }
410 410
411 mutex_lock(&q->lock); 411 mutex_lock(&q->vb_lock);
412 if (req->type != q->type) { 412 if (req->type != q->type) {
413 dprintk(1, "reqbufs: queue type invalid\n"); 413 dprintk(1, "reqbufs: queue type invalid\n");
414 retval = -EINVAL; 414 retval = -EINVAL;
@@ -444,7 +444,7 @@ int videobuf_reqbufs(struct videobuf_queue *q,
444 req->count = retval; 444 req->count = retval;
445 445
446 done: 446 done:
447 mutex_unlock(&q->lock); 447 mutex_unlock(&q->vb_lock);
448 return retval; 448 return retval;
449} 449}
450 450
@@ -452,7 +452,7 @@ int videobuf_querybuf(struct videobuf_queue *q, struct v4l2_buffer *b)
452{ 452{
453 int ret = -EINVAL; 453 int ret = -EINVAL;
454 454
455 mutex_lock(&q->lock); 455 mutex_lock(&q->vb_lock);
456 if (unlikely(b->type != q->type)) { 456 if (unlikely(b->type != q->type)) {
457 dprintk(1, "querybuf: Wrong type.\n"); 457 dprintk(1, "querybuf: Wrong type.\n");
458 goto done; 458 goto done;
@@ -470,7 +470,7 @@ int videobuf_querybuf(struct videobuf_queue *q, struct v4l2_buffer *b)
470 470
471 ret = 0; 471 ret = 0;
472done: 472done:
473 mutex_unlock(&q->lock); 473 mutex_unlock(&q->vb_lock);
474 return ret; 474 return ret;
475} 475}
476 476
@@ -487,7 +487,7 @@ int videobuf_qbuf(struct videobuf_queue *q,
487 if (b->memory == V4L2_MEMORY_MMAP) 487 if (b->memory == V4L2_MEMORY_MMAP)
488 down_read(&current->mm->mmap_sem); 488 down_read(&current->mm->mmap_sem);
489 489
490 mutex_lock(&q->lock); 490 mutex_lock(&q->vb_lock);
491 retval = -EBUSY; 491 retval = -EBUSY;
492 if (q->reading) { 492 if (q->reading) {
493 dprintk(1, "qbuf: Reading running...\n"); 493 dprintk(1, "qbuf: Reading running...\n");
@@ -573,7 +573,7 @@ int videobuf_qbuf(struct videobuf_queue *q,
573 retval = 0; 573 retval = 0;
574 574
575 done: 575 done:
576 mutex_unlock(&q->lock); 576 mutex_unlock(&q->vb_lock);
577 577
578 if (b->memory == V4L2_MEMORY_MMAP) 578 if (b->memory == V4L2_MEMORY_MMAP)
579 up_read(&current->mm->mmap_sem); 579 up_read(&current->mm->mmap_sem);
@@ -589,7 +589,7 @@ int videobuf_dqbuf(struct videobuf_queue *q,
589 589
590 MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS); 590 MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS);
591 591
592 mutex_lock(&q->lock); 592 mutex_lock(&q->vb_lock);
593 retval = -EBUSY; 593 retval = -EBUSY;
594 if (q->reading) { 594 if (q->reading) {
595 dprintk(1, "dqbuf: Reading running...\n"); 595 dprintk(1, "dqbuf: Reading running...\n");
@@ -632,7 +632,7 @@ int videobuf_dqbuf(struct videobuf_queue *q,
632 videobuf_status(q, b, buf, q->type); 632 videobuf_status(q, b, buf, q->type);
633 633
634 done: 634 done:
635 mutex_unlock(&q->lock); 635 mutex_unlock(&q->vb_lock);
636 return retval; 636 return retval;
637} 637}
638 638
@@ -642,7 +642,7 @@ int videobuf_streamon(struct videobuf_queue *q)
642 unsigned long flags = 0; 642 unsigned long flags = 0;
643 int retval; 643 int retval;
644 644
645 mutex_lock(&q->lock); 645 mutex_lock(&q->vb_lock);
646 retval = -EBUSY; 646 retval = -EBUSY;
647 if (q->reading) 647 if (q->reading)
648 goto done; 648 goto done;
@@ -659,11 +659,11 @@ int videobuf_streamon(struct videobuf_queue *q)
659 spin_unlock_irqrestore(q->irqlock, flags); 659 spin_unlock_irqrestore(q->irqlock, flags);
660 660
661 done: 661 done:
662 mutex_unlock(&q->lock); 662 mutex_unlock(&q->vb_lock);
663 return retval; 663 return retval;
664} 664}
665 665
666/* Locking: Caller holds q->lock */ 666/* Locking: Caller holds q->vb_lock */
667static int __videobuf_streamoff(struct videobuf_queue *q) 667static int __videobuf_streamoff(struct videobuf_queue *q)
668{ 668{
669 if (!q->streaming) 669 if (!q->streaming)
@@ -679,14 +679,14 @@ int videobuf_streamoff(struct videobuf_queue *q)
679{ 679{
680 int retval; 680 int retval;
681 681
682 mutex_lock(&q->lock); 682 mutex_lock(&q->vb_lock);
683 retval = __videobuf_streamoff(q); 683 retval = __videobuf_streamoff(q);
684 mutex_unlock(&q->lock); 684 mutex_unlock(&q->vb_lock);
685 685
686 return retval; 686 return retval;
687} 687}
688 688
689/* Locking: Caller holds q->lock */ 689/* Locking: Caller holds q->vb_lock */
690static ssize_t videobuf_read_zerocopy(struct videobuf_queue *q, 690static ssize_t videobuf_read_zerocopy(struct videobuf_queue *q,
691 char __user *data, 691 char __user *data,
692 size_t count, loff_t *ppos) 692 size_t count, loff_t *ppos)
@@ -745,7 +745,7 @@ ssize_t videobuf_read_one(struct videobuf_queue *q,
745 745
746 MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS); 746 MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS);
747 747
748 mutex_lock(&q->lock); 748 mutex_lock(&q->vb_lock);
749 749
750 nbufs = 1; size = 0; 750 nbufs = 1; size = 0;
751 q->ops->buf_setup(q, &nbufs, &size); 751 q->ops->buf_setup(q, &nbufs, &size);
@@ -817,11 +817,11 @@ ssize_t videobuf_read_one(struct videobuf_queue *q,
817 } 817 }
818 818
819 done: 819 done:
820 mutex_unlock(&q->lock); 820 mutex_unlock(&q->vb_lock);
821 return retval; 821 return retval;
822} 822}
823 823
824/* Locking: Caller holds q->lock */ 824/* Locking: Caller holds q->vb_lock */
825static int __videobuf_read_start(struct videobuf_queue *q) 825static int __videobuf_read_start(struct videobuf_queue *q)
826{ 826{
827 enum v4l2_field field; 827 enum v4l2_field field;
@@ -882,23 +882,23 @@ int videobuf_read_start(struct videobuf_queue *q)
882{ 882{
883 int rc; 883 int rc;
884 884
885 mutex_lock(&q->lock); 885 mutex_lock(&q->vb_lock);
886 rc = __videobuf_read_start(q); 886 rc = __videobuf_read_start(q);
887 mutex_unlock(&q->lock); 887 mutex_unlock(&q->vb_lock);
888 888
889 return rc; 889 return rc;
890} 890}
891 891
892void videobuf_read_stop(struct videobuf_queue *q) 892void videobuf_read_stop(struct videobuf_queue *q)
893{ 893{
894 mutex_lock(&q->lock); 894 mutex_lock(&q->vb_lock);
895 __videobuf_read_stop(q); 895 __videobuf_read_stop(q);
896 mutex_unlock(&q->lock); 896 mutex_unlock(&q->vb_lock);
897} 897}
898 898
899void videobuf_stop(struct videobuf_queue *q) 899void videobuf_stop(struct videobuf_queue *q)
900{ 900{
901 mutex_lock(&q->lock); 901 mutex_lock(&q->vb_lock);
902 902
903 if (q->streaming) 903 if (q->streaming)
904 __videobuf_streamoff(q); 904 __videobuf_streamoff(q);
@@ -906,7 +906,7 @@ void videobuf_stop(struct videobuf_queue *q)
906 if (q->reading) 906 if (q->reading)
907 __videobuf_read_stop(q); 907 __videobuf_read_stop(q);
908 908
909 mutex_unlock(&q->lock); 909 mutex_unlock(&q->vb_lock);
910} 910}
911 911
912 912
@@ -920,7 +920,7 @@ ssize_t videobuf_read_stream(struct videobuf_queue *q,
920 MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS); 920 MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS);
921 921
922 dprintk(2, "%s\n", __FUNCTION__); 922 dprintk(2, "%s\n", __FUNCTION__);
923 mutex_lock(&q->lock); 923 mutex_lock(&q->vb_lock);
924 retval = -EBUSY; 924 retval = -EBUSY;
925 if (q->streaming) 925 if (q->streaming)
926 goto done; 926 goto done;
@@ -980,7 +980,7 @@ ssize_t videobuf_read_stream(struct videobuf_queue *q,
980 } 980 }
981 981
982 done: 982 done:
983 mutex_unlock(&q->lock); 983 mutex_unlock(&q->vb_lock);
984 return retval; 984 return retval;
985} 985}
986 986
@@ -991,7 +991,7 @@ unsigned int videobuf_poll_stream(struct file *file,
991 struct videobuf_buffer *buf = NULL; 991 struct videobuf_buffer *buf = NULL;
992 unsigned int rc = 0; 992 unsigned int rc = 0;
993 993
994 mutex_lock(&q->lock); 994 mutex_lock(&q->vb_lock);
995 if (q->streaming) { 995 if (q->streaming) {
996 if (!list_empty(&q->stream)) 996 if (!list_empty(&q->stream))
997 buf = list_entry(q->stream.next, 997 buf = list_entry(q->stream.next,
@@ -1019,7 +1019,7 @@ unsigned int videobuf_poll_stream(struct file *file,
1019 buf->state == VIDEOBUF_ERROR) 1019 buf->state == VIDEOBUF_ERROR)
1020 rc = POLLIN|POLLRDNORM; 1020 rc = POLLIN|POLLRDNORM;
1021 } 1021 }
1022 mutex_unlock(&q->lock); 1022 mutex_unlock(&q->vb_lock);
1023 return rc; 1023 return rc;
1024} 1024}
1025 1025
@@ -1030,10 +1030,10 @@ int videobuf_mmap_mapper(struct videobuf_queue *q,
1030 1030
1031 MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS); 1031 MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS);
1032 1032
1033 mutex_lock(&q->lock); 1033 mutex_lock(&q->vb_lock);
1034 retval = CALL(q, mmap_mapper, q, vma); 1034 retval = CALL(q, mmap_mapper, q, vma);
1035 q->is_mmapped = 1; 1035 q->is_mmapped = 1;
1036 mutex_unlock(&q->lock); 1036 mutex_unlock(&q->vb_lock);
1037 1037
1038 return retval; 1038 return retval;
1039} 1039}
diff --git a/drivers/media/video/videobuf-dma-sg.c b/drivers/media/video/videobuf-dma-sg.c
index 98efd7ab1f50..53fed4b74ce9 100644
--- a/drivers/media/video/videobuf-dma-sg.c
+++ b/drivers/media/video/videobuf-dma-sg.c
@@ -356,7 +356,7 @@ videobuf_vm_close(struct vm_area_struct *vma)
356 map->count--; 356 map->count--;
357 if (0 == map->count) { 357 if (0 == map->count) {
358 dprintk(1,"munmap %p q=%p\n",map,q); 358 dprintk(1,"munmap %p q=%p\n",map,q);
359 mutex_lock(&q->lock); 359 mutex_lock(&q->vb_lock);
360 for (i = 0; i < VIDEO_MAX_FRAME; i++) { 360 for (i = 0; i < VIDEO_MAX_FRAME; i++) {
361 if (NULL == q->bufs[i]) 361 if (NULL == q->bufs[i])
362 continue; 362 continue;
@@ -373,7 +373,7 @@ videobuf_vm_close(struct vm_area_struct *vma)
373 q->bufs[i]->baddr = 0; 373 q->bufs[i]->baddr = 0;
374 q->ops->buf_release(q,q->bufs[i]); 374 q->ops->buf_release(q,q->bufs[i]);
375 } 375 }
376 mutex_unlock(&q->lock); 376 mutex_unlock(&q->vb_lock);
377 kfree(map); 377 kfree(map);
378 } 378 }
379 return; 379 return;
diff --git a/drivers/media/video/videobuf-vmalloc.c b/drivers/media/video/videobuf-vmalloc.c
index 9b3898347ca5..03b3b41cbb62 100644
--- a/drivers/media/video/videobuf-vmalloc.c
+++ b/drivers/media/video/videobuf-vmalloc.c
@@ -70,7 +70,7 @@ videobuf_vm_close(struct vm_area_struct *vma)
70 map->count--; 70 map->count--;
71 if (0 == map->count) { 71 if (0 == map->count) {
72 dprintk(1,"munmap %p q=%p\n",map,q); 72 dprintk(1,"munmap %p q=%p\n",map,q);
73 mutex_lock(&q->lock); 73 mutex_lock(&q->vb_lock);
74 for (i = 0; i < VIDEO_MAX_FRAME; i++) { 74 for (i = 0; i < VIDEO_MAX_FRAME; i++) {
75 if (NULL == q->bufs[i]) 75 if (NULL == q->bufs[i])
76 continue; 76 continue;
@@ -83,7 +83,7 @@ videobuf_vm_close(struct vm_area_struct *vma)
83 q->bufs[i]->map = NULL; 83 q->bufs[i]->map = NULL;
84 q->bufs[i]->baddr = 0; 84 q->bufs[i]->baddr = 0;
85 } 85 }
86 mutex_unlock(&q->lock); 86 mutex_unlock(&q->vb_lock);
87 kfree(map); 87 kfree(map);
88 } 88 }
89 return; 89 return;