Skip to content

Commit

Permalink
V4L/DVB (7121): Renames videobuf lock to vb_lock
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Mauro Carvalho Chehab committed Feb 18, 2008
1 parent ce3a35d commit 64f9477
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 86 deletions.
50 changes: 24 additions & 26 deletions drivers/media/video/bt8xx/bttv-driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -2354,8 +2354,8 @@ static int setup_window(struct bttv_fh *fh, struct bttv *btv,
BUG();
}

mutex_lock(&fh->cap.lock);
kfree(fh->ov.clips);
mutex_lock(&fh->cap.vb_lock);
kfree(fh->ov.clips);
fh->ov.clips = clips;
fh->ov.nclips = n;

Expand All @@ -2376,7 +2376,7 @@ static int setup_window(struct bttv_fh *fh, struct bttv *btv,
bttv_overlay_risc(btv, &fh->ov, fh->ovfmt, new);
retval = bttv_switch_overlay(btv,fh,new);
}
mutex_unlock(&fh->cap.lock);
mutex_unlock(&fh->cap.vb_lock);
return retval;
}

Expand Down Expand Up @@ -2576,7 +2576,7 @@ static int bttv_s_fmt_cap(struct file *file, void *priv,
fmt = format_by_fourcc(f->fmt.pix.pixelformat);

/* update our state informations */
mutex_lock(&fh->cap.lock);
mutex_lock(&fh->cap.vb_lock);
fh->fmt = fmt;
fh->cap.field = f->fmt.pix.field;
fh->cap.last = V4L2_FIELD_NONE;
Expand All @@ -2585,7 +2585,7 @@ static int bttv_s_fmt_cap(struct file *file, void *priv,
btv->init.fmt = fmt;
btv->init.width = f->fmt.pix.width;
btv->init.height = f->fmt.pix.height;
mutex_unlock(&fh->cap.lock);
mutex_unlock(&fh->cap.vb_lock);

return 0;
}
Expand All @@ -2611,11 +2611,11 @@ static int vidiocgmbuf(struct file *file, void *priv, struct video_mbuf *mbuf)
unsigned int i;
struct bttv_fh *fh = priv;

mutex_lock(&fh->cap.lock);
mutex_lock(&fh->cap.vb_lock);
retval = videobuf_mmap_setup(&fh->cap, gbuffers, gbufsize,
V4L2_MEMORY_MMAP);
if (retval < 0) {
mutex_unlock(&fh->cap.lock);
mutex_unlock(&fh->cap.vb_lock);
return retval;
}

Expand All @@ -2627,7 +2627,7 @@ static int vidiocgmbuf(struct file *file, void *priv, struct video_mbuf *mbuf)
for (i = 0; i < gbuffers; i++)
mbuf->offsets[i] = i * gbufsize;

mutex_unlock(&fh->cap.lock);
mutex_unlock(&fh->cap.vb_lock);
return 0;
}
#endif
Expand Down Expand Up @@ -2756,7 +2756,7 @@ static int bttv_overlay(struct file *file, void *f, unsigned int on)
if (!check_alloc_btres(btv, fh, RESOURCE_OVERLAY))
return -EBUSY;

mutex_lock(&fh->cap.lock);
mutex_lock(&fh->cap.vb_lock);
if (on) {
fh->ov.tvnorm = btv->tvnorm;
new = videobuf_pci_alloc(sizeof(*new));
Expand All @@ -2767,7 +2767,7 @@ static int bttv_overlay(struct file *file, void *f, unsigned int on)

/* switch over */
retval = bttv_switch_overlay(btv, fh, new);
mutex_unlock(&fh->cap.lock);
mutex_unlock(&fh->cap.vb_lock);
return retval;
}

Expand Down Expand Up @@ -2806,7 +2806,7 @@ static int bttv_s_fbuf(struct file *file, void *f,
}

/* ok, accept it */
mutex_lock(&fh->cap.lock);
mutex_lock(&fh->cap.vb_lock);
btv->fbuf.base = fb->base;
btv->fbuf.fmt.width = fb->fmt.width;
btv->fbuf.fmt.height = fb->fmt.height;
Expand Down Expand Up @@ -2838,7 +2838,7 @@ static int bttv_s_fbuf(struct file *file, void *f,
retval = bttv_switch_overlay(btv, fh, new);
}
}
mutex_unlock(&fh->cap.lock);
mutex_unlock(&fh->cap.vb_lock);
return retval;
}

Expand Down Expand Up @@ -3090,7 +3090,7 @@ static int bttv_s_crop(struct file *file, void *f, struct v4l2_crop *crop)

fh->do_crop = 1;

mutex_lock(&fh->cap.lock);
mutex_lock(&fh->cap.vb_lock);

if (fh->width < c.min_scaled_width) {
fh->width = c.min_scaled_width;
Expand All @@ -3108,7 +3108,7 @@ static int bttv_s_crop(struct file *file, void *f, struct v4l2_crop *crop)
btv->init.height = c.max_scaled_height;
}

mutex_unlock(&fh->cap.lock);
mutex_unlock(&fh->cap.vb_lock);

