aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@redhat.com>2010-09-14 11:19:51 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-10-20 23:06:12 -0400
commit8822f0d60b7cd550465e7d07dbe02084f5476d91 (patch)
tree437ed9b7082f7d0a2217d9ec23579886b8279455
parentf2f8e8503e16985a784ed4e3fc5125fd5f86adf6 (diff)
V4L/DVB: bttv-driver: document functions using mutex_lock
There are a few ancillary static routines used by ioctl functions that takes bttv lock internally. As we'll be adding the same lock for all ioctl's that need, we need to properly document them, to avoid doing double locks Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/video/bt8xx/bttv-driver.c50
1 files changed, 25 insertions, 25 deletions
diff --git a/drivers/media/video/bt8xx/bttv-driver.c b/drivers/media/video/bt8xx/bttv-driver.c
index 38c7f78ad9cf..fcafe2f1e5cf 100644
--- a/drivers/media/video/bt8xx/bttv-driver.c
+++ b/drivers/media/video/bt8xx/bttv-driver.c
@@ -842,7 +842,7 @@ static const struct v4l2_queryctrl *ctrl_by_id(int id)
842 RESOURCE_OVERLAY) 842 RESOURCE_OVERLAY)
843 843
844static 844static
845int check_alloc_btres(struct bttv *btv, struct bttv_fh *fh, int bit) 845int check_alloc_btres_lock(struct bttv *btv, struct bttv_fh *fh, int bit)
846{ 846{
847 int xbits; /* mutual exclusive resources */ 847 int xbits; /* mutual exclusive resources */
848 848
@@ -935,7 +935,7 @@ disclaim_video_lines(struct bttv *btv)
935} 935}
936 936
937static 937static
938void free_btres(struct bttv *btv, struct bttv_fh *fh, int bits) 938void free_btres_lock(struct bttv *btv, struct bttv_fh *fh, int bits)
939{ 939{
940 if ((fh->resources & bits) != bits) { 940 if ((fh->resources & bits) != bits) {
941 /* trying to free ressources not allocated by us ... */ 941 /* trying to free ressources not allocated by us ... */
@@ -1682,7 +1682,7 @@ bttv_switch_overlay(struct bttv *btv, struct bttv_fh *fh,
1682 kfree(old); 1682 kfree(old);
1683 } 1683 }
1684 if (NULL == new) 1684 if (NULL == new)
1685 free_btres(btv,fh,RESOURCE_OVERLAY); 1685 free_btres_lock(btv,fh,RESOURCE_OVERLAY);
1686 dprintk("switch_overlay: done\n"); 1686 dprintk("switch_overlay: done\n");
1687 return retval; 1687 return retval;
1688} 1688}
@@ -2124,7 +2124,7 @@ bttv_crop_adjust (struct bttv_crop * c,
2124 also adjust the current cropping parameters to get closer to the 2124 also adjust the current cropping parameters to get closer to the
2125 desired image size. */ 2125 desired image size. */
2126static int 2126static int
2127limit_scaled_size (struct bttv_fh * fh, 2127limit_scaled_size_lock (struct bttv_fh * fh,
2128 __s32 * width, 2128 __s32 * width,
2129 __s32 * height, 2129 __s32 * height,
2130 enum v4l2_field field, 2130 enum v4l2_field field,
@@ -2238,7 +2238,7 @@ limit_scaled_size (struct bttv_fh * fh,
2238 may also adjust the current cropping parameters to get closer 2238 may also adjust the current cropping parameters to get closer
2239 to the desired window size. */ 2239 to the desired window size. */
2240static int 2240static int
2241verify_window (struct bttv_fh * fh, 2241verify_window_lock (struct bttv_fh * fh,
2242 struct v4l2_window * win, 2242 struct v4l2_window * win,
2243 int adjust_size, 2243 int adjust_size,
2244 int adjust_crop) 2244 int adjust_crop)
@@ -2292,7 +2292,7 @@ verify_window (struct bttv_fh * fh,
2292 win->w.width -= win->w.left & ~width_mask; 2292 win->w.width -= win->w.left & ~width_mask;
2293 win->w.left = (win->w.left - width_mask - 1) & width_mask; 2293 win->w.left = (win->w.left - width_mask - 1) & width_mask;
2294 2294
2295 rc = limit_scaled_size(fh, &win->w.width, &win->w.height, 2295 rc = limit_scaled_size_lock(fh, &win->w.width, &win->w.height,
2296 field, width_mask, 2296 field, width_mask,
2297 /* width_bias: round down */ 0, 2297 /* width_bias: round down */ 0,
2298 adjust_size, adjust_crop); 2298 adjust_size, adjust_crop);
@@ -2303,7 +2303,7 @@ verify_window (struct bttv_fh * fh,
2303 return 0; 2303 return 0;
2304} 2304}
2305 2305
2306static int setup_window(struct bttv_fh *fh, struct bttv *btv, 2306static int setup_window_lock(struct bttv_fh *fh, struct bttv *btv,
2307 struct v4l2_window *win, int fixup) 2307 struct v4l2_window *win, int fixup)
2308{ 2308{
2309 struct v4l2_clip *clips = NULL; 2309 struct v4l2_clip *clips = NULL;
@@ -2313,7 +2313,7 @@ static int setup_window(struct bttv_fh *fh, struct bttv *btv,
2313 return -EINVAL; 2313 return -EINVAL;
2314 if (!(fh->ovfmt->flags & FORMAT_FLAGS_PACKED)) 2314 if (!(fh->ovfmt->flags & FORMAT_FLAGS_PACKED))
2315 return -EINVAL; 2315 return -EINVAL;
2316 retval = verify_window(fh, win, 2316 retval = verify_window_lock(fh, win,
2317 /* adjust_size */ fixup, 2317 /* adjust_size */ fixup,
2318 /* adjust_crop */ fixup); 2318 /* adjust_crop */ fixup);
2319 if (0 != retval) 2319 if (0 != retval)
@@ -2516,7 +2516,7 @@ static int bttv_try_fmt_vid_cap(struct file *file, void *priv,
2516 width = f->fmt.pix.width; 2516 width = f->fmt.pix.width;
2517 height = f->fmt.pix.height; 2517 height = f->fmt.pix.height;
2518 2518
2519 rc = limit_scaled_size(fh, &width, &height, field, 2519 rc = limit_scaled_size_lock(fh, &width, &height, field,
2520 /* width_mask: 4 pixels */ ~3, 2520 /* width_mask: 4 pixels */ ~3,
2521 /* width_bias: nearest */ 2, 2521 /* width_bias: nearest */ 2,
2522 /* adjust_size */ 1, 2522 /* adjust_size */ 1,
@@ -2536,7 +2536,7 @@ static int bttv_try_fmt_vid_overlay(struct file *file, void *priv,
2536{ 2536{
2537 struct bttv_fh *fh = priv; 2537 struct bttv_fh *fh = priv;
2538 2538
2539 return verify_window(fh, &f->fmt.win, 2539 return verify_window_lock(fh, &f->fmt.win,
2540 /* adjust_size */ 1, 2540 /* adjust_size */ 1,
2541 /* adjust_crop */ 0); 2541 /* adjust_crop */ 0);
2542} 2542}
@@ -2563,7 +2563,7 @@ static int bttv_s_fmt_vid_cap(struct file *file, void *priv,
2563 height = f->fmt.pix.height; 2563 height = f->fmt.pix.height;
2564 field = f->fmt.pix.field; 2564 field = f->fmt.pix.field;
2565 2565
2566 retval = limit_scaled_size(fh, &width, &height, f->fmt.pix.field, 2566 retval = limit_scaled_size_lock(fh, &width, &height, f->fmt.pix.field,
2567 /* width_mask: 4 pixels */ ~3, 2567 /* width_mask: 4 pixels */ ~3,
2568 /* width_bias: nearest */ 2, 2568 /* width_bias: nearest */ 2,
2569 /* adjust_size */ 1, 2569 /* adjust_size */ 1,
@@ -2601,7 +2601,7 @@ static int bttv_s_fmt_vid_overlay(struct file *file, void *priv,
2601 return -EINVAL; 2601 return -EINVAL;
2602 } 2602 }
2603 2603
2604 return setup_window(fh, btv, &f->fmt.win, 1); 2604 return setup_window_lock(fh, btv, &f->fmt.win, 1);
2605} 2605}
2606 2606
2607#ifdef CONFIG_VIDEO_V4L1_COMPAT 2607#ifdef CONFIG_VIDEO_V4L1_COMPAT
@@ -2742,7 +2742,7 @@ static int bttv_overlay(struct file *file, void *f, unsigned int on)
2742 } 2742 }
2743 } 2743 }
2744 2744
2745 if (!check_alloc_btres(btv, fh, RESOURCE_OVERLAY)) 2745 if (!check_alloc_btres_lock(btv, fh, RESOURCE_OVERLAY))
2746 return -EBUSY; 2746 return -EBUSY;
2747 2747
2748 mutex_lock(&fh->cap.vb_lock); 2748 mutex_lock(&fh->cap.vb_lock);
@@ -2785,7 +2785,7 @@ static int bttv_s_fbuf(struct file *file, void *f,
2785 __s32 width = fb->fmt.width; 2785 __s32 width = fb->fmt.width;
2786 __s32 height = fb->fmt.height; 2786 __s32 height = fb->fmt.height;
2787 2787
2788 retval = limit_scaled_size(fh, &width, &height, 2788 retval = limit_scaled_size_lock(fh, &width, &height,
2789 V4L2_FIELD_INTERLACED, 2789 V4L2_FIELD_INTERLACED,
2790 /* width_mask */ ~3, 2790 /* width_mask */ ~3,
2791 /* width_bias */ 2, 2791 /* width_bias */ 2,
@@ -2852,7 +2852,7 @@ static int bttv_qbuf(struct file *file, void *priv, struct v4l2_buffer *b)
2852 struct bttv *btv = fh->btv; 2852 struct bttv *btv = fh->btv;
2853 int res = bttv_resource(fh); 2853 int res = bttv_resource(fh);
2854 2854
2855 if (!check_alloc_btres(btv, fh, res)) 2855 if (!check_alloc_btres_lock(btv, fh, res))
2856 return -EBUSY; 2856 return -EBUSY;
2857 2857
2858 return videobuf_qbuf(bttv_queue(fh), b); 2858 return videobuf_qbuf(bttv_queue(fh), b);
@@ -2872,7 +2872,7 @@ static int bttv_streamon(struct file *file, void *priv,
2872 struct bttv *btv = fh->btv; 2872 struct bttv *btv = fh->btv;
2873 int res = bttv_resource(fh); 2873 int res = bttv_resource(fh);
2874 2874
2875 if (!check_alloc_btres(btv, fh, res)) 2875 if (!check_alloc_btres_lock(btv, fh, res))
2876 return -EBUSY; 2876 return -EBUSY;
2877 return videobuf_streamon(bttv_queue(fh)); 2877 return videobuf_streamon(bttv_queue(fh));
2878} 2878}
@@ -2890,7 +2890,7 @@ static int bttv_streamoff(struct file *file, void *priv,
2890 retval = videobuf_streamoff(bttv_queue(fh)); 2890 retval = videobuf_streamoff(bttv_queue(fh));
2891 if (retval < 0) 2891 if (retval < 0)
2892 return retval; 2892 return retval;
2893 free_btres(btv, fh, res); 2893 free_btres_lock(btv, fh, res);
2894 return 0; 2894 return 0;
2895} 2895}
2896 2896
@@ -3030,7 +3030,7 @@ static int bttv_s_crop(struct file *file, void *f, struct v4l2_crop *crop)
3030 3030
3031 /* Make sure tvnorm, vbi_end and the current cropping 3031 /* Make sure tvnorm, vbi_end and the current cropping
3032 parameters remain consistent until we're done. Note 3032 parameters remain consistent until we're done. Note
3033 read() may change vbi_end in check_alloc_btres(). */ 3033 read() may change vbi_end in check_alloc_btres_lock(). */
3034 mutex_lock(&btv->lock); 3034 mutex_lock(&btv->lock);
3035 3035
3036 retval = -EBUSY; 3036 retval = -EBUSY;
@@ -3128,17 +3128,17 @@ static ssize_t bttv_read(struct file *file, char __user *data,
3128 3128
3129 switch (fh->type) { 3129 switch (fh->type) {
3130 case V4L2_BUF_TYPE_VIDEO_CAPTURE: 3130 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
3131 if (!check_alloc_btres(fh->btv, fh, RESOURCE_VIDEO_READ)) { 3131 if (!check_alloc_btres_lock(fh->btv, fh, RESOURCE_VIDEO_READ)) {
3132 /* VIDEO_READ in use by another fh, 3132 /* VIDEO_READ in use by another fh,
3133 or VIDEO_STREAM by any fh. */ 3133 or VIDEO_STREAM by any fh. */
3134 return -EBUSY; 3134 return -EBUSY;
3135 } 3135 }
3136 retval = videobuf_read_one(&fh->cap, data, count, ppos, 3136 retval = videobuf_read_one(&fh->cap, data, count, ppos,
3137 file->f_flags & O_NONBLOCK); 3137 file->f_flags & O_NONBLOCK);
3138 free_btres(fh->btv, fh, RESOURCE_VIDEO_READ); 3138 free_btres_lock(fh->btv, fh, RESOURCE_VIDEO_READ);
3139 break; 3139 break;
3140 case V4L2_BUF_TYPE_VBI_CAPTURE: 3140 case V4L2_BUF_TYPE_VBI_CAPTURE:
3141 if (!check_alloc_btres(fh->btv,fh,RESOURCE_VBI)) 3141 if (!check_alloc_btres_lock(fh->btv,fh,RESOURCE_VBI))
3142 return -EBUSY; 3142 return -EBUSY;
3143 retval = videobuf_read_stream(&fh->vbi, data, count, ppos, 1, 3143 retval = videobuf_read_stream(&fh->vbi, data, count, ppos, 1,
3144 file->f_flags & O_NONBLOCK); 3144 file->f_flags & O_NONBLOCK);
@@ -3157,7 +3157,7 @@ static unsigned int bttv_poll(struct file *file, poll_table *wait)
3157 unsigned int rc = POLLERR; 3157 unsigned int rc = POLLERR;
3158 3158
3159 if (V4L2_BUF_TYPE_VBI_CAPTURE == fh->type) { 3159 if (V4L2_BUF_TYPE_VBI_CAPTURE == fh->type) {
3160 if (!check_alloc_btres(fh->btv,fh,RESOURCE_VBI)) 3160 if (!check_alloc_btres_lock(fh->btv,fh,RESOURCE_VBI))
3161 return POLLERR; 3161 return POLLERR;
3162 return videobuf_poll_stream(file, &fh->vbi, wait); 3162 return videobuf_poll_stream(file, &fh->vbi, wait);
3163 } 3163 }
@@ -3288,20 +3288,20 @@ static int bttv_release(struct file *file)
3288 /* stop video capture */ 3288 /* stop video capture */
3289 if (check_btres(fh, RESOURCE_VIDEO_STREAM)) { 3289 if (check_btres(fh, RESOURCE_VIDEO_STREAM)) {
3290 videobuf_streamoff(&fh->cap); 3290 videobuf_streamoff(&fh->cap);
3291 free_btres(btv,fh,RESOURCE_VIDEO_STREAM); 3291 free_btres_lock(btv,fh,RESOURCE_VIDEO_STREAM);
3292 } 3292 }
3293 if (fh->cap.read_buf) { 3293 if (fh->cap.read_buf) {
3294 buffer_release(&fh->cap,fh->cap.read_buf); 3294 buffer_release(&fh->cap,fh->cap.read_buf);
3295 kfree(fh->cap.read_buf); 3295 kfree(fh->cap.read_buf);
3296 } 3296 }
3297 if (check_btres(fh, RESOURCE_VIDEO_READ)) { 3297 if (check_btres(fh, RESOURCE_VIDEO_READ)) {
3298 free_btres(btv, fh, RESOURCE_VIDEO_READ); 3298 free_btres_lock(btv, fh, RESOURCE_VIDEO_READ);
3299 } 3299 }
3300 3300
3301 /* stop vbi capture */ 3301 /* stop vbi capture */
3302 if (check_btres(fh, RESOURCE_VBI)) { 3302 if (check_btres(fh, RESOURCE_VBI)) {
3303 videobuf_stop(&fh->vbi); 3303 videobuf_stop(&fh->vbi);
3304 free_btres(btv,fh,RESOURCE_VBI); 3304 free_btres_lock(btv,fh,RESOURCE_VBI);
3305 } 3305 }
3306 3306
3307 /* free stuff */ 3307 /* free stuff */