return 0;
}
Expand Down Expand Up @@ -3177,30 +3177,25 @@ static unsigned int bttv_poll(struct file *file, poll_table *wait)
buf = list_entry(fh->cap.stream.next,struct bttv_buffer,vb.stream);
} else {
/* read() capture */
mutex_lock(&fh->cap.lock);
mutex_lock(&fh->cap.vb_lock);
if (NULL == fh->cap.read_buf) {
/* need to capture a new frame */
if (locked_btres(fh->btv,RESOURCE_VIDEO_STREAM)) {
mutex_unlock(&fh->cap.lock);
return POLLERR;
}
if (locked_btres(fh->btv,RESOURCE_VIDEO_STREAM))
goto err;
fh->cap.read_buf = videobuf_pci_alloc(fh->cap.msize);
if (NULL == fh->cap.read_buf) {
mutex_unlock(&fh->cap.lock);
return POLLERR;
}
if (NULL == fh->cap.read_buf)
goto err;
fh->cap.read_buf->memory = V4L2_MEMORY_USERPTR;
field = videobuf_next_field(&fh->cap);
if (0 != fh->cap.ops->buf_prepare(&fh->cap,fh->cap.read_buf,field)) {
kfree (fh->cap.read_buf);
fh->cap.read_buf = NULL;
mutex_unlock(&fh->cap.lock);
return POLLERR;
goto err;
}
fh->cap.ops->buf_queue(&fh->cap,fh->cap.read_buf);
fh->cap.read_off = 0;
}
mutex_unlock(&fh->cap.lock);
mutex_unlock(&fh->cap.vb_lock);
buf = (struct bttv_buffer*)fh->cap.read_buf;
}

Expand All @@ -3209,6 +3204,9 @@ static unsigned int bttv_poll(struct file *file, poll_table *wait)
buf->vb.state == VIDEOBUF_ERROR)
return POLLIN|POLLRDNORM;
return 0;
err:
mutex_unlock(&fh->cap.vb_lock);
return POLLERR;
}

static int bttv_open(struct inode *inode, struct file *file)
Expand Down
4 changes: 2 additions & 2 deletions drivers/media/video/bt8xx/bttv-vbi.c
Original file line number Diff line number Diff line change
Expand Up @@ -352,13 +352,13 @@ int bttv_s_fmt_vbi(struct file *file, void *f, struct v4l2_format *frt)
because vbi_fmt.end counts field lines times two. */
end = max(frt->fmt.vbi.start[0], start1) * 2 + 2;

mutex_lock(&fh->vbi.lock);
mutex_lock(&fh->vbi.vb_lock);

fh->vbi_fmt.fmt = frt->fmt.vbi;
fh->vbi_fmt.tvnorm = tvnorm;
fh->vbi_fmt.end = end;

mutex_unlock(&fh->vbi.lock);
mutex_unlock(&fh->vbi.vb_lock);

rc = 0;

Expand Down
8 changes: 4 additions & 4 deletions drivers/media/video/saa7134/saa7134-empress.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ static int ts_open(struct inode *inode, struct file *file)

dprintk("open minor=%d\n",minor);
err = -EBUSY;
if (!mutex_trylock(&dev->empress_tsq.lock))
if (!mutex_trylock(&dev->empress_tsq.vb_lock))
goto done;
if (dev->empress_users)
goto done_up;
Expand All @@ -101,7 +101,7 @@ static int ts_open(struct inode *inode, struct file *file)
err = 0;

done_up:
mutex_unlock(&dev->empress_tsq.lock);
mutex_unlock(&dev->empress_tsq.vb_lock);
done:
return err;
}
Expand All @@ -110,7 +110,7 @@ static int ts_release(struct inode *inode, struct file *file)
{
struct saa7134_dev *dev = file->private_data;

mutex_lock(&dev->empress_tsq.lock);
mutex_lock(&dev->empress_tsq.vb_lock);
videobuf_stop(&dev->empress_tsq);
videobuf_mmap_free(&dev->empress_tsq);
dev->empress_users--;
Expand All @@ -122,7 +122,7 @@ static int ts_release(struct inode *inode, struct file *file)
saa_writeb(SAA7134_AUDIO_MUTE_CTRL,
saa_readb(SAA7134_AUDIO_MUTE_CTRL) | (1 << 6));

mutex_unlock(&dev->empress_tsq.lock);
mutex_unlock(&dev->empress_tsq.vb_lock);
return 0;
}

Expand Down
20 changes: 10 additions & 10 deletions drivers/media/video/saa7134/saa7134-video.c
Original file line number Diff line number Diff line change
Expand Up @@ -1414,21 +1414,17 @@ video_poll(struct file *file, struct poll_table_struct *wait)
if (!list_empty(&fh->cap.stream))
buf = list_entry(fh->cap.stream.next, struct videobuf_buffer, stream);
} else {
mutex_lock(&fh->cap.lock);
mutex_lock(&fh->cap.vb_lock);
if (UNSET == fh->cap.read_off) {
/* need to capture a new frame */
if (res_locked(fh->dev,RESOURCE_VIDEO)) {
mutex_unlock(&fh->cap.lock);
return POLLERR;
}
if (0 != fh->cap.ops->buf_prepare(&fh->cap,fh->cap.read_buf,fh->cap.field)) {
mutex_unlock(&fh->cap.lock);
return POLLERR;
}
if (res_locked(fh->dev,RESOURCE_VIDEO))
goto err;
if (0 != fh->cap.ops->buf_prepare(&fh->cap,fh->cap.read_buf,fh->cap.field))
goto err;
fh->cap.ops->buf_queue(&fh->cap,fh->cap.read_buf);
fh->cap.read_off = 0;
}
mutex_unlock(&fh->cap.lock);
mutex_unlock(&fh->cap.vb_lock);
buf = fh->cap.read_buf;
}

Expand All @@ -1440,6 +1436,10 @@ video_poll(struct file *file, struct poll_table_struct *wait)
buf->state == VIDEOBUF_ERROR)
return POLLIN|POLLRDNORM;
return 0;

err:
mutex_unlock(&fh->cap.vb_lock);
return POLLERR;
}

static int video_release(struct inode *inode, struct file *file)
Expand Down
Loading

0 comments on commit 64f9477

Please sign in to comment.