diff options
author | Ingo Molnar <mingo@elte.hu> | 2006-02-07 03:49:14 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2006-02-07 03:49:14 -0500 |
commit | 3593cab5d62c4c7abced1076710f9bc2d8847433 (patch) | |
tree | dd5dc21961f6b4aef6900b0c2eb63ce7c70aecd5 /drivers/media/video | |
parent | 538f9630afbbe429ecbcdcf92536200293a8e4b3 (diff) |
V4L/DVB (3318b): sem2mutex: drivers/media/, #2
Semaphore to mutex conversion.
The conversion was generated via scripts, and the result was validated
automatically via a script as well.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video')
30 files changed, 366 insertions, 353 deletions
diff --git a/drivers/media/video/arv.c b/drivers/media/video/arv.c index 994b75fe165a..c586f64b6b7f 100644 --- a/drivers/media/video/arv.c +++ b/drivers/media/video/arv.c | |||
@@ -31,8 +31,8 @@ | |||
31 | #include <linux/mm.h> | 31 | #include <linux/mm.h> |
32 | #include <linux/sched.h> | 32 | #include <linux/sched.h> |
33 | #include <linux/videodev.h> | 33 | #include <linux/videodev.h> |
34 | #include <linux/mutex.h> | ||
34 | 35 | ||
35 | #include <asm/semaphore.h> | ||
36 | #include <asm/uaccess.h> | 36 | #include <asm/uaccess.h> |
37 | #include <asm/m32r.h> | 37 | #include <asm/m32r.h> |
38 | #include <asm/io.h> | 38 | #include <asm/io.h> |
@@ -117,7 +117,7 @@ struct ar_device { | |||
117 | int width, height; | 117 | int width, height; |
118 | int frame_bytes, line_bytes; | 118 | int frame_bytes, line_bytes; |
119 | wait_queue_head_t wait; | 119 | wait_queue_head_t wait; |
120 | struct semaphore lock; | 120 | struct mutex lock; |
121 | }; | 121 | }; |
122 | 122 | ||
123 | static int video_nr = -1; /* video device number (first free) */ | 123 | static int video_nr = -1; /* video device number (first free) */ |
@@ -288,7 +288,7 @@ static ssize_t ar_read(struct file *file, char *buf, size_t count, loff_t *ppos) | |||
288 | if (ar->mode == AR_MODE_NORMAL) | 288 | if (ar->mode == AR_MODE_NORMAL) |
289 | arvcr1 |= ARVCR1_NORMAL; | 289 | arvcr1 |= ARVCR1_NORMAL; |
290 | 290 | ||
291 | down(&ar->lock); | 291 | mutex_lock(&ar->lock); |
292 | 292 | ||
293 | #if USE_INT | 293 | #if USE_INT |
294 | local_irq_save(flags); | 294 | local_irq_save(flags); |
@@ -392,7 +392,7 @@ static ssize_t ar_read(struct file *file, char *buf, size_t count, loff_t *ppos) | |||
392 | } | 392 | } |
393 | DEBUG(1, "ret = %d\n", ret); | 393 | DEBUG(1, "ret = %d\n", ret); |
394 | out_up: | 394 | out_up: |
395 | up(&ar->lock); | 395 | mutex_unlock(&ar->lock); |
396 | return ret; | 396 | return ret; |
397 | } | 397 | } |
398 | 398 | ||
@@ -456,7 +456,7 @@ static int ar_do_ioctl(struct inode *inode, struct file *file, | |||
456 | (w->width != AR_WIDTH_QVGA || w->height != AR_HEIGHT_QVGA)) | 456 | (w->width != AR_WIDTH_QVGA || w->height != AR_HEIGHT_QVGA)) |
457 | return -EINVAL; | 457 | return -EINVAL; |
458 | 458 | ||
459 | down(&ar->lock); | 459 | mutex_lock(&ar->lock); |
460 | ar->width = w->width; | 460 | ar->width = w->width; |
461 | ar->height = w->height; | 461 | ar->height = w->height; |
462 | if (ar->width == AR_WIDTH_VGA) { | 462 | if (ar->width == AR_WIDTH_VGA) { |
@@ -473,7 +473,7 @@ static int ar_do_ioctl(struct inode *inode, struct file *file, | |||
473 | ar->line_bytes = AR_LINE_BYTES_QVGA; | 473 | ar->line_bytes = AR_LINE_BYTES_QVGA; |
474 | ar->mode = AR_MODE_INTERLACE; | 474 | ar->mode = AR_MODE_INTERLACE; |
475 | } | 475 | } |
476 | up(&ar->lock); | 476 | mutex_unlock(&ar->lock); |
477 | return 0; | 477 | return 0; |
478 | } | 478 | } |
479 | case VIDIOCGFBUF: | 479 | case VIDIOCGFBUF: |
@@ -734,7 +734,7 @@ static int ar_initialize(struct video_device *dev) | |||
734 | void ar_release(struct video_device *vfd) | 734 | void ar_release(struct video_device *vfd) |
735 | { | 735 | { |
736 | struct ar_device *ar = vfd->priv; | 736 | struct ar_device *ar = vfd->priv; |
737 | down(&ar->lock); | 737 | mutex_lock(&ar->lock); |
738 | video_device_release(vfd); | 738 | video_device_release(vfd); |
739 | } | 739 | } |
740 | 740 | ||
@@ -824,7 +824,7 @@ static int __init ar_init(void) | |||
824 | ar->line_bytes = AR_LINE_BYTES_QVGA; | 824 | ar->line_bytes = AR_LINE_BYTES_QVGA; |
825 | ar->mode = AR_MODE_INTERLACE; | 825 | ar->mode = AR_MODE_INTERLACE; |
826 | } | 826 | } |
827 | init_MUTEX(&ar->lock); | 827 | mutex_init(&ar->lock); |
828 | init_waitqueue_head(&ar->wait); | 828 | init_waitqueue_head(&ar->wait); |
829 | 829 | ||
830 | #if USE_INT | 830 | #if USE_INT |
diff --git a/drivers/media/video/bttv-driver.c b/drivers/media/video/bttv-driver.c index 578b20085082..c0415d6e7fee 100644 --- a/drivers/media/video/bttv-driver.c +++ b/drivers/media/video/bttv-driver.c | |||
@@ -1965,7 +1965,7 @@ static int setup_window(struct bttv_fh *fh, struct bttv *btv, | |||
1965 | BUG(); | 1965 | BUG(); |
1966 | } | 1966 | } |
1967 | 1967 | ||
1968 | down(&fh->cap.lock); | 1968 | mutex_lock(&fh->cap.lock); |
1969 | kfree(fh->ov.clips); | 1969 | kfree(fh->ov.clips); |
1970 | fh->ov.clips = clips; | 1970 | fh->ov.clips = clips; |
1971 | fh->ov.nclips = n; | 1971 | fh->ov.nclips = n; |
@@ -1986,7 +1986,7 @@ static int setup_window(struct bttv_fh *fh, struct bttv *btv, | |||
1986 | bttv_overlay_risc(btv, &fh->ov, fh->ovfmt, new); | 1986 | bttv_overlay_risc(btv, &fh->ov, fh->ovfmt, new); |
1987 | retval = bttv_switch_overlay(btv,fh,new); | 1987 | retval = bttv_switch_overlay(btv,fh,new); |
1988 | } | 1988 | } |
1989 | up(&fh->cap.lock); | 1989 | mutex_unlock(&fh->cap.lock); |
1990 | return retval; | 1990 | return retval; |
1991 | } | 1991 | } |
1992 | 1992 | ||
@@ -2166,7 +2166,7 @@ static int bttv_s_fmt(struct bttv_fh *fh, struct bttv *btv, | |||
2166 | fmt = format_by_fourcc(f->fmt.pix.pixelformat); | 2166 | fmt = format_by_fourcc(f->fmt.pix.pixelformat); |
2167 | 2167 | ||
2168 | /* update our state informations */ | 2168 | /* update our state informations */ |
2169 | down(&fh->cap.lock); | 2169 | mutex_lock(&fh->cap.lock); |
2170 | fh->fmt = fmt; | 2170 | fh->fmt = fmt; |
2171 | fh->cap.field = f->fmt.pix.field; | 2171 | fh->cap.field = f->fmt.pix.field; |
2172 | fh->cap.last = V4L2_FIELD_NONE; | 2172 | fh->cap.last = V4L2_FIELD_NONE; |
@@ -2175,7 +2175,7 @@ static int bttv_s_fmt(struct bttv_fh *fh, struct bttv *btv, | |||
2175 | btv->init.fmt = fmt; | 2175 | btv->init.fmt = fmt; |
2176 | btv->init.width = f->fmt.pix.width; | 2176 | btv->init.width = f->fmt.pix.width; |
2177 | btv->init.height = f->fmt.pix.height; | 2177 | btv->init.height = f->fmt.pix.height; |
2178 | up(&fh->cap.lock); | 2178 | mutex_unlock(&fh->cap.lock); |
2179 | 2179 | ||
2180 | return 0; | 2180 | return 0; |
2181 | } | 2181 | } |
@@ -2282,7 +2282,7 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file, | |||
2282 | fmt = format_by_palette(pic->palette); | 2282 | fmt = format_by_palette(pic->palette); |
2283 | if (NULL == fmt) | 2283 | if (NULL == fmt) |
2284 | return -EINVAL; | 2284 | return -EINVAL; |
2285 | down(&fh->cap.lock); | 2285 | mutex_lock(&fh->cap.lock); |
2286 | if (fmt->depth != pic->depth) { | 2286 | if (fmt->depth != pic->depth) { |
2287 | retval = -EINVAL; | 2287 | retval = -EINVAL; |
2288 | goto fh_unlock_and_return; | 2288 | goto fh_unlock_and_return; |
@@ -2313,7 +2313,7 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file, | |||
2313 | bt848_contrast(btv,pic->contrast); | 2313 | bt848_contrast(btv,pic->contrast); |
2314 | bt848_hue(btv,pic->hue); | 2314 | bt848_hue(btv,pic->hue); |
2315 | bt848_sat(btv,pic->colour); | 2315 | bt848_sat(btv,pic->colour); |
2316 | up(&fh->cap.lock); | 2316 | mutex_unlock(&fh->cap.lock); |
2317 | return 0; | 2317 | return 0; |
2318 | } | 2318 | } |
2319 | 2319 | ||
@@ -2379,7 +2379,7 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file, | |||
2379 | return -EPERM; | 2379 | return -EPERM; |
2380 | end = (unsigned long)fbuf->base + | 2380 | end = (unsigned long)fbuf->base + |
2381 | fbuf->height * fbuf->bytesperline; | 2381 | fbuf->height * fbuf->bytesperline; |
2382 | down(&fh->cap.lock); | 2382 | mutex_lock(&fh->cap.lock); |
2383 | retval = -EINVAL; | 2383 | retval = -EINVAL; |
2384 | 2384 | ||
2385 | switch (fbuf->depth) { | 2385 | switch (fbuf->depth) { |
@@ -2417,7 +2417,7 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file, | |||
2417 | btv->fbuf.fmt.bytesperline = fbuf->bytesperline; | 2417 | btv->fbuf.fmt.bytesperline = fbuf->bytesperline; |
2418 | else | 2418 | else |
2419 | btv->fbuf.fmt.bytesperline = btv->fbuf.fmt.width*fbuf->depth/8; | 2419 | btv->fbuf.fmt.bytesperline = btv->fbuf.fmt.width*fbuf->depth/8; |
2420 | up(&fh->cap.lock); | 2420 | mutex_unlock(&fh->cap.lock); |
2421 | return 0; | 2421 | return 0; |
2422 | } | 2422 | } |
2423 | 2423 | ||
@@ -2440,7 +2440,7 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file, | |||
2440 | if (!check_alloc_btres(btv,fh,RESOURCE_OVERLAY)) | 2440 | if (!check_alloc_btres(btv,fh,RESOURCE_OVERLAY)) |
2441 | return -EBUSY; | 2441 | return -EBUSY; |
2442 | 2442 | ||
2443 | down(&fh->cap.lock); | 2443 | mutex_lock(&fh->cap.lock); |
2444 | if (*on) { | 2444 | if (*on) { |
2445 | fh->ov.tvnorm = btv->tvnorm; | 2445 | fh->ov.tvnorm = btv->tvnorm; |
2446 | new = videobuf_alloc(sizeof(*new)); | 2446 | new = videobuf_alloc(sizeof(*new)); |
@@ -2451,7 +2451,7 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file, | |||
2451 | 2451 | ||
2452 | /* switch over */ | 2452 | /* switch over */ |
2453 | retval = bttv_switch_overlay(btv,fh,new); | 2453 | retval = bttv_switch_overlay(btv,fh,new); |
2454 | up(&fh->cap.lock); | 2454 | mutex_unlock(&fh->cap.lock); |
2455 | return retval; | 2455 | return retval; |
2456 | } | 2456 | } |
2457 | 2457 | ||
@@ -2460,7 +2460,7 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file, | |||
2460 | struct video_mbuf *mbuf = arg; | 2460 | struct video_mbuf *mbuf = arg; |
2461 | unsigned int i; | 2461 | unsigned int i; |
2462 | 2462 | ||
2463 | down(&fh->cap.lock); | 2463 | mutex_lock(&fh->cap.lock); |
2464 | retval = videobuf_mmap_setup(&fh->cap,gbuffers,gbufsize, | 2464 | retval = videobuf_mmap_setup(&fh->cap,gbuffers,gbufsize, |
2465 | V4L2_MEMORY_MMAP); | 2465 | V4L2_MEMORY_MMAP); |
2466 | if (retval < 0) | 2466 | if (retval < 0) |
@@ -2470,7 +2470,7 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file, | |||
2470 | mbuf->size = gbuffers * gbufsize; | 2470 | mbuf->size = gbuffers * gbufsize; |
2471 | for (i = 0; i < gbuffers; i++) | 2471 | for (i = 0; i < gbuffers; i++) |
2472 | mbuf->offsets[i] = i * gbufsize; | 2472 | mbuf->offsets[i] = i * gbufsize; |
2473 | up(&fh->cap.lock); | 2473 | mutex_unlock(&fh->cap.lock); |
2474 | return 0; | 2474 | return 0; |
2475 | } | 2475 | } |
2476 | case VIDIOCMCAPTURE: | 2476 | case VIDIOCMCAPTURE: |
@@ -2482,7 +2482,7 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file, | |||
2482 | if (vm->frame >= VIDEO_MAX_FRAME) | 2482 | if (vm->frame >= VIDEO_MAX_FRAME) |
2483 | return -EINVAL; | 2483 | return -EINVAL; |
2484 | 2484 | ||
2485 | down(&fh->cap.lock); | 2485 | mutex_lock(&fh->cap.lock); |
2486 | retval = -EINVAL; | 2486 | retval = -EINVAL; |
2487 | buf = (struct bttv_buffer *)fh->cap.bufs[vm->frame]; | 2487 | buf = (struct bttv_buffer *)fh->cap.bufs[vm->frame]; |
2488 | if (NULL == buf) | 2488 | if (NULL == buf) |
@@ -2504,7 +2504,7 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file, | |||
2504 | spin_lock_irqsave(&btv->s_lock,flags); | 2504 | spin_lock_irqsave(&btv->s_lock,flags); |
2505 | buffer_queue(&fh->cap,&buf->vb); | 2505 | buffer_queue(&fh->cap,&buf->vb); |
2506 | spin_unlock_irqrestore(&btv->s_lock,flags); | 2506 | spin_unlock_irqrestore(&btv->s_lock,flags); |
2507 | up(&fh->cap.lock); | 2507 | mutex_unlock(&fh->cap.lock); |
2508 | return 0; | 2508 | return 0; |
2509 | } | 2509 | } |
2510 | case VIDIOCSYNC: | 2510 | case VIDIOCSYNC: |
@@ -2515,7 +2515,7 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file, | |||
2515 | if (*frame >= VIDEO_MAX_FRAME) | 2515 | if (*frame >= VIDEO_MAX_FRAME) |
2516 | return -EINVAL; | 2516 | return -EINVAL; |
2517 | 2517 | ||
2518 | down(&fh->cap.lock); | 2518 | mutex_lock(&fh->cap.lock); |
2519 | retval = -EINVAL; | 2519 | retval = -EINVAL; |
2520 | buf = (struct bttv_buffer *)fh->cap.bufs[*frame]; | 2520 | buf = (struct bttv_buffer *)fh->cap.bufs[*frame]; |
2521 | if (NULL == buf) | 2521 | if (NULL == buf) |
@@ -2535,7 +2535,7 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file, | |||
2535 | retval = -EINVAL; | 2535 | retval = -EINVAL; |
2536 | break; | 2536 | break; |
2537 | } | 2537 | } |
2538 | up(&fh->cap.lock); | 2538 | mutex_unlock(&fh->cap.lock); |
2539 | return retval; | 2539 | return retval; |
2540 | } | 2540 | } |
2541 | 2541 | ||
@@ -2719,7 +2719,7 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file, | |||
2719 | if (0 == (fmt->flags & FORMAT_FLAGS_PACKED)) | 2719 | if (0 == (fmt->flags & FORMAT_FLAGS_PACKED)) |
2720 | return -EINVAL; | 2720 | return -EINVAL; |
2721 | 2721 | ||
2722 | down(&fh->cap.lock); | 2722 | mutex_lock(&fh->cap.lock); |
2723 | retval = -EINVAL; | 2723 | retval = -EINVAL; |
2724 | if (fb->flags & V4L2_FBUF_FLAG_OVERLAY) { | 2724 | if (fb->flags & V4L2_FBUF_FLAG_OVERLAY) { |
2725 | if (fb->fmt.width > bttv_tvnorms[btv->tvnorm].swidth) | 2725 | if (fb->fmt.width > bttv_tvnorms[btv->tvnorm].swidth) |
@@ -2759,7 +2759,7 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file, | |||
2759 | retval = bttv_switch_overlay(btv,fh,new); | 2759 | retval = bttv_switch_overlay(btv,fh,new); |
2760 | } | 2760 | } |
2761 | } | 2761 | } |
2762 | up(&fh->cap.lock); | 2762 | mutex_unlock(&fh->cap.lock); |
2763 | return retval; | 2763 | return retval; |
2764 | } | 2764 | } |
2765 | 2765 | ||
@@ -2890,7 +2890,7 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file, | |||
2890 | return 0; | 2890 | return 0; |
2891 | 2891 | ||
2892 | fh_unlock_and_return: | 2892 | fh_unlock_and_return: |
2893 | up(&fh->cap.lock); | 2893 | mutex_unlock(&fh->cap.lock); |
2894 | return retval; | 2894 | return retval; |
2895 | } | 2895 | } |
2896 | 2896 | ||
@@ -2957,16 +2957,16 @@ static unsigned int bttv_poll(struct file *file, poll_table *wait) | |||
2957 | buf = list_entry(fh->cap.stream.next,struct bttv_buffer,vb.stream); | 2957 | buf = list_entry(fh->cap.stream.next,struct bttv_buffer,vb.stream); |
2958 | } else { | 2958 | } else { |
2959 | /* read() capture */ | 2959 | /* read() capture */ |
2960 | down(&fh->cap.lock); | 2960 | mutex_lock(&fh->cap.lock); |
2961 | if (NULL == fh->cap.read_buf) { | 2961 | if (NULL == fh->cap.read_buf) { |
2962 | /* need to capture a new frame */ | 2962 | /* need to capture a new frame */ |
2963 | if (locked_btres(fh->btv,RESOURCE_VIDEO)) { | 2963 | if (locked_btres(fh->btv,RESOURCE_VIDEO)) { |
2964 | up(&fh->cap.lock); | 2964 | mutex_unlock(&fh->cap.lock); |
2965 | return POLLERR; | 2965 | return POLLERR; |
2966 | } | 2966 | } |
2967 | fh->cap.read_buf = videobuf_alloc(fh->cap.msize); | 2967 | fh->cap.read_buf = videobuf_alloc(fh->cap.msize); |
2968 | if (NULL == fh->cap.read_buf) { | 2968 | if (NULL == fh->cap.read_buf) { |
2969 | up(&fh->cap.lock); | 2969 | mutex_unlock(&fh->cap.lock); |
2970 | return POLLERR; | 2970 | return POLLERR; |
2971 | } | 2971 | } |
2972 | fh->cap.read_buf->memory = V4L2_MEMORY_USERPTR; | 2972 | fh->cap.read_buf->memory = V4L2_MEMORY_USERPTR; |
@@ -2974,13 +2974,13 @@ static unsigned int bttv_poll(struct file *file, poll_table *wait) | |||
2974 | if (0 != fh->cap.ops->buf_prepare(&fh->cap,fh->cap.read_buf,field)) { | 2974 | if (0 != fh->cap.ops->buf_prepare(&fh->cap,fh->cap.read_buf,field)) { |
2975 | kfree (fh->cap.read_buf); | 2975 | kfree (fh->cap.read_buf); |
2976 | fh->cap.read_buf = NULL; | 2976 | fh->cap.read_buf = NULL; |
2977 | up(&fh->cap.lock); | 2977 | mutex_unlock(&fh->cap.lock); |
2978 | return POLLERR; | 2978 | return POLLERR; |
2979 | } | 2979 | } |
2980 | fh->cap.ops->buf_queue(&fh->cap,fh->cap.read_buf); | 2980 | fh->cap.ops->buf_queue(&fh->cap,fh->cap.read_buf); |
2981 | fh->cap.read_off = 0; | 2981 | fh->cap.read_off = 0; |
2982 | } | 2982 | } |
2983 | up(&fh->cap.lock); | 2983 | mutex_unlock(&fh->cap.lock); |
2984 | buf = (struct bttv_buffer*)fh->cap.read_buf; | 2984 | buf = (struct bttv_buffer*)fh->cap.read_buf; |
2985 | } | 2985 | } |
2986 | 2986 | ||
diff --git a/drivers/media/video/bw-qcam.c b/drivers/media/video/bw-qcam.c index 6bad93ef969f..d97b7d8ac33d 100644 --- a/drivers/media/video/bw-qcam.c +++ b/drivers/media/video/bw-qcam.c | |||
@@ -73,7 +73,7 @@ OTHER DEALINGS IN THE SOFTWARE. | |||
73 | #include <linux/parport.h> | 73 | #include <linux/parport.h> |
74 | #include <linux/sched.h> | 74 | #include <linux/sched.h> |
75 | #include <linux/videodev.h> | 75 | #include <linux/videodev.h> |
76 | #include <asm/semaphore.h> | 76 | #include <linux/mutex.h> |
77 | #include <asm/uaccess.h> | 77 | #include <asm/uaccess.h> |
78 | 78 | ||
79 | #include "bw-qcam.h" | 79 | #include "bw-qcam.h" |
@@ -168,7 +168,7 @@ static struct qcam_device *qcam_init(struct parport *port) | |||
168 | 168 | ||
169 | memcpy(&q->vdev, &qcam_template, sizeof(qcam_template)); | 169 | memcpy(&q->vdev, &qcam_template, sizeof(qcam_template)); |
170 | 170 | ||
171 | init_MUTEX(&q->lock); | 171 | mutex_init(&q->lock); |
172 | 172 | ||
173 | q->port_mode = (QC_ANY | QC_NOTSET); | 173 | q->port_mode = (QC_ANY | QC_NOTSET); |
174 | q->width = 320; | 174 | q->width = 320; |
@@ -772,9 +772,9 @@ static int qcam_do_ioctl(struct inode *inode, struct file *file, | |||
772 | qcam->whitebal = p->whiteness>>8; | 772 | qcam->whitebal = p->whiteness>>8; |
773 | qcam->bpp = p->depth; | 773 | qcam->bpp = p->depth; |
774 | 774 | ||
775 | down(&qcam->lock); | 775 | mutex_lock(&qcam->lock); |
776 | qc_setscanmode(qcam); | 776 | qc_setscanmode(qcam); |
777 | up(&qcam->lock); | 777 | mutex_unlock(&qcam->lock); |
778 | qcam->status |= QC_PARAM_CHANGE; | 778 | qcam->status |= QC_PARAM_CHANGE; |
779 | 779 | ||
780 | return 0; | 780 | return 0; |
@@ -805,9 +805,9 @@ static int qcam_do_ioctl(struct inode *inode, struct file *file, | |||
805 | qcam->height = 240; | 805 | qcam->height = 240; |
806 | qcam->transfer_scale = 1; | 806 | qcam->transfer_scale = 1; |
807 | } | 807 | } |
808 | down(&qcam->lock); | 808 | mutex_lock(&qcam->lock); |
809 | qc_setscanmode(qcam); | 809 | qc_setscanmode(qcam); |
810 | up(&qcam->lock); | 810 | mutex_unlock(&qcam->lock); |
811 | 811 | ||
812 | /* We must update the camera before we grab. We could | 812 | /* We must update the camera before we grab. We could |
813 | just have changed the grab size */ | 813 | just have changed the grab size */ |
@@ -854,7 +854,7 @@ static ssize_t qcam_read(struct file *file, char __user *buf, | |||
854 | int len; | 854 | int len; |
855 | parport_claim_or_block(qcam->pdev); | 855 | parport_claim_or_block(qcam->pdev); |
856 | 856 | ||
857 | down(&qcam->lock); | 857 | mutex_lock(&qcam->lock); |
858 | 858 | ||
859 | qc_reset(qcam); | 859 | qc_reset(qcam); |
860 | 860 | ||
@@ -864,7 +864,7 @@ static ssize_t qcam_read(struct file *file, char __user *buf, | |||
864 | 864 | ||
865 | len=qc_capture(qcam, buf,count); | 865 | len=qc_capture(qcam, buf,count); |
866 | 866 | ||
867 | up(&qcam->lock); | 867 | mutex_unlock(&qcam->lock); |
868 | 868 | ||
869 | parport_release(qcam->pdev); | 869 | parport_release(qcam->pdev); |
870 | return len; | 870 | return len; |
diff --git a/drivers/media/video/bw-qcam.h b/drivers/media/video/bw-qcam.h index 723e8ad9e56a..6701dafbc0da 100644 --- a/drivers/media/video/bw-qcam.h +++ b/drivers/media/video/bw-qcam.h | |||
@@ -55,7 +55,7 @@ struct qcam_device { | |||
55 | struct video_device vdev; | 55 | struct video_device vdev; |
56 | struct pardevice *pdev; | 56 | struct pardevice *pdev; |
57 | struct parport *pport; | 57 | struct parport *pport; |
58 | struct semaphore lock; | 58 | struct mutex lock; |
59 | int width, height; | 59 | int width, height; |
60 | int bpp; | 60 | int bpp; |
61 | int mode; | 61 | int mode; |
diff --git a/drivers/media/video/c-qcam.c b/drivers/media/video/c-qcam.c index 9976db4f6da8..8211fd8d7cbf 100644 --- a/drivers/media/video/c-qcam.c +++ b/drivers/media/video/c-qcam.c | |||
@@ -34,7 +34,8 @@ | |||
34 | #include <linux/parport.h> | 34 | #include <linux/parport.h> |
35 | #include <linux/sched.h> | 35 | #include <linux/sched.h> |
36 | #include <linux/videodev.h> | 36 | #include <linux/videodev.h> |
37 | #include <asm/semaphore.h> | 37 | #include <linux/mutex.h> |
38 | |||
38 | #include <asm/uaccess.h> | 39 | #include <asm/uaccess.h> |
39 | 40 | ||
40 | struct qcam_device { | 41 | struct qcam_device { |
@@ -47,7 +48,7 @@ struct qcam_device { | |||
47 | int contrast, brightness, whitebal; | 48 | int contrast, brightness, whitebal; |
48 | int top, left; | 49 | int top, left; |
49 | unsigned int bidirectional; | 50 | unsigned int bidirectional; |
50 | struct semaphore lock; | 51 | struct mutex lock; |
51 | }; | 52 | }; |
52 | 53 | ||
53 | /* cameras maximum */ | 54 | /* cameras maximum */ |
@@ -581,11 +582,11 @@ static int qcam_do_ioctl(struct inode *inode, struct file *file, | |||
581 | qcam->contrast = p->contrast>>8; | 582 | qcam->contrast = p->contrast>>8; |
582 | qcam->whitebal = p->whiteness>>8; | 583 | qcam->whitebal = p->whiteness>>8; |
583 | 584 | ||
584 | down(&qcam->lock); | 585 | mutex_lock(&qcam->lock); |
585 | parport_claim_or_block(qcam->pdev); | 586 | parport_claim_or_block(qcam->pdev); |
586 | qc_setup(qcam); | 587 | qc_setup(qcam); |
587 | parport_release(qcam->pdev); | 588 | parport_release(qcam->pdev); |
588 | up(&qcam->lock); | 589 | mutex_unlock(&qcam->lock); |
589 | return 0; | 590 | return 0; |
590 | } | 591 | } |
591 | case VIDIOCSWIN: | 592 | case VIDIOCSWIN: |
@@ -628,11 +629,11 @@ static int qcam_do_ioctl(struct inode *inode, struct file *file, | |||
628 | #endif | 629 | #endif |
629 | /* Ok we figured out what to use from our | 630 | /* Ok we figured out what to use from our |
630 | wide choice */ | 631 | wide choice */ |
631 | down(&qcam->lock); | 632 | mutex_lock(&qcam->lock); |
632 | parport_claim_or_block(qcam->pdev); | 633 | parport_claim_or_block(qcam->pdev); |
633 | qc_setup(qcam); | 634 | qc_setup(qcam); |
634 | parport_release(qcam->pdev); | 635 | parport_release(qcam->pdev); |
635 | up(&qcam->lock); | 636 | mutex_unlock(&qcam->lock); |
636 | return 0; | 637 | return 0; |
637 | } | 638 | } |
638 | case VIDIOCGWIN: | 639 | case VIDIOCGWIN: |
@@ -672,12 +673,12 @@ static ssize_t qcam_read(struct file *file, char __user *buf, | |||
672 | struct qcam_device *qcam=(struct qcam_device *)v; | 673 | struct qcam_device *qcam=(struct qcam_device *)v; |
673 | int len; | 674 | int len; |
674 | 675 | ||
675 | down(&qcam->lock); | 676 | mutex_lock(&qcam->lock); |
676 | parport_claim_or_block(qcam->pdev); | 677 | parport_claim_or_block(qcam->pdev); |
677 | /* Probably should have a semaphore against multiple users */ | 678 | /* Probably should have a semaphore against multiple users */ |
678 | len = qc_capture(qcam, buf,count); | 679 | len = qc_capture(qcam, buf,count); |
679 | parport_release(qcam->pdev); | 680 | parport_release(qcam->pdev); |
680 | up(&qcam->lock); | 681 | mutex_unlock(&qcam->lock); |
681 | return len; | 682 | return len; |
682 | } | 683 | } |
683 | 684 | ||
@@ -727,7 +728,7 @@ static struct qcam_device *qcam_init(struct parport *port) | |||
727 | 728 | ||
728 | memcpy(&q->vdev, &qcam_template, sizeof(qcam_template)); | 729 | memcpy(&q->vdev, &qcam_template, sizeof(qcam_template)); |
729 | 730 | ||
730 | init_MUTEX(&q->lock); | 731 | mutex_init(&q->lock); |
731 | q->width = q->ccd_width = 320; | 732 | q->width = q->ccd_width = 320; |
732 | q->height = q->ccd_height = 240; | 733 | q->height = q->ccd_height = 240; |
733 | q->mode = QC_MILLIONS | QC_DECIMATION_1; | 734 | q->mode = QC_MILLIONS | QC_DECIMATION_1; |
diff --git a/drivers/media/video/cpia.c b/drivers/media/video/cpia.c index 9f59541155d9..c2405029a720 100644 --- a/drivers/media/video/cpia.c +++ b/drivers/media/video/cpia.c | |||
@@ -39,7 +39,7 @@ | |||
39 | #include <linux/pagemap.h> | 39 | #include <linux/pagemap.h> |
40 | #include <linux/delay.h> | 40 | #include <linux/delay.h> |
41 | #include <asm/io.h> | 41 | #include <asm/io.h> |
42 | #include <asm/semaphore.h> | 42 | #include <linux/mutex.h> |
43 | 43 | ||
44 | #ifdef CONFIG_KMOD | 44 | #ifdef CONFIG_KMOD |
45 | #include <linux/kmod.h> | 45 | #include <linux/kmod.h> |
@@ -622,7 +622,7 @@ static int cpia_write_proc(struct file *file, const char __user *buf, | |||
622 | 622 | ||
623 | buffer = page; | 623 | buffer = page; |
624 | 624 | ||
625 | if (down_interruptible(&cam->param_lock)) | 625 | if (mutex_lock_interruptible(&cam->param_lock)) |
626 | return -ERESTARTSYS; | 626 | return -ERESTARTSYS; |
627 | 627 | ||
628 | /* | 628 | /* |
@@ -1350,7 +1350,7 @@ static int cpia_write_proc(struct file *file, const char __user *buf, | |||
1350 | } else | 1350 | } else |
1351 | DBG("error: %d\n", retval); | 1351 | DBG("error: %d\n", retval); |
1352 | 1352 | ||
1353 | up(&cam->param_lock); | 1353 | mutex_unlock(&cam->param_lock); |
1354 | 1354 | ||
1355 | out: | 1355 | out: |
1356 | free_page((unsigned long)page); | 1356 | free_page((unsigned long)page); |
@@ -1664,7 +1664,7 @@ static int do_command(struct cam_data *cam, u16 command, u8 a, u8 b, u8 c, u8 d) | |||
1664 | case CPIA_COMMAND_GetColourParams: | 1664 | case CPIA_COMMAND_GetColourParams: |
1665 | case CPIA_COMMAND_GetColourBalance: | 1665 | case CPIA_COMMAND_GetColourBalance: |
1666 | case CPIA_COMMAND_GetExposure: | 1666 | case CPIA_COMMAND_GetExposure: |
1667 | down(&cam->param_lock); | 1667 | mutex_lock(&cam->param_lock); |
1668 | datasize=8; | 1668 | datasize=8; |
1669 | break; | 1669 | break; |
1670 | case CPIA_COMMAND_ReadMCPorts: | 1670 | case CPIA_COMMAND_ReadMCPorts: |
@@ -1691,7 +1691,7 @@ static int do_command(struct cam_data *cam, u16 command, u8 a, u8 b, u8 c, u8 d) | |||
1691 | if (command == CPIA_COMMAND_GetColourParams || | 1691 | if (command == CPIA_COMMAND_GetColourParams || |
1692 | command == CPIA_COMMAND_GetColourBalance || | 1692 | command == CPIA_COMMAND_GetColourBalance || |
1693 | command == CPIA_COMMAND_GetExposure) | 1693 | command == CPIA_COMMAND_GetExposure) |
1694 | up(&cam->param_lock); | 1694 | mutex_unlock(&cam->param_lock); |
1695 | } else { | 1695 | } else { |
1696 | switch(command) { | 1696 | switch(command) { |
1697 | case CPIA_COMMAND_GetCPIAVersion: | 1697 | case CPIA_COMMAND_GetCPIAVersion: |
@@ -1726,13 +1726,13 @@ static int do_command(struct cam_data *cam, u16 command, u8 a, u8 b, u8 c, u8 d) | |||
1726 | cam->params.colourParams.brightness = data[0]; | 1726 | cam->params.colourParams.brightness = data[0]; |
1727 | cam->params.colourParams.contrast = data[1]; | 1727 | cam->params.colourParams.contrast = data[1]; |
1728 | cam->params.colourParams.saturation = data[2]; | 1728 | cam->params.colourParams.saturation = data[2]; |
1729 | up(&cam->param_lock); | 1729 | mutex_unlock(&cam->param_lock); |
1730 | break; | 1730 | break; |
1731 | case CPIA_COMMAND_GetColourBalance: | 1731 | case CPIA_COMMAND_GetColourBalance: |
1732 | cam->params.colourBalance.redGain = data[0]; | 1732 | cam->params.colourBalance.redGain = data[0]; |
1733 | cam->params.colourBalance.greenGain = data[1]; | 1733 | cam->params.colourBalance.greenGain = data[1]; |
1734 | cam->params.colourBalance.blueGain = data[2]; | 1734 | cam->params.colourBalance.blueGain = data[2]; |
1735 | up(&cam->param_lock); | 1735 | mutex_unlock(&cam->param_lock); |
1736 | break; | 1736 | break; |
1737 | case CPIA_COMMAND_GetExposure: | 1737 | case CPIA_COMMAND_GetExposure: |
1738 | cam->params.exposure.gain = data[0]; | 1738 | cam->params.exposure.gain = data[0]; |
@@ -1743,7 +1743,7 @@ static int do_command(struct cam_data *cam, u16 command, u8 a, u8 b, u8 c, u8 d) | |||
1743 | cam->params.exposure.green1Comp = data[5]; | 1743 | cam->params.exposure.green1Comp = data[5]; |
1744 | cam->params.exposure.green2Comp = data[6]; | 1744 | cam->params.exposure.green2Comp = data[6]; |
1745 | cam->params.exposure.blueComp = data[7]; | 1745 | cam->params.exposure.blueComp = data[7]; |
1746 | up(&cam->param_lock); | 1746 | mutex_unlock(&cam->param_lock); |
1747 | break; | 1747 | break; |
1748 | 1748 | ||
1749 | case CPIA_COMMAND_ReadMCPorts: | 1749 | case CPIA_COMMAND_ReadMCPorts: |
@@ -2059,7 +2059,7 @@ static int parse_picture(struct cam_data *cam, int size) | |||
2059 | int rows, cols, linesize, subsample_422; | 2059 | int rows, cols, linesize, subsample_422; |
2060 | 2060 | ||
2061 | /* make sure params don't change while we are decoding */ | 2061 | /* make sure params don't change while we are decoding */ |
2062 | down(&cam->param_lock); | 2062 | mutex_lock(&cam->param_lock); |
2063 | 2063 | ||
2064 | obuf = cam->decompressed_frame.data; | 2064 | obuf = cam->decompressed_frame.data; |
2065 | end_obuf = obuf+CPIA_MAX_FRAME_SIZE; | 2065 | end_obuf = obuf+CPIA_MAX_FRAME_SIZE; |
@@ -2069,26 +2069,26 @@ static int parse_picture(struct cam_data *cam, int size) | |||
2069 | 2069 | ||
2070 | if ((ibuf[0] != MAGIC_0) || (ibuf[1] != MAGIC_1)) { | 2070 | if ((ibuf[0] != MAGIC_0) || (ibuf[1] != MAGIC_1)) { |
2071 | LOG("header not found\n"); | 2071 | LOG("header not found\n"); |
2072 | up(&cam->param_lock); | 2072 | mutex_unlock(&cam->param_lock); |
2073 | return -1; | 2073 | return -1; |
2074 | } | 2074 | } |
2075 | 2075 | ||
2076 | if ((ibuf[16] != VIDEOSIZE_QCIF) && (ibuf[16] != VIDEOSIZE_CIF)) { | 2076 | if ((ibuf[16] != VIDEOSIZE_QCIF) && (ibuf[16] != VIDEOSIZE_CIF)) { |
2077 | LOG("wrong video size\n"); | 2077 | LOG("wrong video size\n"); |
2078 | up(&cam->param_lock); | 2078 | mutex_unlock(&cam->param_lock); |
2079 | return -1; | 2079 | return -1; |
2080 | } | 2080 | } |
2081 | 2081 | ||
2082 | if (ibuf[17] != SUBSAMPLE_420 && ibuf[17] != SUBSAMPLE_422) { | 2082 | if (ibuf[17] != SUBSAMPLE_420 && ibuf[17] != SUBSAMPLE_422) { |
2083 | LOG("illegal subtype %d\n",ibuf[17]); | 2083 | LOG("illegal subtype %d\n",ibuf[17]); |
2084 | up(&cam->param_lock); | 2084 | mutex_unlock(&cam->param_lock); |
2085 | return -1; | 2085 | return -1; |
2086 | } | 2086 | } |
2087 | subsample_422 = ibuf[17] == SUBSAMPLE_422; | 2087 | subsample_422 = ibuf[17] == SUBSAMPLE_422; |
2088 | 2088 | ||
2089 | if (ibuf[18] != YUVORDER_YUYV && ibuf[18] != YUVORDER_UYVY) { | 2089 | if (ibuf[18] != YUVORDER_YUYV && ibuf[18] != YUVORDER_UYVY) { |
2090 | LOG("illegal yuvorder %d\n",ibuf[18]); | 2090 | LOG("illegal yuvorder %d\n",ibuf[18]); |
2091 | up(&cam->param_lock); | 2091 | mutex_unlock(&cam->param_lock); |
2092 | return -1; | 2092 | return -1; |
2093 | } | 2093 | } |
2094 | in_uyvy = ibuf[18] == YUVORDER_UYVY; | 2094 | in_uyvy = ibuf[18] == YUVORDER_UYVY; |
@@ -2098,7 +2098,7 @@ static int parse_picture(struct cam_data *cam, int size) | |||
2098 | (ibuf[26] != cam->params.roi.rowStart) || | 2098 | (ibuf[26] != cam->params.roi.rowStart) || |
2099 | (ibuf[27] != cam->params.roi.rowEnd)) { | 2099 | (ibuf[27] != cam->params.roi.rowEnd)) { |
2100 | LOG("ROI mismatch\n"); | 2100 | LOG("ROI mismatch\n"); |
2101 | up(&cam->param_lock); | 2101 | mutex_unlock(&cam->param_lock); |
2102 | return -1; | 2102 | return -1; |
2103 | } | 2103 | } |
2104 | cols = 8*(ibuf[25] - ibuf[24]); | 2104 | cols = 8*(ibuf[25] - ibuf[24]); |
@@ -2107,14 +2107,14 @@ static int parse_picture(struct cam_data *cam, int size) | |||
2107 | 2107 | ||
2108 | if ((ibuf[28] != NOT_COMPRESSED) && (ibuf[28] != COMPRESSED)) { | 2108 | if ((ibuf[28] != NOT_COMPRESSED) && (ibuf[28] != COMPRESSED)) { |
2109 | LOG("illegal compression %d\n",ibuf[28]); | 2109 | LOG("illegal compression %d\n",ibuf[28]); |
2110 | up(&cam->param_lock); | 2110 | mutex_unlock(&cam->param_lock); |
2111 | return -1; | 2111 | return -1; |
2112 | } | 2112 | } |
2113 | compressed = (ibuf[28] == COMPRESSED); | 2113 | compressed = (ibuf[28] == COMPRESSED); |
2114 | 2114 | ||
2115 | if (ibuf[29] != NO_DECIMATION && ibuf[29] != DECIMATION_ENAB) { | 2115 | if (ibuf[29] != NO_DECIMATION && ibuf[29] != DECIMATION_ENAB) { |
2116 | LOG("illegal decimation %d\n",ibuf[29]); | 2116 | LOG("illegal decimation %d\n",ibuf[29]); |
2117 | up(&cam->param_lock); | 2117 | mutex_unlock(&cam->param_lock); |
2118 | return -1; | 2118 | return -1; |
2119 | } | 2119 | } |
2120 | decimation = (ibuf[29] == DECIMATION_ENAB); | 2120 | decimation = (ibuf[29] == DECIMATION_ENAB); |
@@ -2130,7 +2130,7 @@ static int parse_picture(struct cam_data *cam, int size) | |||
2130 | cam->params.status.vpStatus = ibuf[38]; | 2130 | cam->params.status.vpStatus = ibuf[38]; |
2131 | cam->params.status.errorCode = ibuf[39]; | 2131 | cam->params.status.errorCode = ibuf[39]; |
2132 | cam->fps = ibuf[41]; | 2132 | cam->fps = ibuf[41]; |
2133 | up(&cam->param_lock); | 2133 | mutex_unlock(&cam->param_lock); |
2134 | 2134 | ||
2135 | linesize = skipcount(cols, out_fmt); | 2135 | linesize = skipcount(cols, out_fmt); |
2136 | ibuf += FRAME_HEADER_SIZE; | 2136 | ibuf += FRAME_HEADER_SIZE; |
@@ -2271,9 +2271,9 @@ static int find_over_exposure(int brightness) | |||
2271 | /* update various camera modes and settings */ | 2271 | /* update various camera modes and settings */ |
2272 | static void dispatch_commands(struct cam_data *cam) | 2272 | static void dispatch_commands(struct cam_data *cam) |
2273 | { | 2273 | { |
2274 | down(&cam->param_lock); | 2274 | mutex_lock(&cam->param_lock); |
2275 | if (cam->cmd_queue==COMMAND_NONE) { | 2275 | if (cam->cmd_queue==COMMAND_NONE) { |
2276 | up(&cam->param_lock); | 2276 | mutex_unlock(&cam->param_lock); |
2277 | return; | 2277 | return; |
2278 | } | 2278 | } |
2279 | DEB_BYTE(cam->cmd_queue); | 2279 | DEB_BYTE(cam->cmd_queue); |
@@ -2415,7 +2415,7 @@ static void dispatch_commands(struct cam_data *cam) | |||
2415 | } | 2415 | } |
2416 | 2416 | ||
2417 | cam->cmd_queue = COMMAND_NONE; | 2417 | cam->cmd_queue = COMMAND_NONE; |
2418 | up(&cam->param_lock); | 2418 | mutex_unlock(&cam->param_lock); |
2419 | return; | 2419 | return; |
2420 | } | 2420 | } |
2421 | 2421 | ||
@@ -2562,7 +2562,7 @@ static void monitor_exposure(struct cam_data *cam) | |||
2562 | gain = data[2]; | 2562 | gain = data[2]; |
2563 | coarseL = data[3]; | 2563 | coarseL = data[3]; |
2564 | 2564 | ||
2565 | down(&cam->param_lock); | 2565 | mutex_lock(&cam->param_lock); |
2566 | light_exp = cam->params.colourParams.brightness + | 2566 | light_exp = cam->params.colourParams.brightness + |
2567 | TC - 50 + EXP_ACC_LIGHT; | 2567 | TC - 50 + EXP_ACC_LIGHT; |
2568 | if(light_exp > 255) | 2568 | if(light_exp > 255) |
@@ -2762,7 +2762,7 @@ static void monitor_exposure(struct cam_data *cam) | |||
2762 | LOG("Automatically increasing sensor_fps\n"); | 2762 | LOG("Automatically increasing sensor_fps\n"); |
2763 | } | 2763 | } |
2764 | } | 2764 | } |
2765 | up(&cam->param_lock); | 2765 | mutex_unlock(&cam->param_lock); |
2766 | } | 2766 | } |
2767 | 2767 | ||
2768 | /*-----------------------------------------------------------------*/ | 2768 | /*-----------------------------------------------------------------*/ |
@@ -2778,10 +2778,10 @@ static void restart_flicker(struct cam_data *cam) | |||
2778 | int cam_exposure, old_exp; | 2778 | int cam_exposure, old_exp; |
2779 | if(!FIRMWARE_VERSION(1,2)) | 2779 | if(!FIRMWARE_VERSION(1,2)) |
2780 | return; | 2780 | return; |
2781 | down(&cam->param_lock); | 2781 | mutex_lock(&cam->param_lock); |
2782 | if(cam->params.flickerControl.flickerMode == 0 || | 2782 | if(cam->params.flickerControl.flickerMode == 0 || |
2783 | cam->raw_image[39] == 0) { | 2783 | cam->raw_image[39] == 0) { |
2784 | up(&cam->param_lock); | 2784 | mutex_unlock(&cam->param_lock); |
2785 | return; | 2785 | return; |
2786 | } | 2786 | } |
2787 | cam_exposure = cam->raw_image[39]*2; | 2787 | cam_exposure = cam->raw_image[39]*2; |
@@ -2810,7 +2810,7 @@ static void restart_flicker(struct cam_data *cam) | |||
2810 | cam->exposure_status = EXPOSURE_NORMAL; | 2810 | cam->exposure_status = EXPOSURE_NORMAL; |
2811 | 2811 | ||
2812 | } | 2812 | } |
2813 | up(&cam->param_lock); | 2813 | mutex_unlock(&cam->param_lock); |
2814 | } | 2814 | } |
2815 | #undef FIRMWARE_VERSION | 2815 | #undef FIRMWARE_VERSION |
2816 | 2816 | ||
@@ -3186,7 +3186,7 @@ static int cpia_open(struct inode *inode, struct file *file) | |||
3186 | if (!try_module_get(cam->ops->owner)) | 3186 | if (!try_module_get(cam->ops->owner)) |
3187 | return -ENODEV; | 3187 | return -ENODEV; |
3188 | 3188 | ||
3189 | down(&cam->busy_lock); | 3189 | mutex_lock(&cam->busy_lock); |
3190 | err = -ENOMEM; | 3190 | err = -ENOMEM; |
3191 | if (!cam->raw_image) { | 3191 | if (!cam->raw_image) { |
3192 | cam->raw_image = rvmalloc(CPIA_MAX_IMAGE_SIZE); | 3192 | cam->raw_image = rvmalloc(CPIA_MAX_IMAGE_SIZE); |
@@ -3227,7 +3227,7 @@ static int cpia_open(struct inode *inode, struct file *file) | |||
3227 | 3227 | ||
3228 | ++cam->open_count; | 3228 | ++cam->open_count; |
3229 | file->private_data = dev; | 3229 | file->private_data = dev; |
3230 | up(&cam->busy_lock); | 3230 | mutex_unlock(&cam->busy_lock); |
3231 | return 0; | 3231 | return 0; |
3232 | 3232 | ||
3233 | oops: | 3233 | oops: |
@@ -3239,7 +3239,7 @@ static int cpia_open(struct inode *inode, struct file *file) | |||
3239 | rvfree(cam->raw_image, CPIA_MAX_IMAGE_SIZE); | 3239 | rvfree(cam->raw_image, CPIA_MAX_IMAGE_SIZE); |
3240 | cam->raw_image = NULL; | 3240 | cam->raw_image = NULL; |
3241 | } | 3241 | } |
3242 | up(&cam->busy_lock); | 3242 | mutex_unlock(&cam->busy_lock); |
3243 | put_cam(cam->ops); | 3243 | put_cam(cam->ops); |
3244 | return err; | 3244 | return err; |
3245 | } | 3245 | } |
@@ -3303,24 +3303,24 @@ static ssize_t cpia_read(struct file *file, char __user *buf, | |||
3303 | int err; | 3303 | int err; |
3304 | 3304 | ||
3305 | /* make this _really_ smp and multithread-safe */ | 3305 | /* make this _really_ smp and multithread-safe */ |
3306 | if (down_interruptible(&cam->busy_lock)) | 3306 | if (mutex_lock_interruptible(&cam->busy_lock)) |
3307 | return -EINTR; | 3307 | return -EINTR; |
3308 | 3308 | ||
3309 | if (!buf) { | 3309 | if (!buf) { |
3310 | DBG("buf NULL\n"); | 3310 | DBG("buf NULL\n"); |
3311 | up(&cam->busy_lock); | 3311 | mutex_unlock(&cam->busy_lock); |
3312 | return -EINVAL; | 3312 | return -EINVAL; |
3313 | } | 3313 | } |
3314 | 3314 | ||
3315 | if (!count) { | 3315 | if (!count) { |
3316 | DBG("count 0\n"); | 3316 | DBG("count 0\n"); |
3317 | up(&cam->busy_lock); | 3317 | mutex_unlock(&cam->busy_lock); |
3318 | return 0; | 3318 | return 0; |
3319 | } | 3319 | } |
3320 | 3320 | ||
3321 | if (!cam->ops) { | 3321 | if (!cam->ops) { |
3322 | DBG("ops NULL\n"); | 3322 | DBG("ops NULL\n"); |
3323 | up(&cam->busy_lock); | 3323 | mutex_unlock(&cam->busy_lock); |
3324 | return -ENODEV; | 3324 | return -ENODEV; |
3325 | } | 3325 | } |
3326 | 3326 | ||
@@ -3329,7 +3329,7 @@ static ssize_t cpia_read(struct file *file, char __user *buf, | |||
3329 | cam->mmap_kludge=0; | 3329 | cam->mmap_kludge=0; |
3330 | if((err = fetch_frame(cam)) != 0) { | 3330 | if((err = fetch_frame(cam)) != 0) { |
3331 | DBG("ERROR from fetch_frame: %d\n", err); | 3331 | DBG("ERROR from fetch_frame: %d\n", err); |
3332 | up(&cam->busy_lock); | 3332 | mutex_unlock(&cam->busy_lock); |
3333 | return err; | 3333 | return err; |
3334 | } | 3334 | } |
3335 | cam->decompressed_frame.state = FRAME_UNUSED; | 3335 | cam->decompressed_frame.state = FRAME_UNUSED; |
@@ -3338,17 +3338,17 @@ static ssize_t cpia_read(struct file *file, char __user *buf, | |||
3338 | if (cam->decompressed_frame.count > count) { | 3338 | if (cam->decompressed_frame.count > count) { |
3339 | DBG("count wrong: %d, %lu\n", cam->decompressed_frame.count, | 3339 | DBG("count wrong: %d, %lu\n", cam->decompressed_frame.count, |
3340 | (unsigned long) count); | 3340 | (unsigned long) count); |
3341 | up(&cam->busy_lock); | 3341 | mutex_unlock(&cam->busy_lock); |
3342 | return -EFAULT; | 3342 | return -EFAULT; |
3343 | } | 3343 | } |
3344 | if (copy_to_user(buf, cam->decompressed_frame.data, | 3344 | if (copy_to_user(buf, cam->decompressed_frame.data, |
3345 | cam->decompressed_frame.count)) { | 3345 | cam->decompressed_frame.count)) { |
3346 | DBG("copy_to_user failed\n"); | 3346 | DBG("copy_to_user failed\n"); |
3347 | up(&cam->busy_lock); | 3347 | mutex_unlock(&cam->busy_lock); |
3348 | return -EFAULT; | 3348 | return -EFAULT; |
3349 | } | 3349 | } |
3350 | 3350 | ||
3351 | up(&cam->busy_lock); | 3351 | mutex_unlock(&cam->busy_lock); |
3352 | return cam->decompressed_frame.count; | 3352 | return cam->decompressed_frame.count; |
3353 | } | 3353 | } |
3354 | 3354 | ||
@@ -3363,7 +3363,7 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file, | |||
3363 | return -ENODEV; | 3363 | return -ENODEV; |
3364 | 3364 | ||
3365 | /* make this _really_ smp-safe */ | 3365 | /* make this _really_ smp-safe */ |
3366 | if (down_interruptible(&cam->busy_lock)) | 3366 | if (mutex_lock_interruptible(&cam->busy_lock)) |
3367 | return -EINTR; | 3367 | return -EINTR; |
3368 | 3368 | ||
3369 | //DBG("cpia_ioctl: %u\n", ioctlnr); | 3369 | //DBG("cpia_ioctl: %u\n", ioctlnr); |
@@ -3439,7 +3439,7 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file, | |||
3439 | break; | 3439 | break; |
3440 | } | 3440 | } |
3441 | 3441 | ||
3442 | down(&cam->param_lock); | 3442 | mutex_lock(&cam->param_lock); |
3443 | /* brightness, colour, contrast need no check 0-65535 */ | 3443 | /* brightness, colour, contrast need no check 0-65535 */ |
3444 | cam->vp = *vp; | 3444 | cam->vp = *vp; |
3445 | /* update cam->params.colourParams */ | 3445 | /* update cam->params.colourParams */ |
@@ -3466,7 +3466,7 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file, | |||
3466 | 3466 | ||
3467 | /* queue command to update camera */ | 3467 | /* queue command to update camera */ |
3468 | cam->cmd_queue |= COMMAND_SETCOLOURPARAMS; | 3468 | cam->cmd_queue |= COMMAND_SETCOLOURPARAMS; |
3469 | up(&cam->param_lock); | 3469 | mutex_unlock(&cam->param_lock); |
3470 | DBG("VIDIOCSPICT: %d / %d // %d / %d / %d / %d\n", | 3470 | DBG("VIDIOCSPICT: %d / %d // %d / %d / %d / %d\n", |
3471 | vp->depth, vp->palette, vp->brightness, vp->hue, vp->colour, | 3471 | vp->depth, vp->palette, vp->brightness, vp->hue, vp->colour, |
3472 | vp->contrast); | 3472 | vp->contrast); |
@@ -3501,13 +3501,13 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file, | |||
3501 | /* we set the video window to something smaller or equal to what | 3501 | /* we set the video window to something smaller or equal to what |
3502 | * is requested by the user??? | 3502 | * is requested by the user??? |
3503 | */ | 3503 | */ |
3504 | down(&cam->param_lock); | 3504 | mutex_lock(&cam->param_lock); |
3505 | if (vw->width != cam->vw.width || vw->height != cam->vw.height) { | 3505 | if (vw->width != cam->vw.width || vw->height != cam->vw.height) { |
3506 | int video_size = match_videosize(vw->width, vw->height); | 3506 | int video_size = match_videosize(vw->width, vw->height); |
3507 | 3507 | ||
3508 | if (video_size < 0) { | 3508 | if (video_size < 0) { |
3509 | retval = -EINVAL; | 3509 | retval = -EINVAL; |
3510 | up(&cam->param_lock); | 3510 | mutex_unlock(&cam->param_lock); |
3511 | break; | 3511 | break; |
3512 | } | 3512 | } |
3513 | cam->video_size = video_size; | 3513 | cam->video_size = video_size; |
@@ -3520,7 +3520,7 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file, | |||
3520 | cam->cmd_queue |= COMMAND_SETFORMAT; | 3520 | cam->cmd_queue |= COMMAND_SETFORMAT; |
3521 | } | 3521 | } |
3522 | 3522 | ||
3523 | up(&cam->param_lock); | 3523 | mutex_unlock(&cam->param_lock); |
3524 | 3524 | ||
3525 | /* setformat ignored by camera during streaming, | 3525 | /* setformat ignored by camera during streaming, |
3526 | * so stop/dispatch/start */ | 3526 | * so stop/dispatch/start */ |
@@ -3682,7 +3682,7 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file, | |||
3682 | 3682 | ||
3683 | DBG("%d,%d/%dx%d\n", vc->x,vc->y,vc->width, vc->height); | 3683 | DBG("%d,%d/%dx%d\n", vc->x,vc->y,vc->width, vc->height); |
3684 | 3684 | ||
3685 | down(&cam->param_lock); | 3685 | mutex_lock(&cam->param_lock); |
3686 | 3686 | ||
3687 | cam->vc.x = vc->x; | 3687 | cam->vc.x = vc->x; |
3688 | cam->vc.y = vc->y; | 3688 | cam->vc.y = vc->y; |
@@ -3692,7 +3692,7 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file, | |||
3692 | set_vw_size(cam); | 3692 | set_vw_size(cam); |
3693 | cam->cmd_queue |= COMMAND_SETFORMAT; | 3693 | cam->cmd_queue |= COMMAND_SETFORMAT; |
3694 | 3694 | ||
3695 | up(&cam->param_lock); | 3695 | mutex_unlock(&cam->param_lock); |
3696 | 3696 | ||
3697 | /* setformat ignored by camera during streaming, | 3697 | /* setformat ignored by camera during streaming, |
3698 | * so stop/dispatch/start */ | 3698 | * so stop/dispatch/start */ |
@@ -3736,7 +3736,7 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file, | |||
3736 | break; | 3736 | break; |
3737 | } | 3737 | } |
3738 | 3738 | ||
3739 | up(&cam->busy_lock); | 3739 | mutex_unlock(&cam->busy_lock); |
3740 | return retval; | 3740 | return retval; |
3741 | } | 3741 | } |
3742 | 3742 | ||
@@ -3769,12 +3769,12 @@ static int cpia_mmap(struct file *file, struct vm_area_struct *vma) | |||
3769 | return -ENODEV; | 3769 | return -ENODEV; |
3770 | 3770 | ||
3771 | /* make this _really_ smp-safe */ | 3771 | /* make this _really_ smp-safe */ |
3772 | if (down_interruptible(&cam->busy_lock)) | 3772 | if (mutex_lock_interruptible(&cam->busy_lock)) |
3773 | return -EINTR; | 3773 | return -EINTR; |
3774 | 3774 | ||
3775 | if (!cam->frame_buf) { /* we do lazy allocation */ | 3775 | if (!cam->frame_buf) { /* we do lazy allocation */ |
3776 | if ((retval = allocate_frame_buf(cam))) { | 3776 | if ((retval = allocate_frame_buf(cam))) { |
3777 | up(&cam->busy_lock); | 3777 | mutex_unlock(&cam->busy_lock); |
3778 | return retval; | 3778 | return retval; |
3779 | } | 3779 | } |
3780 | } | 3780 | } |
@@ -3783,7 +3783,7 @@ static int cpia_mmap(struct file *file, struct vm_area_struct *vma) | |||
3783 | while (size > 0) { | 3783 | while (size > 0) { |
3784 | page = vmalloc_to_pfn((void *)pos); | 3784 | page = vmalloc_to_pfn((void *)pos); |
3785 | if (remap_pfn_range(vma, start, page, PAGE_SIZE, PAGE_SHARED)) { | 3785 | if (remap_pfn_range(vma, start, page, PAGE_SIZE, PAGE_SHARED)) { |
3786 | up(&cam->busy_lock); | 3786 | mutex_unlock(&cam->busy_lock); |
3787 | return -EAGAIN; | 3787 | return -EAGAIN; |
3788 | } | 3788 | } |
3789 | start += PAGE_SIZE; | 3789 | start += PAGE_SIZE; |
@@ -3795,7 +3795,7 @@ static int cpia_mmap(struct file *file, struct vm_area_struct *vma) | |||
3795 | } | 3795 | } |
3796 | 3796 | ||
3797 | DBG("cpia_mmap: %ld\n", size); | 3797 | DBG("cpia_mmap: %ld\n", size); |
3798 | up(&cam->busy_lock); | 3798 | mutex_unlock(&cam->busy_lock); |
3799 | 3799 | ||
3800 | return 0; | 3800 | return 0; |
3801 | } | 3801 | } |
@@ -3936,8 +3936,8 @@ static void init_camera_struct(struct cam_data *cam, | |||
3936 | memset(cam, 0, sizeof(struct cam_data)); | 3936 | memset(cam, 0, sizeof(struct cam_data)); |
3937 | 3937 | ||
3938 | cam->ops = ops; | 3938 | cam->ops = ops; |
3939 | init_MUTEX(&cam->param_lock); | 3939 | mutex_init(&cam->param_lock); |
3940 | init_MUTEX(&cam->busy_lock); | 3940 | mutex_init(&cam->busy_lock); |
3941 | 3941 | ||
3942 | reset_camera_struct(cam); | 3942 | reset_camera_struct(cam); |
3943 | 3943 | ||
diff --git a/drivers/media/video/cpia.h b/drivers/media/video/cpia.h index f629b693ee65..de6678200a57 100644 --- a/drivers/media/video/cpia.h +++ b/drivers/media/video/cpia.h | |||
@@ -47,6 +47,7 @@ | |||
47 | #include <linux/videodev.h> | 47 | #include <linux/videodev.h> |
48 | #include <linux/list.h> | 48 | #include <linux/list.h> |
49 | #include <linux/smp_lock.h> | 49 | #include <linux/smp_lock.h> |
50 | #include <linux/mutex.h> | ||
50 | 51 | ||
51 | struct cpia_camera_ops | 52 | struct cpia_camera_ops |
52 | { | 53 | { |
@@ -246,7 +247,7 @@ enum v4l_camstates { | |||
246 | struct cam_data { | 247 | struct cam_data { |
247 | struct list_head cam_data_list; | 248 | struct list_head cam_data_list; |
248 | 249 | ||
249 | struct semaphore busy_lock; /* guard against SMP multithreading */ | 250 | struct mutex busy_lock; /* guard against SMP multithreading */ |
250 | struct cpia_camera_ops *ops; /* lowlevel driver operations */ | 251 | struct cpia_camera_ops *ops; /* lowlevel driver operations */ |
251 | void *lowlevel_data; /* private data for lowlevel driver */ | 252 | void *lowlevel_data; /* private data for lowlevel driver */ |
252 | u8 *raw_image; /* buffer for raw image data */ | 253 | u8 *raw_image; /* buffer for raw image data */ |
@@ -261,7 +262,7 @@ struct cam_data { | |||
261 | u8 mainsFreq; /* for flicker control */ | 262 | u8 mainsFreq; /* for flicker control */ |
262 | 263 | ||
263 | /* proc interface */ | 264 | /* proc interface */ |
264 | struct semaphore param_lock; /* params lock for this camera */ | 265 | struct mutex param_lock; /* params lock for this camera */ |
265 | struct cam_params params; /* camera settings */ | 266 | struct cam_params params; /* camera settings */ |
266 | struct proc_dir_entry *proc_entry; /* /proc/cpia/videoX */ | 267 | struct proc_dir_entry *proc_entry; /* /proc/cpia/videoX */ |
267 | 268 | ||
diff --git a/drivers/media/video/cx88/cx88-core.c b/drivers/media/video/cx88/cx88-core.c index 3720f24a25cf..eda7cd8b2d4a 100644 --- a/drivers/media/video/cx88/cx88-core.c +++ b/drivers/media/video/cx88/cx88-core.c | |||
@@ -1061,7 +1061,7 @@ struct cx88_core* cx88_core_get(struct pci_dev *pci) | |||
1061 | core->pci_bus = pci->bus->number; | 1061 | core->pci_bus = pci->bus->number; |
1062 | core->pci_slot = PCI_SLOT(pci->devfn); | 1062 | core->pci_slot = PCI_SLOT(pci->devfn); |
1063 | core->pci_irqmask = 0x00fc00; | 1063 | core->pci_irqmask = 0x00fc00; |
1064 | init_MUTEX(&core->lock); | 1064 | mutex_init(&core->lock); |
1065 | 1065 | ||
1066 | core->nr = cx88_devcount++; | 1066 | core->nr = cx88_devcount++; |
1067 | sprintf(core->name,"cx88[%d]",core->nr); | 1067 | sprintf(core->name,"cx88[%d]",core->nr); |
diff --git a/drivers/media/video/cx88/cx88-video.c b/drivers/media/video/cx88/cx88-video.c index 073494ceab0f..d15ef158ac8f 100644 --- a/drivers/media/video/cx88/cx88-video.c +++ b/drivers/media/video/cx88/cx88-video.c | |||
@@ -336,17 +336,17 @@ static int res_get(struct cx8800_dev *dev, struct cx8800_fh *fh, unsigned int bi | |||
336 | return 1; | 336 | return 1; |
337 | 337 | ||
338 | /* is it free? */ | 338 | /* is it free? */ |
339 | down(&core->lock); | 339 | mutex_lock(&core->lock); |
340 | if (dev->resources & bit) { | 340 | if (dev->resources & bit) { |
341 | /* no, someone else uses it */ | 341 | /* no, someone else uses it */ |
342 | up(&core->lock); | 342 | mutex_unlock(&core->lock); |
343 | return 0; | 343 | return 0; |
344 | } | 344 | } |
345 | /* it's free, grab it */ | 345 | /* it's free, grab it */ |
346 | fh->resources |= bit; | 346 | fh->resources |= bit; |
347 | dev->resources |= bit; | 347 | dev->resources |= bit; |
348 | dprintk(1,"res: get %d\n",bit); | 348 | dprintk(1,"res: get %d\n",bit); |
349 | up(&core->lock); | 349 | mutex_unlock(&core->lock); |
350 | return 1; | 350 | return 1; |
351 | } | 351 | } |
352 | 352 | ||
@@ -369,11 +369,11 @@ void res_free(struct cx8800_dev *dev, struct cx8800_fh *fh, unsigned int bits) | |||
369 | if ((fh->resources & bits) != bits) | 369 | if ((fh->resources & bits) != bits) |
370 | BUG(); | 370 | BUG(); |
371 | 371 | ||
372 | down(&core->lock); | 372 | mutex_lock(&core->lock); |
373 | fh->resources &= ~bits; | 373 | fh->resources &= ~bits; |
374 | dev->resources &= ~bits; | 374 | dev->resources &= ~bits; |
375 | dprintk(1,"res: put %d\n",bits); | 375 | dprintk(1,"res: put %d\n",bits); |
376 | up(&core->lock); | 376 | mutex_unlock(&core->lock); |
377 | } | 377 | } |
378 | 378 | ||
379 | /* ------------------------------------------------------------------ */ | 379 | /* ------------------------------------------------------------------ */ |
@@ -1291,9 +1291,9 @@ int cx88_do_ioctl(struct inode *inode, struct file *file, int radio, | |||
1291 | if (i == ARRAY_SIZE(tvnorms)) | 1291 | if (i == ARRAY_SIZE(tvnorms)) |
1292 | return -EINVAL; | 1292 | return -EINVAL; |
1293 | 1293 | ||
1294 | down(&core->lock); | 1294 | mutex_lock(&core->lock); |
1295 | cx88_set_tvnorm(core,&tvnorms[i]); | 1295 | cx88_set_tvnorm(core,&tvnorms[i]); |
1296 | up(&core->lock); | 1296 | mutex_unlock(&core->lock); |
1297 | return 0; | 1297 | return 0; |
1298 | } | 1298 | } |
1299 | 1299 | ||
@@ -1343,10 +1343,10 @@ int cx88_do_ioctl(struct inode *inode, struct file *file, int radio, | |||
1343 | 1343 | ||
1344 | if (*i >= 4) | 1344 | if (*i >= 4) |
1345 | return -EINVAL; | 1345 | return -EINVAL; |
1346 | down(&core->lock); | 1346 | mutex_lock(&core->lock); |
1347 | cx88_newstation(core); | 1347 | cx88_newstation(core); |
1348 | video_mux(core,*i); | 1348 | video_mux(core,*i); |
1349 | up(&core->lock); | 1349 | mutex_unlock(&core->lock); |
1350 | return 0; | 1350 | return 0; |
1351 | } | 1351 | } |
1352 | 1352 | ||
@@ -1438,7 +1438,7 @@ int cx88_do_ioctl(struct inode *inode, struct file *file, int radio, | |||
1438 | return -EINVAL; | 1438 | return -EINVAL; |
1439 | if (1 == radio && f->type != V4L2_TUNER_RADIO) | 1439 | if (1 == radio && f->type != V4L2_TUNER_RADIO) |
1440 | return -EINVAL; | 1440 | return -EINVAL; |
1441 | down(&core->lock); | 1441 | mutex_lock(&core->lock); |
1442 | core->freq = f->frequency; | 1442 | core->freq = f->frequency; |
1443 | cx88_newstation(core); | 1443 | cx88_newstation(core); |
1444 | cx88_call_i2c_clients(core,VIDIOC_S_FREQUENCY,f); | 1444 | cx88_call_i2c_clients(core,VIDIOC_S_FREQUENCY,f); |
@@ -1447,7 +1447,7 @@ int cx88_do_ioctl(struct inode *inode, struct file *file, int radio, | |||
1447 | msleep (10); | 1447 | msleep (10); |
1448 | cx88_set_tvaudio(core); | 1448 | cx88_set_tvaudio(core); |
1449 | 1449 | ||
1450 | up(&core->lock); | 1450 | mutex_unlock(&core->lock); |
1451 | return 0; | 1451 | return 0; |
1452 | } | 1452 | } |
1453 | 1453 | ||
@@ -1921,11 +1921,11 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev, | |||
1921 | pci_set_drvdata(pci_dev,dev); | 1921 | pci_set_drvdata(pci_dev,dev); |
1922 | 1922 | ||
1923 | /* initial device configuration */ | 1923 | /* initial device configuration */ |
1924 | down(&core->lock); | 1924 | mutex_lock(&core->lock); |
1925 | cx88_set_tvnorm(core,tvnorms); | 1925 | cx88_set_tvnorm(core,tvnorms); |
1926 | init_controls(core); | 1926 | init_controls(core); |
1927 | video_mux(core,0); | 1927 | video_mux(core,0); |
1928 | up(&core->lock); | 1928 | mutex_unlock(&core->lock); |
1929 | 1929 | ||
1930 | /* start tvaudio thread */ | 1930 | /* start tvaudio thread */ |
1931 | if (core->tuner_type != TUNER_ABSENT) | 1931 | if (core->tuner_type != TUNER_ABSENT) |
diff --git a/drivers/media/video/cx88/cx88.h b/drivers/media/video/cx88/cx88.h index 31a688a3fb77..a4cf2473eacf 100644 --- a/drivers/media/video/cx88/cx88.h +++ b/drivers/media/video/cx88/cx88.h | |||
@@ -35,6 +35,7 @@ | |||
35 | #include "cx88-reg.h" | 35 | #include "cx88-reg.h" |
36 | 36 | ||
37 | #include <linux/version.h> | 37 | #include <linux/version.h> |
38 | #include <linux/mutex.h> | ||
38 | #define CX88_VERSION_CODE KERNEL_VERSION(0,0,5) | 39 | #define CX88_VERSION_CODE KERNEL_VERSION(0,0,5) |
39 | 40 | ||
40 | #ifndef TRUE | 41 | #ifndef TRUE |
@@ -309,8 +310,7 @@ struct cx88_core { | |||
309 | /* IR remote control state */ | 310 | /* IR remote control state */ |
310 | struct cx88_IR *ir; | 311 | struct cx88_IR *ir; |
311 | 312 | ||
312 | struct semaphore lock; | 313 | struct mutex lock; |
313 | |||
314 | /* various v4l controls */ | 314 | /* various v4l controls */ |
315 | u32 freq; | 315 | u32 freq; |
316 | 316 | ||
diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c index 1c1557d9bace..671fc52b6a88 100644 --- a/drivers/media/video/em28xx/em28xx-video.c +++ b/drivers/media/video/em28xx/em28xx-video.c | |||
@@ -362,12 +362,12 @@ static int em28xx_v4l2_open(struct inode *inode, struct file *filp) | |||
362 | return -EBUSY; | 362 | return -EBUSY; |
363 | } | 363 | } |
364 | 364 | ||
365 | init_MUTEX(&dev->fileop_lock); /* to 1 == available */ | 365 | mutex_init(&dev->fileop_lock); /* to 1 == available */ |
366 | spin_lock_init(&dev->queue_lock); | 366 | spin_lock_init(&dev->queue_lock); |
367 | init_waitqueue_head(&dev->wait_frame); | 367 | init_waitqueue_head(&dev->wait_frame); |
368 | init_waitqueue_head(&dev->wait_stream); | 368 | init_waitqueue_head(&dev->wait_stream); |
369 | 369 | ||
370 | down(&dev->lock); | 370 | mutex_lock(&dev->lock); |
371 | 371 | ||
372 | if (dev->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) { | 372 | if (dev->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) { |
373 | em28xx_set_alternate(dev); | 373 | em28xx_set_alternate(dev); |
@@ -404,8 +404,8 @@ static int em28xx_v4l2_open(struct inode *inode, struct file *filp) | |||
404 | 404 | ||
405 | dev->state |= DEV_INITIALIZED; | 405 | dev->state |= DEV_INITIALIZED; |
406 | 406 | ||
407 | err: | 407 | err: |
408 | up(&dev->lock); | 408 | mutex_unlock(&dev->lock); |
409 | up_read(&em28xx_disconnect); | 409 | up_read(&em28xx_disconnect); |
410 | return errCode; | 410 | return errCode; |
411 | } | 411 | } |
@@ -447,7 +447,7 @@ static int em28xx_v4l2_close(struct inode *inode, struct file *filp) | |||
447 | 447 | ||
448 | em28xx_videodbg("users=%d\n", dev->users); | 448 | em28xx_videodbg("users=%d\n", dev->users); |
449 | 449 | ||
450 | down(&dev->lock); | 450 | mutex_lock(&dev->lock); |
451 | 451 | ||
452 | em28xx_uninit_isoc(dev); | 452 | em28xx_uninit_isoc(dev); |
453 | 453 | ||
@@ -456,7 +456,7 @@ static int em28xx_v4l2_close(struct inode *inode, struct file *filp) | |||
456 | /* the device is already disconnect, free the remaining resources */ | 456 | /* the device is already disconnect, free the remaining resources */ |
457 | if (dev->state & DEV_DISCONNECTED) { | 457 | if (dev->state & DEV_DISCONNECTED) { |
458 | em28xx_release_resources(dev); | 458 | em28xx_release_resources(dev); |
459 | up(&dev->lock); | 459 | mutex_unlock(&dev->lock); |
460 | kfree(dev); | 460 | kfree(dev); |
461 | return 0; | 461 | return 0; |
462 | } | 462 | } |
@@ -472,7 +472,7 @@ static int em28xx_v4l2_close(struct inode *inode, struct file *filp) | |||
472 | 472 | ||
473 | dev->users--; | 473 | dev->users--; |
474 | wake_up_interruptible_nr(&dev->open, 1); | 474 | wake_up_interruptible_nr(&dev->open, 1); |
475 | up(&dev->lock); | 475 | mutex_unlock(&dev->lock); |
476 | return 0; | 476 | return 0; |
477 | } | 477 | } |
478 | 478 | ||
@@ -496,7 +496,7 @@ em28xx_v4l2_read(struct file *filp, char __user * buf, size_t count, | |||
496 | em28xx_videodbg("V4L2_BUF_TYPE_VBI_CAPTURE is set\n"); | 496 | em28xx_videodbg("V4L2_BUF_TYPE_VBI_CAPTURE is set\n"); |
497 | em28xx_videodbg("not supported yet! ...\n"); | 497 | em28xx_videodbg("not supported yet! ...\n"); |
498 | if (copy_to_user(buf, "", 1)) { | 498 | if (copy_to_user(buf, "", 1)) { |
499 | up(&dev->fileop_lock); | 499 | mutex_unlock(&dev->fileop_lock); |
500 | return -EFAULT; | 500 | return -EFAULT; |
501 | } | 501 | } |
502 | return (1); | 502 | return (1); |
@@ -505,38 +505,38 @@ em28xx_v4l2_read(struct file *filp, char __user * buf, size_t count, | |||
505 | em28xx_videodbg("V4L2_BUF_TYPE_SLICED_VBI_CAPTURE is set\n"); | 505 | em28xx_videodbg("V4L2_BUF_TYPE_SLICED_VBI_CAPTURE is set\n"); |
506 | em28xx_videodbg("not supported yet! ...\n"); | 506 | em28xx_videodbg("not supported yet! ...\n"); |
507 | if (copy_to_user(buf, "", 1)) { | 507 | if (copy_to_user(buf, "", 1)) { |
508 | up(&dev->fileop_lock); | 508 | mutex_unlock(&dev->fileop_lock); |
509 | return -EFAULT; | 509 | return -EFAULT; |
510 | } | 510 | } |
511 | return (1); | 511 | return (1); |
512 | } | 512 | } |
513 | 513 | ||
514 | if (down_interruptible(&dev->fileop_lock)) | 514 | if (mutex_lock_interruptible(&dev->fileop_lock)) |
515 | return -ERESTARTSYS; | 515 | return -ERESTARTSYS; |
516 | 516 | ||
517 | if (dev->state & DEV_DISCONNECTED) { | 517 | if (dev->state & DEV_DISCONNECTED) { |
518 | em28xx_videodbg("device not present\n"); | 518 | em28xx_videodbg("device not present\n"); |
519 | up(&dev->fileop_lock); | 519 | mutex_unlock(&dev->fileop_lock); |
520 | return -ENODEV; | 520 | return -ENODEV; |
521 | } | 521 | } |
522 | 522 | ||
523 | if (dev->state & DEV_MISCONFIGURED) { | 523 | if (dev->state & DEV_MISCONFIGURED) { |
524 | em28xx_videodbg("device misconfigured; close and open it again\n"); | 524 | em28xx_videodbg("device misconfigured; close and open it again\n"); |
525 | up(&dev->fileop_lock); | 525 | mutex_unlock(&dev->fileop_lock); |
526 | return -EIO; | 526 | return -EIO; |
527 | } | 527 | } |
528 | 528 | ||
529 | if (dev->io == IO_MMAP) { | 529 | if (dev->io == IO_MMAP) { |
530 | em28xx_videodbg ("IO method is set to mmap; close and open" | 530 | em28xx_videodbg ("IO method is set to mmap; close and open" |
531 | " the device again to choose the read method\n"); | 531 | " the device again to choose the read method\n"); |
532 | up(&dev->fileop_lock); | 532 | mutex_unlock(&dev->fileop_lock); |
533 | return -EINVAL; | 533 | return -EINVAL; |
534 | } | 534 | } |
535 | 535 | ||
536 | if (dev->io == IO_NONE) { | 536 | if (dev->io == IO_NONE) { |
537 | if (!em28xx_request_buffers(dev, EM28XX_NUM_READ_FRAMES)) { | 537 | if (!em28xx_request_buffers(dev, EM28XX_NUM_READ_FRAMES)) { |
538 | em28xx_errdev("read failed, not enough memory\n"); | 538 | em28xx_errdev("read failed, not enough memory\n"); |
539 | up(&dev->fileop_lock); | 539 | mutex_unlock(&dev->fileop_lock); |
540 | return -ENOMEM; | 540 | return -ENOMEM; |
541 | } | 541 | } |
542 | dev->io = IO_READ; | 542 | dev->io = IO_READ; |
@@ -545,13 +545,13 @@ em28xx_v4l2_read(struct file *filp, char __user * buf, size_t count, | |||
545 | } | 545 | } |
546 | 546 | ||
547 | if (!count) { | 547 | if (!count) { |
548 | up(&dev->fileop_lock); | 548 | mutex_unlock(&dev->fileop_lock); |
549 | return 0; | 549 | return 0; |
550 | } | 550 | } |
551 | 551 | ||
552 | if (list_empty(&dev->outqueue)) { | 552 | if (list_empty(&dev->outqueue)) { |
553 | if (filp->f_flags & O_NONBLOCK) { | 553 | if (filp->f_flags & O_NONBLOCK) { |
554 | up(&dev->fileop_lock); | 554 | mutex_unlock(&dev->fileop_lock); |
555 | return -EAGAIN; | 555 | return -EAGAIN; |
556 | } | 556 | } |
557 | ret = wait_event_interruptible | 557 | ret = wait_event_interruptible |
@@ -559,11 +559,11 @@ em28xx_v4l2_read(struct file *filp, char __user * buf, size_t count, | |||
559 | (!list_empty(&dev->outqueue)) || | 559 | (!list_empty(&dev->outqueue)) || |
560 | (dev->state & DEV_DISCONNECTED)); | 560 | (dev->state & DEV_DISCONNECTED)); |
561 | if (ret) { | 561 | if (ret) { |
562 | up(&dev->fileop_lock); | 562 | mutex_unlock(&dev->fileop_lock); |
563 | return ret; | 563 | return ret; |
564 | } | 564 | } |
565 | if (dev->state & DEV_DISCONNECTED) { | 565 | if (dev->state & DEV_DISCONNECTED) { |
566 | up(&dev->fileop_lock); | 566 | mutex_unlock(&dev->fileop_lock); |
567 | return -ENODEV; | 567 | return -ENODEV; |
568 | } | 568 | } |
569 | } | 569 | } |
@@ -582,12 +582,12 @@ em28xx_v4l2_read(struct file *filp, char __user * buf, size_t count, | |||
582 | count = f->buf.length; | 582 | count = f->buf.length; |
583 | 583 | ||
584 | if (copy_to_user(buf, f->bufmem, count)) { | 584 | if (copy_to_user(buf, f->bufmem, count)) { |
585 | up(&dev->fileop_lock); | 585 | mutex_unlock(&dev->fileop_lock); |
586 | return -EFAULT; | 586 | return -EFAULT; |
587 | } | 587 | } |
588 | *f_pos += count; | 588 | *f_pos += count; |
589 | 589 | ||
590 | up(&dev->fileop_lock); | 590 | mutex_unlock(&dev->fileop_lock); |
591 | 591 | ||
592 | return count; | 592 | return count; |
593 | } | 593 | } |
@@ -601,7 +601,7 @@ static unsigned int em28xx_v4l2_poll(struct file *filp, poll_table * wait) | |||
601 | unsigned int mask = 0; | 601 | unsigned int mask = 0; |
602 | struct em28xx *dev = filp->private_data; | 602 | struct em28xx *dev = filp->private_data; |
603 | 603 | ||
604 | if (down_interruptible(&dev->fileop_lock)) | 604 | if (mutex_lock_interruptible(&dev->fileop_lock)) |
605 | return POLLERR; | 605 | return POLLERR; |
606 | 606 | ||
607 | if (dev->state & DEV_DISCONNECTED) { | 607 | if (dev->state & DEV_DISCONNECTED) { |
@@ -627,13 +627,13 @@ static unsigned int em28xx_v4l2_poll(struct file *filp, poll_table * wait) | |||
627 | if (!list_empty(&dev->outqueue)) | 627 | if (!list_empty(&dev->outqueue)) |
628 | mask |= POLLIN | POLLRDNORM; | 628 | mask |= POLLIN | POLLRDNORM; |
629 | 629 | ||
630 | up(&dev->fileop_lock); | 630 | mutex_unlock(&dev->fileop_lock); |
631 | 631 | ||
632 | return mask; | 632 | return mask; |
633 | } | 633 | } |
634 | } | 634 | } |
635 | 635 | ||
636 | up(&dev->fileop_lock); | 636 | mutex_unlock(&dev->fileop_lock); |
637 | return POLLERR; | 637 | return POLLERR; |
638 | } | 638 | } |
639 | 639 | ||
@@ -673,25 +673,25 @@ static int em28xx_v4l2_mmap(struct file *filp, struct vm_area_struct *vma) | |||
673 | 673 | ||
674 | struct em28xx *dev = filp->private_data; | 674 | struct em28xx *dev = filp->private_data; |
675 | 675 | ||
676 | if (down_interruptible(&dev->fileop_lock)) | 676 | if (mutex_lock_interruptible(&dev->fileop_lock)) |
677 | return -ERESTARTSYS; | 677 | return -ERESTARTSYS; |
678 | 678 | ||
679 | if (dev->state & DEV_DISCONNECTED) { | 679 | if (dev->state & DEV_DISCONNECTED) { |
680 | em28xx_videodbg("mmap: device not present\n"); | 680 | em28xx_videodbg("mmap: device not present\n"); |
681 | up(&dev->fileop_lock); | 681 | mutex_unlock(&dev->fileop_lock); |
682 | return -ENODEV; | 682 | return -ENODEV; |
683 | } | 683 | } |
684 | 684 | ||
685 | if (dev->state & DEV_MISCONFIGURED) { | 685 | if (dev->state & DEV_MISCONFIGURED) { |
686 | em28xx_videodbg ("mmap: Device is misconfigured; close and " | 686 | em28xx_videodbg ("mmap: Device is misconfigured; close and " |
687 | "open it again\n"); | 687 | "open it again\n"); |
688 | up(&dev->fileop_lock); | 688 | mutex_unlock(&dev->fileop_lock); |
689 | return -EIO; | 689 | return -EIO; |
690 | } | 690 | } |
691 | 691 | ||
692 | if (dev->io != IO_MMAP || !(vma->vm_flags & VM_WRITE) || | 692 | if (dev->io != IO_MMAP || !(vma->vm_flags & VM_WRITE) || |
693 | size != PAGE_ALIGN(dev->frame[0].buf.length)) { | 693 | size != PAGE_ALIGN(dev->frame[0].buf.length)) { |
694 | up(&dev->fileop_lock); | 694 | mutex_unlock(&dev->fileop_lock); |
695 | return -EINVAL; | 695 | return -EINVAL; |
696 | } | 696 | } |
697 | 697 | ||
@@ -701,7 +701,7 @@ static int em28xx_v4l2_mmap(struct file *filp, struct vm_area_struct *vma) | |||
701 | } | 701 | } |
702 | if (i == dev->num_frames) { | 702 | if (i == dev->num_frames) { |
703 | em28xx_videodbg("mmap: user supplied mapping address is out of range\n"); | 703 | em28xx_videodbg("mmap: user supplied mapping address is out of range\n"); |
704 | up(&dev->fileop_lock); | 704 | mutex_unlock(&dev->fileop_lock); |
705 | return -EINVAL; | 705 | return -EINVAL; |
706 | } | 706 | } |
707 | 707 | ||
@@ -713,7 +713,7 @@ static int em28xx_v4l2_mmap(struct file *filp, struct vm_area_struct *vma) | |||
713 | while (size > 0) { /* size is page-aligned */ | 713 | while (size > 0) { /* size is page-aligned */ |
714 | if (vm_insert_page(vma, start, vmalloc_to_page(pos))) { | 714 | if (vm_insert_page(vma, start, vmalloc_to_page(pos))) { |
715 | em28xx_videodbg("mmap: vm_insert_page failed\n"); | 715 | em28xx_videodbg("mmap: vm_insert_page failed\n"); |
716 | up(&dev->fileop_lock); | 716 | mutex_unlock(&dev->fileop_lock); |
717 | return -EAGAIN; | 717 | return -EAGAIN; |
718 | } | 718 | } |
719 | start += PAGE_SIZE; | 719 | start += PAGE_SIZE; |
@@ -725,7 +725,7 @@ static int em28xx_v4l2_mmap(struct file *filp, struct vm_area_struct *vma) | |||
725 | vma->vm_private_data = &dev->frame[i]; | 725 | vma->vm_private_data = &dev->frame[i]; |
726 | 726 | ||
727 | em28xx_vm_open(vma); | 727 | em28xx_vm_open(vma); |
728 | up(&dev->fileop_lock); | 728 | mutex_unlock(&dev->fileop_lock); |
729 | return 0; | 729 | return 0; |
730 | } | 730 | } |
731 | 731 | ||
@@ -1125,7 +1125,7 @@ static int em28xx_do_ioctl(struct inode *inode, struct file *filp, | |||
1125 | if (i == TVNORMS) | 1125 | if (i == TVNORMS) |
1126 | return -EINVAL; | 1126 | return -EINVAL; |
1127 | 1127 | ||
1128 | down(&dev->lock); | 1128 | mutex_lock(&dev->lock); |
1129 | dev->tvnorm = &tvnorms[i]; | 1129 | dev->tvnorm = &tvnorms[i]; |
1130 | 1130 | ||
1131 | em28xx_set_norm(dev, dev->width, dev->height); | 1131 | em28xx_set_norm(dev, dev->width, dev->height); |
@@ -1135,7 +1135,7 @@ static int em28xx_do_ioctl(struct inode *inode, struct file *filp, | |||
1135 | em28xx_i2c_call_clients(dev, VIDIOC_S_STD, | 1135 | em28xx_i2c_call_clients(dev, VIDIOC_S_STD, |
1136 | &dev->tvnorm->id); | 1136 | &dev->tvnorm->id); |
1137 | 1137 | ||
1138 | up(&dev->lock); | 1138 | mutex_unlock(&dev->lock); |
1139 | 1139 | ||
1140 | return 0; | 1140 | return 0; |
1141 | } | 1141 | } |
@@ -1189,9 +1189,9 @@ static int em28xx_do_ioctl(struct inode *inode, struct file *filp, | |||
1189 | if (0 == INPUT(*index)->type) | 1189 | if (0 == INPUT(*index)->type) |
1190 | return -EINVAL; | 1190 | return -EINVAL; |
1191 | 1191 | ||
1192 | down(&dev->lock); | 1192 | mutex_lock(&dev->lock); |
1193 | video_mux(dev, *index); | 1193 | video_mux(dev, *index); |
1194 | up(&dev->lock); | 1194 | mutex_unlock(&dev->lock); |
1195 | 1195 | ||
1196 | return 0; | 1196 | return 0; |
1197 | } | 1197 | } |
@@ -1338,10 +1338,10 @@ static int em28xx_do_ioctl(struct inode *inode, struct file *filp, | |||
1338 | /* t->signal = 0xffff;*/ | 1338 | /* t->signal = 0xffff;*/ |
1339 | /* em28xx_i2c_call_clients(dev,VIDIOC_G_TUNER,t);*/ | 1339 | /* em28xx_i2c_call_clients(dev,VIDIOC_G_TUNER,t);*/ |
1340 | /* No way to get signal strength? */ | 1340 | /* No way to get signal strength? */ |
1341 | down(&dev->lock); | 1341 | mutex_lock(&dev->lock); |
1342 | em28xx_i2c_call_clients(dev, DECODER_GET_STATUS, | 1342 | em28xx_i2c_call_clients(dev, DECODER_GET_STATUS, |
1343 | &status); | 1343 | &status); |
1344 | up(&dev->lock); | 1344 | mutex_unlock(&dev->lock); |
1345 | t->signal = | 1345 | t->signal = |
1346 | (status & DECODER_STATUS_GOOD) != 0 ? 0xffff : 0; | 1346 | (status & DECODER_STATUS_GOOD) != 0 ? 0xffff : 0; |
1347 | 1347 | ||
@@ -1363,10 +1363,10 @@ static int em28xx_do_ioctl(struct inode *inode, struct file *filp, | |||
1363 | t->rangehigh = 0xffffffffUL; /* FIXME: set correct range */ | 1363 | t->rangehigh = 0xffffffffUL; /* FIXME: set correct range */ |
1364 | /* t->signal = 0xffff; */ | 1364 | /* t->signal = 0xffff; */ |
1365 | /* No way to get signal strength? */ | 1365 | /* No way to get signal strength? */ |
1366 | down(&dev->lock); | 1366 | mutex_lock(&dev->lock); |
1367 | em28xx_i2c_call_clients(dev, DECODER_GET_STATUS, | 1367 | em28xx_i2c_call_clients(dev, DECODER_GET_STATUS, |
1368 | &status); | 1368 | &status); |
1369 | up(&dev->lock); | 1369 | mutex_unlock(&dev->lock); |
1370 | t->signal = | 1370 | t->signal = |
1371 | (status & DECODER_STATUS_GOOD) != 0 ? 0xffff : 0; | 1371 | (status & DECODER_STATUS_GOOD) != 0 ? 0xffff : 0; |
1372 | 1372 | ||
@@ -1394,10 +1394,10 @@ static int em28xx_do_ioctl(struct inode *inode, struct file *filp, | |||
1394 | if (V4L2_TUNER_ANALOG_TV != f->type) | 1394 | if (V4L2_TUNER_ANALOG_TV != f->type) |
1395 | return -EINVAL; | 1395 | return -EINVAL; |
1396 | 1396 | ||
1397 | down(&dev->lock); | 1397 | mutex_lock(&dev->lock); |
1398 | dev->ctl_freq = f->frequency; | 1398 | dev->ctl_freq = f->frequency; |
1399 | em28xx_i2c_call_clients(dev, VIDIOC_S_FREQUENCY, f); | 1399 | em28xx_i2c_call_clients(dev, VIDIOC_S_FREQUENCY, f); |
1400 | up(&dev->lock); | 1400 | mutex_unlock(&dev->lock); |
1401 | return 0; | 1401 | return 0; |
1402 | } | 1402 | } |
1403 | case VIDIOC_CROPCAP: | 1403 | case VIDIOC_CROPCAP: |
@@ -1660,25 +1660,25 @@ static int em28xx_v4l2_ioctl(struct inode *inode, struct file *filp, | |||
1660 | int ret = 0; | 1660 | int ret = 0; |
1661 | struct em28xx *dev = filp->private_data; | 1661 | struct em28xx *dev = filp->private_data; |
1662 | 1662 | ||
1663 | if (down_interruptible(&dev->fileop_lock)) | 1663 | if (mutex_lock_interruptible(&dev->fileop_lock)) |
1664 | return -ERESTARTSYS; | 1664 | return -ERESTARTSYS; |
1665 | 1665 | ||
1666 | if (dev->state & DEV_DISCONNECTED) { | 1666 | if (dev->state & DEV_DISCONNECTED) { |
1667 | em28xx_errdev("v4l2 ioctl: device not present\n"); | 1667 | em28xx_errdev("v4l2 ioctl: device not present\n"); |
1668 | up(&dev->fileop_lock); | 1668 | mutex_unlock(&dev->fileop_lock); |
1669 | return -ENODEV; | 1669 | return -ENODEV; |
1670 | } | 1670 | } |
1671 | 1671 | ||
1672 | if (dev->state & DEV_MISCONFIGURED) { | 1672 | if (dev->state & DEV_MISCONFIGURED) { |
1673 | em28xx_errdev | 1673 | em28xx_errdev |
1674 | ("v4l2 ioctl: device is misconfigured; close and open it again\n"); | 1674 | ("v4l2 ioctl: device is misconfigured; close and open it again\n"); |
1675 | up(&dev->fileop_lock); | 1675 | mutex_unlock(&dev->fileop_lock); |
1676 | return -EIO; | 1676 | return -EIO; |
1677 | } | 1677 | } |
1678 | 1678 | ||
1679 | ret = video_usercopy(inode, filp, cmd, arg, em28xx_video_do_ioctl); | 1679 | ret = video_usercopy(inode, filp, cmd, arg, em28xx_video_do_ioctl); |
1680 | 1680 | ||
1681 | up(&dev->fileop_lock); | 1681 | mutex_unlock(&dev->fileop_lock); |
1682 | 1682 | ||
1683 | return ret; | 1683 | return ret; |
1684 | } | 1684 | } |
@@ -1712,7 +1712,7 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev, | |||
1712 | 1712 | ||
1713 | dev->udev = udev; | 1713 | dev->udev = udev; |
1714 | dev->model = model; | 1714 | dev->model = model; |
1715 | init_MUTEX(&dev->lock); | 1715 | mutex_init(&dev->lock); |
1716 | init_waitqueue_head(&dev->open); | 1716 | init_waitqueue_head(&dev->open); |
1717 | 1717 | ||
1718 | dev->em28xx_write_regs = em28xx_write_regs; | 1718 | dev->em28xx_write_regs = em28xx_write_regs; |
@@ -1788,7 +1788,7 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev, | |||
1788 | return -ENOMEM; | 1788 | return -ENOMEM; |
1789 | } | 1789 | } |
1790 | 1790 | ||
1791 | down(&dev->lock); | 1791 | mutex_lock(&dev->lock); |
1792 | /* register i2c bus */ | 1792 | /* register i2c bus */ |
1793 | em28xx_i2c_register(dev); | 1793 | em28xx_i2c_register(dev); |
1794 | 1794 | ||
@@ -1798,7 +1798,7 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev, | |||
1798 | /* configure the device */ | 1798 | /* configure the device */ |
1799 | em28xx_config_i2c(dev); | 1799 | em28xx_config_i2c(dev); |
1800 | 1800 | ||
1801 | up(&dev->lock); | 1801 | mutex_unlock(&dev->lock); |
1802 | 1802 | ||
1803 | errCode = em28xx_config(dev); | 1803 | errCode = em28xx_config(dev); |
1804 | 1804 | ||
@@ -1849,12 +1849,12 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev, | |||
1849 | list_add_tail(&dev->devlist,&em28xx_devlist); | 1849 | list_add_tail(&dev->devlist,&em28xx_devlist); |
1850 | 1850 | ||
1851 | /* register v4l2 device */ | 1851 | /* register v4l2 device */ |
1852 | down(&dev->lock); | 1852 | mutex_lock(&dev->lock); |
1853 | if ((retval = video_register_device(dev->vdev, VFL_TYPE_GRABBER, | 1853 | if ((retval = video_register_device(dev->vdev, VFL_TYPE_GRABBER, |
1854 | video_nr[dev->devno]))) { | 1854 | video_nr[dev->devno]))) { |
1855 | em28xx_errdev("unable to register video device (error=%i).\n", | 1855 | em28xx_errdev("unable to register video device (error=%i).\n", |
1856 | retval); | 1856 | retval); |
1857 | up(&dev->lock); | 1857 | mutex_unlock(&dev->lock); |
1858 | list_del(&dev->devlist); | 1858 | list_del(&dev->devlist); |
1859 | video_device_release(dev->vdev); | 1859 | video_device_release(dev->vdev); |
1860 | kfree(dev); | 1860 | kfree(dev); |
@@ -1865,7 +1865,7 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev, | |||
1865 | if (video_register_device(dev->vbi_dev, VFL_TYPE_VBI, | 1865 | if (video_register_device(dev->vbi_dev, VFL_TYPE_VBI, |
1866 | vbi_nr[dev->devno]) < 0) { | 1866 | vbi_nr[dev->devno]) < 0) { |
1867 | printk("unable to register vbi device\n"); | 1867 | printk("unable to register vbi device\n"); |
1868 | up(&dev->lock); | 1868 | mutex_unlock(&dev->lock); |
1869 | list_del(&dev->devlist); | 1869 | list_del(&dev->devlist); |
1870 | video_device_release(dev->vbi_dev); | 1870 | video_device_release(dev->vbi_dev); |
1871 | video_device_release(dev->vdev); | 1871 | video_device_release(dev->vdev); |
@@ -1886,7 +1886,7 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev, | |||
1886 | } | 1886 | } |
1887 | video_mux(dev, 0); | 1887 | video_mux(dev, 0); |
1888 | 1888 | ||
1889 | up(&dev->lock); | 1889 | mutex_unlock(&dev->lock); |
1890 | 1890 | ||
1891 | em28xx_info("V4L2 device registered as /dev/video%d and /dev/vbi%d\n", | 1891 | em28xx_info("V4L2 device registered as /dev/video%d and /dev/vbi%d\n", |
1892 | dev->vdev->minor-MINOR_VFL_TYPE_GRABBER_MIN, | 1892 | dev->vdev->minor-MINOR_VFL_TYPE_GRABBER_MIN, |
@@ -2035,7 +2035,7 @@ static void em28xx_usb_disconnect(struct usb_interface *interface) | |||
2035 | 2035 | ||
2036 | down_write(&em28xx_disconnect); | 2036 | down_write(&em28xx_disconnect); |
2037 | 2037 | ||
2038 | down(&dev->lock); | 2038 | mutex_lock(&dev->lock); |
2039 | 2039 | ||
2040 | em28xx_info("disconnecting %s\n", dev->vdev->name); | 2040 | em28xx_info("disconnecting %s\n", dev->vdev->name); |
2041 | 2041 | ||
@@ -2057,7 +2057,7 @@ static void em28xx_usb_disconnect(struct usb_interface *interface) | |||
2057 | em28xx_release_resources(dev); | 2057 | em28xx_release_resources(dev); |
2058 | } | 2058 | } |
2059 | 2059 | ||
2060 | up(&dev->lock); | 2060 | mutex_unlock(&dev->lock); |
2061 | 2061 | ||
2062 | if (!dev->users) { | 2062 | if (!dev->users) { |
2063 | kfree(dev->alt_max_pkt_size); | 2063 | kfree(dev->alt_max_pkt_size); |
diff --git a/drivers/media/video/em28xx/em28xx.h b/drivers/media/video/em28xx/em28xx.h index ddf06c520e99..4e2fe62b7350 100644 --- a/drivers/media/video/em28xx/em28xx.h +++ b/drivers/media/video/em28xx/em28xx.h | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | #include <linux/videodev.h> | 28 | #include <linux/videodev.h> |
29 | #include <linux/i2c.h> | 29 | #include <linux/i2c.h> |
30 | #include <linux/mutex.h> | ||
30 | #include <media/ir-kbd-i2c.h> | 31 | #include <media/ir-kbd-i2c.h> |
31 | 32 | ||
32 | /* Boards supported by driver */ | 33 | /* Boards supported by driver */ |
@@ -260,7 +261,7 @@ struct em28xx { | |||
260 | enum em28xx_stream_state stream; | 261 | enum em28xx_stream_state stream; |
261 | enum em28xx_io_method io; | 262 | enum em28xx_io_method io; |
262 | /* locks */ | 263 | /* locks */ |
263 | struct semaphore lock, fileop_lock; | 264 | struct mutex lock, fileop_lock; |
264 | spinlock_t queue_lock; | 265 | spinlock_t queue_lock; |
265 | struct list_head inqueue, outqueue; | 266 | struct list_head inqueue, outqueue; |
266 | wait_queue_head_t open, wait_frame, wait_stream; | 267 | wait_queue_head_t open, wait_frame, wait_stream; |
diff --git a/drivers/media/video/meye.c b/drivers/media/video/meye.c index 2869464aee0d..850bee97090c 100644 --- a/drivers/media/video/meye.c +++ b/drivers/media/video/meye.c | |||
@@ -925,7 +925,7 @@ static int meye_do_ioctl(struct inode *inode, struct file *file, | |||
925 | return -EINVAL; | 925 | return -EINVAL; |
926 | if (p->palette != VIDEO_PALETTE_YUV422) | 926 | if (p->palette != VIDEO_PALETTE_YUV422) |
927 | return -EINVAL; | 927 | return -EINVAL; |
928 | down(&meye.lock); | 928 | mutex_lock(&meye.lock); |
929 | sonypi_camera_command(SONYPI_COMMAND_SETCAMERABRIGHTNESS, | 929 | sonypi_camera_command(SONYPI_COMMAND_SETCAMERABRIGHTNESS, |
930 | p->brightness >> 10); | 930 | p->brightness >> 10); |
931 | sonypi_camera_command(SONYPI_COMMAND_SETCAMERAHUE, | 931 | sonypi_camera_command(SONYPI_COMMAND_SETCAMERAHUE, |
@@ -935,7 +935,7 @@ static int meye_do_ioctl(struct inode *inode, struct file *file, | |||
935 | sonypi_camera_command(SONYPI_COMMAND_SETCAMERACONTRAST, | 935 | sonypi_camera_command(SONYPI_COMMAND_SETCAMERACONTRAST, |
936 | p->contrast >> 10); | 936 | p->contrast >> 10); |
937 | meye.picture = *p; | 937 | meye.picture = *p; |
938 | up(&meye.lock); | 938 | mutex_unlock(&meye.lock); |
939 | break; | 939 | break; |
940 | } | 940 | } |
941 | 941 | ||
@@ -946,21 +946,21 @@ static int meye_do_ioctl(struct inode *inode, struct file *file, | |||
946 | if (*i < 0 || *i >= gbuffers) | 946 | if (*i < 0 || *i >= gbuffers) |
947 | return -EINVAL; | 947 | return -EINVAL; |
948 | 948 | ||
949 | down(&meye.lock); | 949 | mutex_lock(&meye.lock); |
950 | 950 | ||
951 | switch (meye.grab_buffer[*i].state) { | 951 | switch (meye.grab_buffer[*i].state) { |
952 | 952 | ||
953 | case MEYE_BUF_UNUSED: | 953 | case MEYE_BUF_UNUSED: |
954 | up(&meye.lock); | 954 | mutex_unlock(&meye.lock); |
955 | return -EINVAL; | 955 | return -EINVAL; |
956 | case MEYE_BUF_USING: | 956 | case MEYE_BUF_USING: |
957 | if (file->f_flags & O_NONBLOCK) { | 957 | if (file->f_flags & O_NONBLOCK) { |
958 | up(&meye.lock); | 958 | mutex_unlock(&meye.lock); |
959 | return -EAGAIN; | 959 | return -EAGAIN; |
960 | } | 960 | } |
961 | if (wait_event_interruptible(meye.proc_list, | 961 | if (wait_event_interruptible(meye.proc_list, |
962 | (meye.grab_buffer[*i].state != MEYE_BUF_USING))) { | 962 | (meye.grab_buffer[*i].state != MEYE_BUF_USING))) { |
963 | up(&meye.lock); | 963 | mutex_unlock(&meye.lock); |
964 | return -EINTR; | 964 | return -EINTR; |
965 | } | 965 | } |
966 | /* fall through */ | 966 | /* fall through */ |
@@ -968,7 +968,7 @@ static int meye_do_ioctl(struct inode *inode, struct file *file, | |||
968 | meye.grab_buffer[*i].state = MEYE_BUF_UNUSED; | 968 | meye.grab_buffer[*i].state = MEYE_BUF_UNUSED; |
969 | kfifo_get(meye.doneq, (unsigned char *)&unused, sizeof(int)); | 969 | kfifo_get(meye.doneq, (unsigned char *)&unused, sizeof(int)); |
970 | } | 970 | } |
971 | up(&meye.lock); | 971 | mutex_unlock(&meye.lock); |
972 | break; | 972 | break; |
973 | } | 973 | } |
974 | 974 | ||
@@ -987,7 +987,7 @@ static int meye_do_ioctl(struct inode *inode, struct file *file, | |||
987 | if (meye.grab_buffer[vm->frame].state != MEYE_BUF_UNUSED) | 987 | if (meye.grab_buffer[vm->frame].state != MEYE_BUF_UNUSED) |
988 | return -EBUSY; | 988 | return -EBUSY; |
989 | 989 | ||
990 | down(&meye.lock); | 990 | mutex_lock(&meye.lock); |
991 | if (vm->width == 640 && vm->height == 480) { | 991 | if (vm->width == 640 && vm->height == 480) { |
992 | if (meye.params.subsample) { | 992 | if (meye.params.subsample) { |
993 | meye.params.subsample = 0; | 993 | meye.params.subsample = 0; |
@@ -999,7 +999,7 @@ static int meye_do_ioctl(struct inode *inode, struct file *file, | |||
999 | restart = 1; | 999 | restart = 1; |
1000 | } | 1000 | } |
1001 | } else { | 1001 | } else { |
1002 | up(&meye.lock); | 1002 | mutex_unlock(&meye.lock); |
1003 | return -EINVAL; | 1003 | return -EINVAL; |
1004 | } | 1004 | } |
1005 | 1005 | ||
@@ -1007,7 +1007,7 @@ static int meye_do_ioctl(struct inode *inode, struct file *file, | |||
1007 | mchip_continuous_start(); | 1007 | mchip_continuous_start(); |
1008 | meye.grab_buffer[vm->frame].state = MEYE_BUF_USING; | 1008 | meye.grab_buffer[vm->frame].state = MEYE_BUF_USING; |
1009 | kfifo_put(meye.grabq, (unsigned char *)&vm->frame, sizeof(int)); | 1009 | kfifo_put(meye.grabq, (unsigned char *)&vm->frame, sizeof(int)); |
1010 | up(&meye.lock); | 1010 | mutex_unlock(&meye.lock); |
1011 | break; | 1011 | break; |
1012 | } | 1012 | } |
1013 | 1013 | ||
@@ -1039,7 +1039,7 @@ static int meye_do_ioctl(struct inode *inode, struct file *file, | |||
1039 | return -EINVAL; | 1039 | return -EINVAL; |
1040 | if (jp->framerate > 31) | 1040 | if (jp->framerate > 31) |
1041 | return -EINVAL; | 1041 | return -EINVAL; |
1042 | down(&meye.lock); | 1042 | mutex_lock(&meye.lock); |
1043 | if (meye.params.subsample != jp->subsample || | 1043 | if (meye.params.subsample != jp->subsample || |
1044 | meye.params.quality != jp->quality) | 1044 | meye.params.quality != jp->quality) |
1045 | mchip_hic_stop(); /* need restart */ | 1045 | mchip_hic_stop(); /* need restart */ |
@@ -1050,7 +1050,7 @@ static int meye_do_ioctl(struct inode *inode, struct file *file, | |||
1050 | meye.params.agc); | 1050 | meye.params.agc); |
1051 | sonypi_camera_command(SONYPI_COMMAND_SETCAMERAPICTURE, | 1051 | sonypi_camera_command(SONYPI_COMMAND_SETCAMERAPICTURE, |
1052 | meye.params.picture); | 1052 | meye.params.picture); |
1053 | up(&meye.lock); | 1053 | mutex_unlock(&meye.lock); |
1054 | break; | 1054 | break; |
1055 | } | 1055 | } |
1056 | 1056 | ||
@@ -1068,12 +1068,12 @@ static int meye_do_ioctl(struct inode *inode, struct file *file, | |||
1068 | } | 1068 | } |
1069 | if (meye.grab_buffer[*nb].state != MEYE_BUF_UNUSED) | 1069 | if (meye.grab_buffer[*nb].state != MEYE_BUF_UNUSED) |
1070 | return -EBUSY; | 1070 | return -EBUSY; |
1071 | down(&meye.lock); | 1071 | mutex_lock(&meye.lock); |
1072 | if (meye.mchip_mode != MCHIP_HIC_MODE_CONT_COMP) | 1072 | if (meye.mchip_mode != MCHIP_HIC_MODE_CONT_COMP) |
1073 | mchip_cont_compression_start(); | 1073 | mchip_cont_compression_start(); |
1074 | meye.grab_buffer[*nb].state = MEYE_BUF_USING; | 1074 | meye.grab_buffer[*nb].state = MEYE_BUF_USING; |
1075 | kfifo_put(meye.grabq, (unsigned char *)nb, sizeof(int)); | 1075 | kfifo_put(meye.grabq, (unsigned char *)nb, sizeof(int)); |
1076 | up(&meye.lock); | 1076 | mutex_unlock(&meye.lock); |
1077 | break; | 1077 | break; |
1078 | } | 1078 | } |
1079 | 1079 | ||
@@ -1084,20 +1084,20 @@ static int meye_do_ioctl(struct inode *inode, struct file *file, | |||
1084 | if (*i < 0 || *i >= gbuffers) | 1084 | if (*i < 0 || *i >= gbuffers) |
1085 | return -EINVAL; | 1085 | return -EINVAL; |
1086 | 1086 | ||
1087 | down(&meye.lock); | 1087 | mutex_lock(&meye.lock); |
1088 | switch (meye.grab_buffer[*i].state) { | 1088 | switch (meye.grab_buffer[*i].state) { |
1089 | 1089 | ||
1090 | case MEYE_BUF_UNUSED: | 1090 | case MEYE_BUF_UNUSED: |
1091 | up(&meye.lock); | 1091 | mutex_unlock(&meye.lock); |
1092 | return -EINVAL; | 1092 | return -EINVAL; |
1093 | case MEYE_BUF_USING: | 1093 | case MEYE_BUF_USING: |
1094 | if (file->f_flags & O_NONBLOCK) { | 1094 | if (file->f_flags & O_NONBLOCK) { |
1095 | up(&meye.lock); | 1095 | mutex_unlock(&meye.lock); |
1096 | return -EAGAIN; | 1096 | return -EAGAIN; |
1097 | } | 1097 | } |
1098 | if (wait_event_interruptible(meye.proc_list, | 1098 | if (wait_event_interruptible(meye.proc_list, |
1099 | (meye.grab_buffer[*i].state != MEYE_BUF_USING))) { | 1099 | (meye.grab_buffer[*i].state != MEYE_BUF_USING))) { |
1100 | up(&meye.lock); | 1100 | mutex_unlock(&meye.lock); |
1101 | return -EINTR; | 1101 | return -EINTR; |
1102 | } | 1102 | } |
1103 | /* fall through */ | 1103 | /* fall through */ |
@@ -1106,7 +1106,7 @@ static int meye_do_ioctl(struct inode *inode, struct file *file, | |||
1106 | kfifo_get(meye.doneq, (unsigned char *)&unused, sizeof(int)); | 1106 | kfifo_get(meye.doneq, (unsigned char *)&unused, sizeof(int)); |
1107 | } | 1107 | } |
1108 | *i = meye.grab_buffer[*i].size; | 1108 | *i = meye.grab_buffer[*i].size; |
1109 | up(&meye.lock); | 1109 | mutex_unlock(&meye.lock); |
1110 | break; | 1110 | break; |
1111 | } | 1111 | } |
1112 | 1112 | ||
@@ -1116,14 +1116,14 @@ static int meye_do_ioctl(struct inode *inode, struct file *file, | |||
1116 | return -EINVAL; | 1116 | return -EINVAL; |
1117 | if (meye.grab_buffer[0].state != MEYE_BUF_UNUSED) | 1117 | if (meye.grab_buffer[0].state != MEYE_BUF_UNUSED) |
1118 | return -EBUSY; | 1118 | return -EBUSY; |
1119 | down(&meye.lock); | 1119 | mutex_lock(&meye.lock); |
1120 | meye.grab_buffer[0].state = MEYE_BUF_USING; | 1120 | meye.grab_buffer[0].state = MEYE_BUF_USING; |
1121 | mchip_take_picture(); | 1121 | mchip_take_picture(); |
1122 | mchip_get_picture( | 1122 | mchip_get_picture( |
1123 | meye.grab_fbuffer, | 1123 | meye.grab_fbuffer, |
1124 | mchip_hsize() * mchip_vsize() * 2); | 1124 | mchip_hsize() * mchip_vsize() * 2); |
1125 | meye.grab_buffer[0].state = MEYE_BUF_DONE; | 1125 | meye.grab_buffer[0].state = MEYE_BUF_DONE; |
1126 | up(&meye.lock); | 1126 | mutex_unlock(&meye.lock); |
1127 | break; | 1127 | break; |
1128 | } | 1128 | } |
1129 | 1129 | ||
@@ -1134,7 +1134,7 @@ static int meye_do_ioctl(struct inode *inode, struct file *file, | |||
1134 | return -EINVAL; | 1134 | return -EINVAL; |
1135 | if (meye.grab_buffer[0].state != MEYE_BUF_UNUSED) | 1135 | if (meye.grab_buffer[0].state != MEYE_BUF_UNUSED) |
1136 | return -EBUSY; | 1136 | return -EBUSY; |
1137 | down(&meye.lock); | 1137 | mutex_lock(&meye.lock); |
1138 | meye.grab_buffer[0].state = MEYE_BUF_USING; | 1138 | meye.grab_buffer[0].state = MEYE_BUF_USING; |
1139 | *len = -1; | 1139 | *len = -1; |
1140 | while (*len == -1) { | 1140 | while (*len == -1) { |
@@ -1142,7 +1142,7 @@ static int meye_do_ioctl(struct inode *inode, struct file *file, | |||
1142 | *len = mchip_compress_frame(meye.grab_fbuffer, gbufsize); | 1142 | *len = mchip_compress_frame(meye.grab_fbuffer, gbufsize); |
1143 | } | 1143 | } |
1144 | meye.grab_buffer[0].state = MEYE_BUF_DONE; | 1144 | meye.grab_buffer[0].state = MEYE_BUF_DONE; |
1145 | up(&meye.lock); | 1145 | mutex_unlock(&meye.lock); |
1146 | break; | 1146 | break; |
1147 | } | 1147 | } |
1148 | 1148 | ||
@@ -1285,7 +1285,7 @@ static int meye_do_ioctl(struct inode *inode, struct file *file, | |||
1285 | case VIDIOC_S_CTRL: { | 1285 | case VIDIOC_S_CTRL: { |
1286 | struct v4l2_control *c = arg; | 1286 | struct v4l2_control *c = arg; |
1287 | 1287 | ||
1288 | down(&meye.lock); | 1288 | mutex_lock(&meye.lock); |
1289 | switch (c->id) { | 1289 | switch (c->id) { |
1290 | case V4L2_CID_BRIGHTNESS: | 1290 | case V4L2_CID_BRIGHTNESS: |
1291 | sonypi_camera_command( | 1291 | sonypi_camera_command( |
@@ -1329,17 +1329,17 @@ static int meye_do_ioctl(struct inode *inode, struct file *file, | |||
1329 | meye.params.framerate = c->value; | 1329 | meye.params.framerate = c->value; |
1330 | break; | 1330 | break; |
1331 | default: | 1331 | default: |
1332 | up(&meye.lock); | 1332 | mutex_unlock(&meye.lock); |
1333 | return -EINVAL; | 1333 | return -EINVAL; |
1334 | } | 1334 | } |
1335 | up(&meye.lock); | 1335 | mutex_unlock(&meye.lock); |
1336 | break; | 1336 | break; |
1337 | } | 1337 | } |
1338 | 1338 | ||
1339 | case VIDIOC_G_CTRL: { | 1339 | case VIDIOC_G_CTRL: { |
1340 | struct v4l2_control *c = arg; | 1340 | struct v4l2_control *c = arg; |
1341 | 1341 | ||
1342 | down(&meye.lock); | 1342 | mutex_lock(&meye.lock); |
1343 | switch (c->id) { | 1343 | switch (c->id) { |
1344 | case V4L2_CID_BRIGHTNESS: | 1344 | case V4L2_CID_BRIGHTNESS: |
1345 | c->value = meye.picture.brightness >> 10; | 1345 | c->value = meye.picture.brightness >> 10; |
@@ -1369,10 +1369,10 @@ static int meye_do_ioctl(struct inode *inode, struct file *file, | |||
1369 | c->value = meye.params.framerate; | 1369 | c->value = meye.params.framerate; |
1370 | break; | 1370 | break; |
1371 | default: | 1371 | default: |
1372 | up(&meye.lock); | 1372 | mutex_unlock(&meye.lock); |
1373 | return -EINVAL; | 1373 | return -EINVAL; |
1374 | } | 1374 | } |
1375 | up(&meye.lock); | 1375 | mutex_unlock(&meye.lock); |
1376 | break; | 1376 | break; |
1377 | } | 1377 | } |
1378 | 1378 | ||
@@ -1469,7 +1469,7 @@ static int meye_do_ioctl(struct inode *inode, struct file *file, | |||
1469 | f->fmt.pix.field != V4L2_FIELD_NONE) | 1469 | f->fmt.pix.field != V4L2_FIELD_NONE) |
1470 | return -EINVAL; | 1470 | return -EINVAL; |
1471 | f->fmt.pix.field = V4L2_FIELD_NONE; | 1471 | f->fmt.pix.field = V4L2_FIELD_NONE; |
1472 | down(&meye.lock); | 1472 | mutex_lock(&meye.lock); |
1473 | if (f->fmt.pix.width <= 320) { | 1473 | if (f->fmt.pix.width <= 320) { |
1474 | f->fmt.pix.width = 320; | 1474 | f->fmt.pix.width = 320; |
1475 | f->fmt.pix.height = 240; | 1475 | f->fmt.pix.height = 240; |
@@ -1487,7 +1487,7 @@ static int meye_do_ioctl(struct inode *inode, struct file *file, | |||
1487 | meye.mchip_mode = MCHIP_HIC_MODE_CONT_COMP; | 1487 | meye.mchip_mode = MCHIP_HIC_MODE_CONT_COMP; |
1488 | break; | 1488 | break; |
1489 | } | 1489 | } |
1490 | up(&meye.lock); | 1490 | mutex_unlock(&meye.lock); |
1491 | f->fmt.pix.bytesperline = f->fmt.pix.width * 2; | 1491 | f->fmt.pix.bytesperline = f->fmt.pix.width * 2; |
1492 | f->fmt.pix.sizeimage = f->fmt.pix.height * | 1492 | f->fmt.pix.sizeimage = f->fmt.pix.height * |
1493 | f->fmt.pix.bytesperline; | 1493 | f->fmt.pix.bytesperline; |
@@ -1509,11 +1509,11 @@ static int meye_do_ioctl(struct inode *inode, struct file *file, | |||
1509 | /* already allocated, no modifications */ | 1509 | /* already allocated, no modifications */ |
1510 | break; | 1510 | break; |
1511 | } | 1511 | } |
1512 | down(&meye.lock); | 1512 | mutex_lock(&meye.lock); |
1513 | if (meye.grab_fbuffer) { | 1513 | if (meye.grab_fbuffer) { |
1514 | for (i = 0; i < gbuffers; i++) | 1514 | for (i = 0; i < gbuffers; i++) |
1515 | if (meye.vma_use_count[i]) { | 1515 | if (meye.vma_use_count[i]) { |
1516 | up(&meye.lock); | 1516 | mutex_unlock(&meye.lock); |
1517 | return -EINVAL; | 1517 | return -EINVAL; |
1518 | } | 1518 | } |
1519 | rvfree(meye.grab_fbuffer, gbuffers * gbufsize); | 1519 | rvfree(meye.grab_fbuffer, gbuffers * gbufsize); |
@@ -1525,12 +1525,12 @@ static int meye_do_ioctl(struct inode *inode, struct file *file, | |||
1525 | if (!meye.grab_fbuffer) { | 1525 | if (!meye.grab_fbuffer) { |
1526 | printk(KERN_ERR "meye: v4l framebuffer allocation" | 1526 | printk(KERN_ERR "meye: v4l framebuffer allocation" |
1527 | " failed\n"); | 1527 | " failed\n"); |
1528 | up(&meye.lock); | 1528 | mutex_unlock(&meye.lock); |
1529 | return -ENOMEM; | 1529 | return -ENOMEM; |
1530 | } | 1530 | } |
1531 | for (i = 0; i < gbuffers; i++) | 1531 | for (i = 0; i < gbuffers; i++) |
1532 | meye.vma_use_count[i] = 0; | 1532 | meye.vma_use_count[i] = 0; |
1533 | up(&meye.lock); | 1533 | mutex_unlock(&meye.lock); |
1534 | break; | 1534 | break; |
1535 | } | 1535 | } |
1536 | 1536 | ||
@@ -1569,12 +1569,12 @@ static int meye_do_ioctl(struct inode *inode, struct file *file, | |||
1569 | return -EINVAL; | 1569 | return -EINVAL; |
1570 | if (meye.grab_buffer[buf->index].state != MEYE_BUF_UNUSED) | 1570 | if (meye.grab_buffer[buf->index].state != MEYE_BUF_UNUSED) |
1571 | return -EINVAL; | 1571 | return -EINVAL; |
1572 | down(&meye.lock); | 1572 | mutex_lock(&meye.lock); |
1573 | buf->flags |= V4L2_BUF_FLAG_QUEUED; | 1573 | buf->flags |= V4L2_BUF_FLAG_QUEUED; |
1574 | buf->flags &= ~V4L2_BUF_FLAG_DONE; | 1574 | buf->flags &= ~V4L2_BUF_FLAG_DONE; |
1575 | meye.grab_buffer[buf->index].state = MEYE_BUF_USING; | 1575 | meye.grab_buffer[buf->index].state = MEYE_BUF_USING; |
1576 | kfifo_put(meye.grabq, (unsigned char *)&buf->index, sizeof(int)); | 1576 | kfifo_put(meye.grabq, (unsigned char *)&buf->index, sizeof(int)); |
1577 | up(&meye.lock); | 1577 | mutex_unlock(&meye.lock); |
1578 | break; | 1578 | break; |
1579 | } | 1579 | } |
1580 | 1580 | ||
@@ -1587,23 +1587,23 @@ static int meye_do_ioctl(struct inode *inode, struct file *file, | |||
1587 | if (buf->memory != V4L2_MEMORY_MMAP) | 1587 | if (buf->memory != V4L2_MEMORY_MMAP) |
1588 | return -EINVAL; | 1588 | return -EINVAL; |
1589 | 1589 | ||
1590 | down(&meye.lock); | 1590 | mutex_lock(&meye.lock); |
1591 | if (kfifo_len(meye.doneq) == 0 && file->f_flags & O_NONBLOCK) { | 1591 | if (kfifo_len(meye.doneq) == 0 && file->f_flags & O_NONBLOCK) { |
1592 | up(&meye.lock); | 1592 | mutex_unlock(&meye.lock); |
1593 | return -EAGAIN; | 1593 | return -EAGAIN; |
1594 | } | 1594 | } |
1595 | if (wait_event_interruptible(meye.proc_list, | 1595 | if (wait_event_interruptible(meye.proc_list, |
1596 | kfifo_len(meye.doneq) != 0) < 0) { | 1596 | kfifo_len(meye.doneq) != 0) < 0) { |
1597 | up(&meye.lock); | 1597 | mutex_unlock(&meye.lock); |
1598 | return -EINTR; | 1598 | return -EINTR; |
1599 | } | 1599 | } |
1600 | if (!kfifo_get(meye.doneq, (unsigned char *)&reqnr, | 1600 | if (!kfifo_get(meye.doneq, (unsigned char *)&reqnr, |
1601 | sizeof(int))) { | 1601 | sizeof(int))) { |
1602 | up(&meye.lock); | 1602 | mutex_unlock(&meye.lock); |
1603 | return -EBUSY; | 1603 | return -EBUSY; |
1604 | } | 1604 | } |
1605 | if (meye.grab_buffer[reqnr].state != MEYE_BUF_DONE) { | 1605 | if (meye.grab_buffer[reqnr].state != MEYE_BUF_DONE) { |
1606 | up(&meye.lock); | 1606 | mutex_unlock(&meye.lock); |
1607 | return -EINVAL; | 1607 | return -EINVAL; |
1608 | } | 1608 | } |
1609 | buf->index = reqnr; | 1609 | buf->index = reqnr; |
@@ -1616,12 +1616,12 @@ static int meye_do_ioctl(struct inode *inode, struct file *file, | |||
1616 | buf->m.offset = reqnr * gbufsize; | 1616 | buf->m.offset = reqnr * gbufsize; |
1617 | buf->length = gbufsize; | 1617 | buf->length = gbufsize; |
1618 | meye.grab_buffer[reqnr].state = MEYE_BUF_UNUSED; | 1618 | meye.grab_buffer[reqnr].state = MEYE_BUF_UNUSED; |
1619 | up(&meye.lock); | 1619 | mutex_unlock(&meye.lock); |
1620 | break; | 1620 | break; |
1621 | } | 1621 | } |
1622 | 1622 | ||
1623 | case VIDIOC_STREAMON: { | 1623 | case VIDIOC_STREAMON: { |
1624 | down(&meye.lock); | 1624 | mutex_lock(&meye.lock); |
1625 | switch (meye.mchip_mode) { | 1625 | switch (meye.mchip_mode) { |
1626 | case MCHIP_HIC_MODE_CONT_OUT: | 1626 | case MCHIP_HIC_MODE_CONT_OUT: |
1627 | mchip_continuous_start(); | 1627 | mchip_continuous_start(); |
@@ -1630,23 +1630,23 @@ static int meye_do_ioctl(struct inode *inode, struct file *file, | |||
1630 | mchip_cont_compression_start(); | 1630 | mchip_cont_compression_start(); |
1631 | break; | 1631 | break; |
1632 | default: | 1632 | default: |
1633 | up(&meye.lock); | 1633 | mutex_unlock(&meye.lock); |
1634 | return -EINVAL; | 1634 | return -EINVAL; |
1635 | } | 1635 | } |
1636 | up(&meye.lock); | 1636 | mutex_unlock(&meye.lock); |
1637 | break; | 1637 | break; |
1638 | } | 1638 | } |
1639 | 1639 | ||
1640 | case VIDIOC_STREAMOFF: { | 1640 | case VIDIOC_STREAMOFF: { |
1641 | int i; | 1641 | int i; |
1642 | 1642 | ||
1643 | down(&meye.lock); | 1643 | mutex_lock(&meye.lock); |
1644 | mchip_hic_stop(); | 1644 | mchip_hic_stop(); |
1645 | kfifo_reset(meye.grabq); | 1645 | kfifo_reset(meye.grabq); |
1646 | kfifo_reset(meye.doneq); | 1646 | kfifo_reset(meye.doneq); |
1647 | for (i = 0; i < MEYE_MAX_BUFNBRS; i++) | 1647 | for (i = 0; i < MEYE_MAX_BUFNBRS; i++) |
1648 | meye.grab_buffer[i].state = MEYE_BUF_UNUSED; | 1648 | meye.grab_buffer[i].state = MEYE_BUF_UNUSED; |
1649 | up(&meye.lock); | 1649 | mutex_unlock(&meye.lock); |
1650 | break; | 1650 | break; |
1651 | } | 1651 | } |
1652 | 1652 | ||
@@ -1672,11 +1672,11 @@ static unsigned int meye_poll(struct file *file, poll_table *wait) | |||
1672 | { | 1672 | { |
1673 | unsigned int res = 0; | 1673 | unsigned int res = 0; |
1674 | 1674 | ||
1675 | down(&meye.lock); | 1675 | mutex_lock(&meye.lock); |
1676 | poll_wait(file, &meye.proc_list, wait); | 1676 | poll_wait(file, &meye.proc_list, wait); |
1677 | if (kfifo_len(meye.doneq)) | 1677 | if (kfifo_len(meye.doneq)) |
1678 | res = POLLIN | POLLRDNORM; | 1678 | res = POLLIN | POLLRDNORM; |
1679 | up(&meye.lock); | 1679 | mutex_unlock(&meye.lock); |
1680 | return res; | 1680 | return res; |
1681 | } | 1681 | } |
1682 | 1682 | ||
@@ -1704,9 +1704,9 @@ static int meye_mmap(struct file *file, struct vm_area_struct *vma) | |||
1704 | unsigned long offset = vma->vm_pgoff << PAGE_SHIFT; | 1704 | unsigned long offset = vma->vm_pgoff << PAGE_SHIFT; |
1705 | unsigned long page, pos; | 1705 | unsigned long page, pos; |
1706 | 1706 | ||
1707 | down(&meye.lock); | 1707 | mutex_lock(&meye.lock); |
1708 | if (size > gbuffers * gbufsize) { | 1708 | if (size > gbuffers * gbufsize) { |
1709 | up(&meye.lock); | 1709 | mutex_unlock(&meye.lock); |
1710 | return -EINVAL; | 1710 | return -EINVAL; |
1711 | } | 1711 | } |
1712 | if (!meye.grab_fbuffer) { | 1712 | if (!meye.grab_fbuffer) { |
@@ -1716,7 +1716,7 @@ static int meye_mmap(struct file *file, struct vm_area_struct *vma) | |||
1716 | meye.grab_fbuffer = rvmalloc(gbuffers*gbufsize); | 1716 | meye.grab_fbuffer = rvmalloc(gbuffers*gbufsize); |
1717 | if (!meye.grab_fbuffer) { | 1717 | if (!meye.grab_fbuffer) { |
1718 | printk(KERN_ERR "meye: v4l framebuffer allocation failed\n"); | 1718 | printk(KERN_ERR "meye: v4l framebuffer allocation failed\n"); |
1719 | up(&meye.lock); | 1719 | mutex_unlock(&meye.lock); |
1720 | return -ENOMEM; | 1720 | return -ENOMEM; |
1721 | } | 1721 | } |
1722 | for (i = 0; i < gbuffers; i++) | 1722 | for (i = 0; i < gbuffers; i++) |
@@ -1727,7 +1727,7 @@ static int meye_mmap(struct file *file, struct vm_area_struct *vma) | |||
1727 | while (size > 0) { | 1727 | while (size > 0) { |
1728 | page = vmalloc_to_pfn((void *)pos); | 1728 | page = vmalloc_to_pfn((void *)pos); |
1729 | if (remap_pfn_range(vma, start, page, PAGE_SIZE, PAGE_SHARED)) { | 1729 | if (remap_pfn_range(vma, start, page, PAGE_SIZE, PAGE_SHARED)) { |
1730 | up(&meye.lock); | 1730 | mutex_unlock(&meye.lock); |
1731 | return -EAGAIN; | 1731 | return -EAGAIN; |
1732 | } | 1732 | } |
1733 | start += PAGE_SIZE; | 1733 | start += PAGE_SIZE; |
@@ -1744,7 +1744,7 @@ static int meye_mmap(struct file *file, struct vm_area_struct *vma) | |||
1744 | vma->vm_private_data = (void *) (offset / gbufsize); | 1744 | vma->vm_private_data = (void *) (offset / gbufsize); |
1745 | meye_vm_open(vma); | 1745 | meye_vm_open(vma); |
1746 | 1746 | ||
1747 | up(&meye.lock); | 1747 | mutex_unlock(&meye.lock); |
1748 | return 0; | 1748 | return 0; |
1749 | } | 1749 | } |
1750 | 1750 | ||
@@ -1913,7 +1913,7 @@ static int __devinit meye_probe(struct pci_dev *pcidev, | |||
1913 | goto outvideoreg; | 1913 | goto outvideoreg; |
1914 | } | 1914 | } |
1915 | 1915 | ||
1916 | init_MUTEX(&meye.lock); | 1916 | mutex_init(&meye.lock); |
1917 | init_waitqueue_head(&meye.proc_list); | 1917 | init_waitqueue_head(&meye.proc_list); |
1918 | meye.picture.depth = 16; | 1918 | meye.picture.depth = 16; |
1919 | meye.picture.palette = VIDEO_PALETTE_YUV422; | 1919 | meye.picture.palette = VIDEO_PALETTE_YUV422; |
diff --git a/drivers/media/video/meye.h b/drivers/media/video/meye.h index e8cd897b0d20..0d09a0e3803c 100644 --- a/drivers/media/video/meye.h +++ b/drivers/media/video/meye.h | |||
@@ -260,6 +260,8 @@ | |||
260 | 260 | ||
261 | /* private API definitions */ | 261 | /* private API definitions */ |
262 | #include <linux/meye.h> | 262 | #include <linux/meye.h> |
263 | #include <linux/mutex.h> | ||
264 | |||
263 | 265 | ||
264 | /* Enable jpg software correction */ | 266 | /* Enable jpg software correction */ |
265 | #define MEYE_JPEG_CORRECTION 1 | 267 | #define MEYE_JPEG_CORRECTION 1 |
@@ -301,7 +303,7 @@ struct meye { | |||
301 | /* list of buffers */ | 303 | /* list of buffers */ |
302 | struct meye_grab_buffer grab_buffer[MEYE_MAX_BUFNBRS]; | 304 | struct meye_grab_buffer grab_buffer[MEYE_MAX_BUFNBRS]; |
303 | int vma_use_count[MEYE_MAX_BUFNBRS]; /* mmap count */ | 305 | int vma_use_count[MEYE_MAX_BUFNBRS]; /* mmap count */ |
304 | struct semaphore lock; /* semaphore for open/mmap... */ | 306 | struct mutex lock; /* mutex for open/mmap... */ |
305 | struct kfifo *grabq; /* queue for buffers to be grabbed */ | 307 | struct kfifo *grabq; /* queue for buffers to be grabbed */ |
306 | spinlock_t grabq_lock; /* lock protecting the queue */ | 308 | spinlock_t grabq_lock; /* lock protecting the queue */ |
307 | struct kfifo *doneq; /* queue for grabbed buffers */ | 309 | struct kfifo *doneq; /* queue for grabbed buffers */ |
diff --git a/drivers/media/video/mxb.c b/drivers/media/video/mxb.c index 8416ceff524b..69a7eddf3a24 100644 --- a/drivers/media/video/mxb.c +++ b/drivers/media/video/mxb.c | |||
@@ -625,9 +625,9 @@ static int mxb_ioctl(struct saa7146_fh *fh, unsigned int cmd, void *arg) | |||
625 | } | 625 | } |
626 | 626 | ||
627 | /* fixme: locke das setzen des inputs mit hilfe des mutexes | 627 | /* fixme: locke das setzen des inputs mit hilfe des mutexes |
628 | down(&dev->lock); | 628 | mutex_lock(&dev->lock); |
629 | video_mux(dev,*i); | 629 | video_mux(dev,*i); |
630 | up(&dev->lock); | 630 | mutex_unlock(&dev->lock); |
631 | */ | 631 | */ |
632 | 632 | ||
633 | /* fixme: check if streaming capture | 633 | /* fixme: check if streaming capture |
diff --git a/drivers/media/video/planb.c b/drivers/media/video/planb.c index f3fc361bec97..15fd85acabda 100644 --- a/drivers/media/video/planb.c +++ b/drivers/media/video/planb.c | |||
@@ -48,7 +48,7 @@ | |||
48 | #include <asm/pgtable.h> | 48 | #include <asm/pgtable.h> |
49 | #include <asm/page.h> | 49 | #include <asm/page.h> |
50 | #include <asm/irq.h> | 50 | #include <asm/irq.h> |
51 | #include <asm/semaphore.h> | 51 | #include <linux/mutex.h> |
52 | 52 | ||
53 | #include "planb.h" | 53 | #include "planb.h" |
54 | #include "saa7196.h" | 54 | #include "saa7196.h" |
@@ -329,12 +329,12 @@ static volatile struct dbdma_cmd *cmd_geo_setup( | |||
329 | 329 | ||
330 | static inline void planb_lock(struct planb *pb) | 330 | static inline void planb_lock(struct planb *pb) |
331 | { | 331 | { |
332 | down(&pb->lock); | 332 | mutex_lock(&pb->lock); |
333 | } | 333 | } |
334 | 334 | ||
335 | static inline void planb_unlock(struct planb *pb) | 335 | static inline void planb_unlock(struct planb *pb) |
336 | { | 336 | { |
337 | up(&pb->lock); | 337 | mutex_unlock(&pb->lock); |
338 | } | 338 | } |
339 | 339 | ||
340 | /***************/ | 340 | /***************/ |
@@ -2067,7 +2067,7 @@ static int init_planb(struct planb *pb) | |||
2067 | #endif | 2067 | #endif |
2068 | pb->tab_size = PLANB_MAXLINES + 40; | 2068 | pb->tab_size = PLANB_MAXLINES + 40; |
2069 | pb->suspend = 0; | 2069 | pb->suspend = 0; |
2070 | init_MUTEX(&pb->lock); | 2070 | mutex_init(&pb->lock); |
2071 | pb->ch1_cmd = 0; | 2071 | pb->ch1_cmd = 0; |
2072 | pb->ch2_cmd = 0; | 2072 | pb->ch2_cmd = 0; |
2073 | pb->mask = 0; | 2073 | pb->mask = 0; |
diff --git a/drivers/media/video/planb.h b/drivers/media/video/planb.h index 8a0faad16118..79b6b561426e 100644 --- a/drivers/media/video/planb.h +++ b/drivers/media/video/planb.h | |||
@@ -174,7 +174,7 @@ struct planb { | |||
174 | int user; | 174 | int user; |
175 | unsigned int tab_size; | 175 | unsigned int tab_size; |
176 | int maxlines; | 176 | int maxlines; |
177 | struct semaphore lock; | 177 | struct mutex lock; |
178 | unsigned int irq; /* interrupt number */ | 178 | unsigned int irq; /* interrupt number */ |
179 | volatile unsigned int intr_mask; | 179 | volatile unsigned int intr_mask; |
180 | 180 | ||
diff --git a/drivers/media/video/pms.c b/drivers/media/video/pms.c index 9e6448639480..05ca55939e77 100644 --- a/drivers/media/video/pms.c +++ b/drivers/media/video/pms.c | |||
@@ -30,6 +30,8 @@ | |||
30 | #include <asm/io.h> | 30 | #include <asm/io.h> |
31 | #include <linux/sched.h> | 31 | #include <linux/sched.h> |
32 | #include <linux/videodev.h> | 32 | #include <linux/videodev.h> |
33 | #include <linux/mutex.h> | ||
34 | |||
33 | #include <asm/uaccess.h> | 35 | #include <asm/uaccess.h> |
34 | 36 | ||
35 | 37 | ||
@@ -44,7 +46,7 @@ struct pms_device | |||
44 | struct video_picture picture; | 46 | struct video_picture picture; |
45 | int height; | 47 | int height; |
46 | int width; | 48 | int width; |
47 | struct semaphore lock; | 49 | struct mutex lock; |
48 | }; | 50 | }; |
49 | 51 | ||
50 | struct i2c_info | 52 | struct i2c_info |
@@ -724,10 +726,10 @@ static int pms_do_ioctl(struct inode *inode, struct file *file, | |||
724 | struct video_channel *v = arg; | 726 | struct video_channel *v = arg; |
725 | if(v->channel<0 || v->channel>3) | 727 | if(v->channel<0 || v->channel>3) |
726 | return -EINVAL; | 728 | return -EINVAL; |
727 | down(&pd->lock); | 729 | mutex_lock(&pd->lock); |
728 | pms_videosource(v->channel&1); | 730 | pms_videosource(v->channel&1); |
729 | pms_vcrinput(v->channel>>1); | 731 | pms_vcrinput(v->channel>>1); |
730 | up(&pd->lock); | 732 | mutex_unlock(&pd->lock); |
731 | return 0; | 733 | return 0; |
732 | } | 734 | } |
733 | case VIDIOCGTUNER: | 735 | case VIDIOCGTUNER: |
@@ -761,7 +763,7 @@ static int pms_do_ioctl(struct inode *inode, struct file *file, | |||
761 | struct video_tuner *v = arg; | 763 | struct video_tuner *v = arg; |
762 | if(v->tuner) | 764 | if(v->tuner) |
763 | return -EINVAL; | 765 | return -EINVAL; |
764 | down(&pd->lock); | 766 | mutex_lock(&pd->lock); |
765 | switch(v->mode) | 767 | switch(v->mode) |
766 | { | 768 | { |
767 | case VIDEO_MODE_AUTO: | 769 | case VIDEO_MODE_AUTO: |
@@ -785,10 +787,10 @@ static int pms_do_ioctl(struct inode *inode, struct file *file, | |||
785 | pms_format(2); | 787 | pms_format(2); |
786 | break; | 788 | break; |
787 | default: | 789 | default: |
788 | up(&pd->lock); | 790 | mutex_unlock(&pd->lock); |
789 | return -EINVAL; | 791 | return -EINVAL; |
790 | } | 792 | } |
791 | up(&pd->lock); | 793 | mutex_unlock(&pd->lock); |
792 | return 0; | 794 | return 0; |
793 | } | 795 | } |
794 | case VIDIOCGPICT: | 796 | case VIDIOCGPICT: |
@@ -809,12 +811,12 @@ static int pms_do_ioctl(struct inode *inode, struct file *file, | |||
809 | * Now load the card. | 811 | * Now load the card. |
810 | */ | 812 | */ |
811 | 813 | ||
812 | down(&pd->lock); | 814 | mutex_lock(&pd->lock); |
813 | pms_brightness(p->brightness>>8); | 815 | pms_brightness(p->brightness>>8); |
814 | pms_hue(p->hue>>8); | 816 | pms_hue(p->hue>>8); |
815 | pms_colour(p->colour>>8); | 817 | pms_colour(p->colour>>8); |
816 | pms_contrast(p->contrast>>8); | 818 | pms_contrast(p->contrast>>8); |
817 | up(&pd->lock); | 819 | mutex_unlock(&pd->lock); |
818 | return 0; | 820 | return 0; |
819 | } | 821 | } |
820 | case VIDIOCSWIN: | 822 | case VIDIOCSWIN: |
@@ -830,9 +832,9 @@ static int pms_do_ioctl(struct inode *inode, struct file *file, | |||
830 | return -EINVAL; | 832 | return -EINVAL; |
831 | pd->width=vw->width; | 833 | pd->width=vw->width; |
832 | pd->height=vw->height; | 834 | pd->height=vw->height; |
833 | down(&pd->lock); | 835 | mutex_lock(&pd->lock); |
834 | pms_resolution(pd->width, pd->height); | 836 | pms_resolution(pd->width, pd->height); |
835 | up(&pd->lock); /* Ok we figured out what to use from our wide choice */ | 837 | mutex_unlock(&pd->lock); /* Ok we figured out what to use from our wide choice */ |
836 | return 0; | 838 | return 0; |
837 | } | 839 | } |
838 | case VIDIOCGWIN: | 840 | case VIDIOCGWIN: |
@@ -872,9 +874,9 @@ static ssize_t pms_read(struct file *file, char __user *buf, | |||
872 | struct pms_device *pd=(struct pms_device *)v; | 874 | struct pms_device *pd=(struct pms_device *)v; |
873 | int len; | 875 | int len; |
874 | 876 | ||
875 | down(&pd->lock); | 877 | mutex_lock(&pd->lock); |
876 | len=pms_capture(pd, buf, (pd->picture.depth==16)?0:1,count); | 878 | len=pms_capture(pd, buf, (pd->picture.depth==16)?0:1,count); |
877 | up(&pd->lock); | 879 | mutex_unlock(&pd->lock); |
878 | return len; | 880 | return len; |
879 | } | 881 | } |
880 | 882 | ||
@@ -1029,7 +1031,7 @@ static int __init init_pms_cards(void) | |||
1029 | return -ENODEV; | 1031 | return -ENODEV; |
1030 | } | 1032 | } |
1031 | memcpy(&pms_device, &pms_template, sizeof(pms_template)); | 1033 | memcpy(&pms_device, &pms_template, sizeof(pms_template)); |
1032 | init_MUTEX(&pms_device.lock); | 1034 | mutex_init(&pms_device.lock); |
1033 | pms_device.height=240; | 1035 | pms_device.height=240; |
1034 | pms_device.width=320; | 1036 | pms_device.width=320; |
1035 | pms_swsense(75); | 1037 | pms_swsense(75); |
diff --git a/drivers/media/video/saa5246a.c b/drivers/media/video/saa5246a.c index 2ce010201308..dd830e0e5e96 100644 --- a/drivers/media/video/saa5246a.c +++ b/drivers/media/video/saa5246a.c | |||
@@ -46,6 +46,8 @@ | |||
46 | #include <linux/i2c.h> | 46 | #include <linux/i2c.h> |
47 | #include <linux/videotext.h> | 47 | #include <linux/videotext.h> |
48 | #include <linux/videodev.h> | 48 | #include <linux/videodev.h> |
49 | #include <linux/mutex.h> | ||
50 | |||
49 | #include "saa5246a.h" | 51 | #include "saa5246a.h" |
50 | 52 | ||
51 | MODULE_AUTHOR("Michael Geng <linux@MichaelGeng.de>"); | 53 | MODULE_AUTHOR("Michael Geng <linux@MichaelGeng.de>"); |
@@ -57,7 +59,7 @@ struct saa5246a_device | |||
57 | u8 pgbuf[NUM_DAUS][VTX_VIRTUALSIZE]; | 59 | u8 pgbuf[NUM_DAUS][VTX_VIRTUALSIZE]; |
58 | int is_searching[NUM_DAUS]; | 60 | int is_searching[NUM_DAUS]; |
59 | struct i2c_client *client; | 61 | struct i2c_client *client; |
60 | struct semaphore lock; | 62 | struct mutex lock; |
61 | }; | 63 | }; |
62 | 64 | ||
63 | static struct video_device saa_template; /* Declared near bottom */ | 65 | static struct video_device saa_template; /* Declared near bottom */ |
@@ -90,7 +92,7 @@ static int saa5246a_attach(struct i2c_adapter *adap, int addr, int kind) | |||
90 | return -ENOMEM; | 92 | return -ENOMEM; |
91 | } | 93 | } |
92 | strlcpy(client->name, IF_NAME, I2C_NAME_SIZE); | 94 | strlcpy(client->name, IF_NAME, I2C_NAME_SIZE); |
93 | init_MUTEX(&t->lock); | 95 | mutex_init(&t->lock); |
94 | 96 | ||
95 | /* | 97 | /* |
96 | * Now create a video4linux device | 98 | * Now create a video4linux device |
@@ -719,9 +721,9 @@ static int saa5246a_ioctl(struct inode *inode, struct file *file, | |||
719 | int err; | 721 | int err; |
720 | 722 | ||
721 | cmd = vtx_fix_command(cmd); | 723 | cmd = vtx_fix_command(cmd); |
722 | down(&t->lock); | 724 | mutex_lock(&t->lock); |
723 | err = video_usercopy(inode, file, cmd, arg, do_saa5246a_ioctl); | 725 | err = video_usercopy(inode, file, cmd, arg, do_saa5246a_ioctl); |
724 | up(&t->lock); | 726 | mutex_unlock(&t->lock); |
725 | return err; | 727 | return err; |
726 | } | 728 | } |
727 | 729 | ||
diff --git a/drivers/media/video/saa5249.c b/drivers/media/video/saa5249.c index 5694eb58c3a1..a9f3cf0b1e3c 100644 --- a/drivers/media/video/saa5249.c +++ b/drivers/media/video/saa5249.c | |||
@@ -56,6 +56,8 @@ | |||
56 | #include <linux/i2c.h> | 56 | #include <linux/i2c.h> |
57 | #include <linux/videotext.h> | 57 | #include <linux/videotext.h> |
58 | #include <linux/videodev.h> | 58 | #include <linux/videodev.h> |
59 | #include <linux/mutex.h> | ||
60 | |||
59 | 61 | ||
60 | #include <asm/io.h> | 62 | #include <asm/io.h> |
61 | #include <asm/uaccess.h> | 63 | #include <asm/uaccess.h> |
@@ -105,7 +107,7 @@ struct saa5249_device | |||
105 | int disp_mode; | 107 | int disp_mode; |
106 | int virtual_mode; | 108 | int virtual_mode; |
107 | struct i2c_client *client; | 109 | struct i2c_client *client; |
108 | struct semaphore lock; | 110 | struct mutex lock; |
109 | }; | 111 | }; |
110 | 112 | ||
111 | 113 | ||
@@ -158,7 +160,7 @@ static int saa5249_attach(struct i2c_adapter *adap, int addr, int kind) | |||
158 | return -ENOMEM; | 160 | return -ENOMEM; |
159 | } | 161 | } |
160 | strlcpy(client->name, IF_NAME, I2C_NAME_SIZE); | 162 | strlcpy(client->name, IF_NAME, I2C_NAME_SIZE); |
161 | init_MUTEX(&t->lock); | 163 | mutex_init(&t->lock); |
162 | 164 | ||
163 | /* | 165 | /* |
164 | * Now create a video4linux device | 166 | * Now create a video4linux device |
@@ -619,9 +621,9 @@ static int saa5249_ioctl(struct inode *inode, struct file *file, | |||
619 | int err; | 621 | int err; |
620 | 622 | ||
621 | cmd = vtx_fix_command(cmd); | 623 | cmd = vtx_fix_command(cmd); |
622 | down(&t->lock); | 624 | mutex_lock(&t->lock); |
623 | err = video_usercopy(inode,file,cmd,arg,do_saa5249_ioctl); | 625 | err = video_usercopy(inode,file,cmd,arg,do_saa5249_ioctl); |
624 | up(&t->lock); | 626 | mutex_unlock(&t->lock); |
625 | return err; | 627 | return err; |
626 | } | 628 | } |
627 | 629 | ||
diff --git a/drivers/media/video/saa7134/saa7134-alsa.c b/drivers/media/video/saa7134/saa7134-alsa.c index a7a6ab9298a9..d3c7345a5d22 100644 --- a/drivers/media/video/saa7134/saa7134-alsa.c +++ b/drivers/media/video/saa7134/saa7134-alsa.c | |||
@@ -609,12 +609,12 @@ static int snd_card_saa7134_capture_open(snd_pcm_substream_t * substream) | |||
609 | struct saa7134_dev *dev = saa7134->dev; | 609 | struct saa7134_dev *dev = saa7134->dev; |
610 | int err; | 610 | int err; |
611 | 611 | ||
612 | down(&dev->dmasound.lock); | 612 | mutex_lock(&dev->dmasound.lock); |
613 | 613 | ||
614 | dev->dmasound.read_count = 0; | 614 | dev->dmasound.read_count = 0; |
615 | dev->dmasound.read_offset = 0; | 615 | dev->dmasound.read_offset = 0; |
616 | 616 | ||
617 | up(&dev->dmasound.lock); | 617 | mutex_unlock(&dev->dmasound.lock); |
618 | 618 | ||
619 | pcm = kzalloc(sizeof(*pcm), GFP_KERNEL); | 619 | pcm = kzalloc(sizeof(*pcm), GFP_KERNEL); |
620 | if (pcm == NULL) | 620 | if (pcm == NULL) |
@@ -932,7 +932,7 @@ static int alsa_card_saa7134_create(struct saa7134_dev *dev, int devnum) | |||
932 | 932 | ||
933 | chip->irq = dev->pci->irq; | 933 | chip->irq = dev->pci->irq; |
934 | 934 | ||
935 | init_MUTEX(&dev->dmasound.lock); | 935 | mutex_init(&dev->dmasound.lock); |
936 | 936 | ||
937 | if ((err = snd_card_saa7134_new_mixer(chip)) < 0) | 937 | if ((err = snd_card_saa7134_new_mixer(chip)) < 0) |
938 | goto __nodev; | 938 | goto __nodev; |
diff --git a/drivers/media/video/saa7134/saa7134-core.c b/drivers/media/video/saa7134/saa7134-core.c index 028904bd94a2..e7c30665739e 100644 --- a/drivers/media/video/saa7134/saa7134-core.c +++ b/drivers/media/video/saa7134/saa7134-core.c | |||
@@ -613,7 +613,7 @@ static int saa7134_hwinit1(struct saa7134_dev *dev) | |||
613 | 613 | ||
614 | saa_writel(SAA7134_IRQ1, 0); | 614 | saa_writel(SAA7134_IRQ1, 0); |
615 | saa_writel(SAA7134_IRQ2, 0); | 615 | saa_writel(SAA7134_IRQ2, 0); |
616 | init_MUTEX(&dev->lock); | 616 | mutex_init(&dev->lock); |
617 | spin_lock_init(&dev->slock); | 617 | spin_lock_init(&dev->slock); |
618 | 618 | ||
619 | saa7134_track_gpio(dev,"pre-init"); | 619 | saa7134_track_gpio(dev,"pre-init"); |
diff --git a/drivers/media/video/saa7134/saa7134-empress.c b/drivers/media/video/saa7134/saa7134-empress.c index bd4c389d4c37..1d972edb3be6 100644 --- a/drivers/media/video/saa7134/saa7134-empress.c +++ b/drivers/media/video/saa7134/saa7134-empress.c | |||
@@ -89,7 +89,7 @@ static int ts_open(struct inode *inode, struct file *file) | |||
89 | 89 | ||
90 | dprintk("open minor=%d\n",minor); | 90 | dprintk("open minor=%d\n",minor); |
91 | err = -EBUSY; | 91 | err = -EBUSY; |
92 | if (down_trylock(&dev->empress_tsq.lock)) | 92 | if (!mutex_trylock(&dev->empress_tsq.lock)) |
93 | goto done; | 93 | goto done; |
94 | if (dev->empress_users) | 94 | if (dev->empress_users) |
95 | goto done_up; | 95 | goto done_up; |
@@ -99,7 +99,7 @@ static int ts_open(struct inode *inode, struct file *file) | |||
99 | err = 0; | 99 | err = 0; |
100 | 100 | ||
101 | done_up: | 101 | done_up: |
102 | up(&dev->empress_tsq.lock); | 102 | mutex_unlock(&dev->empress_tsq.lock); |
103 | done: | 103 | done: |
104 | return err; | 104 | return err; |
105 | } | 105 | } |
@@ -110,7 +110,7 @@ static int ts_release(struct inode *inode, struct file *file) | |||
110 | 110 | ||
111 | if (dev->empress_tsq.streaming) | 111 | if (dev->empress_tsq.streaming) |
112 | videobuf_streamoff(&dev->empress_tsq); | 112 | videobuf_streamoff(&dev->empress_tsq); |
113 | down(&dev->empress_tsq.lock); | 113 | mutex_lock(&dev->empress_tsq.lock); |
114 | if (dev->empress_tsq.reading) | 114 | if (dev->empress_tsq.reading) |
115 | videobuf_read_stop(&dev->empress_tsq); | 115 | videobuf_read_stop(&dev->empress_tsq); |
116 | videobuf_mmap_free(&dev->empress_tsq); | 116 | videobuf_mmap_free(&dev->empress_tsq); |
@@ -119,7 +119,7 @@ static int ts_release(struct inode *inode, struct file *file) | |||
119 | /* stop the encoder */ | 119 | /* stop the encoder */ |
120 | ts_reset_encoder(dev); | 120 | ts_reset_encoder(dev); |
121 | 121 | ||
122 | up(&dev->empress_tsq.lock); | 122 | mutex_unlock(&dev->empress_tsq.lock); |
123 | return 0; | 123 | return 0; |
124 | } | 124 | } |
125 | 125 | ||
diff --git a/drivers/media/video/saa7134/saa7134-oss.c b/drivers/media/video/saa7134/saa7134-oss.c index 7448e386a804..80e34a5fdcc5 100644 --- a/drivers/media/video/saa7134/saa7134-oss.c +++ b/drivers/media/video/saa7134/saa7134-oss.c | |||
@@ -254,7 +254,7 @@ static int dsp_open(struct inode *inode, struct file *file) | |||
254 | if (NULL == dev) | 254 | if (NULL == dev) |
255 | return -ENODEV; | 255 | return -ENODEV; |
256 | 256 | ||
257 | down(&dev->dmasound.lock); | 257 | mutex_lock(&dev->dmasound.lock); |
258 | err = -EBUSY; | 258 | err = -EBUSY; |
259 | if (dev->dmasound.users_dsp) | 259 | if (dev->dmasound.users_dsp) |
260 | goto fail1; | 260 | goto fail1; |
@@ -270,13 +270,13 @@ static int dsp_open(struct inode *inode, struct file *file) | |||
270 | if (0 != err) | 270 | if (0 != err) |
271 | goto fail2; | 271 | goto fail2; |
272 | 272 | ||
273 | up(&dev->dmasound.lock); | 273 | mutex_unlock(&dev->dmasound.lock); |
274 | return 0; | 274 | return 0; |
275 | 275 | ||
276 | fail2: | 276 | fail2: |
277 | dev->dmasound.users_dsp--; | 277 | dev->dmasound.users_dsp--; |
278 | fail1: | 278 | fail1: |
279 | up(&dev->dmasound.lock); | 279 | mutex_unlock(&dev->dmasound.lock); |
280 | return err; | 280 | return err; |
281 | } | 281 | } |
282 | 282 | ||
@@ -284,13 +284,13 @@ static int dsp_release(struct inode *inode, struct file *file) | |||
284 | { | 284 | { |
285 | struct saa7134_dev *dev = file->private_data; | 285 | struct saa7134_dev *dev = file->private_data; |
286 | 286 | ||
287 | down(&dev->dmasound.lock); | 287 | mutex_lock(&dev->dmasound.lock); |
288 | if (dev->dmasound.recording_on) | 288 | if (dev->dmasound.recording_on) |
289 | dsp_rec_stop(dev); | 289 | dsp_rec_stop(dev); |
290 | dsp_buffer_free(dev); | 290 | dsp_buffer_free(dev); |
291 | dev->dmasound.users_dsp--; | 291 | dev->dmasound.users_dsp--; |
292 | file->private_data = NULL; | 292 | file->private_data = NULL; |
293 | up(&dev->dmasound.lock); | 293 | mutex_unlock(&dev->dmasound.lock); |
294 | return 0; | 294 | return 0; |
295 | } | 295 | } |
296 | 296 | ||
@@ -304,7 +304,7 @@ static ssize_t dsp_read(struct file *file, char __user *buffer, | |||
304 | int err,ret = 0; | 304 | int err,ret = 0; |
305 | 305 | ||
306 | add_wait_queue(&dev->dmasound.wq, &wait); | 306 | add_wait_queue(&dev->dmasound.wq, &wait); |
307 | down(&dev->dmasound.lock); | 307 | mutex_lock(&dev->dmasound.lock); |
308 | while (count > 0) { | 308 | while (count > 0) { |
309 | /* wait for data if needed */ | 309 | /* wait for data if needed */ |
310 | if (0 == dev->dmasound.read_count) { | 310 | if (0 == dev->dmasound.read_count) { |
@@ -328,12 +328,12 @@ static ssize_t dsp_read(struct file *file, char __user *buffer, | |||
328 | ret = -EAGAIN; | 328 | ret = -EAGAIN; |
329 | break; | 329 | break; |
330 | } | 330 | } |
331 | up(&dev->dmasound.lock); | 331 | mutex_unlock(&dev->dmasound.lock); |
332 | set_current_state(TASK_INTERRUPTIBLE); | 332 | set_current_state(TASK_INTERRUPTIBLE); |
333 | if (0 == dev->dmasound.read_count) | 333 | if (0 == dev->dmasound.read_count) |
334 | schedule(); | 334 | schedule(); |
335 | set_current_state(TASK_RUNNING); | 335 | set_current_state(TASK_RUNNING); |
336 | down(&dev->dmasound.lock); | 336 | mutex_lock(&dev->dmasound.lock); |
337 | if (signal_pending(current)) { | 337 | if (signal_pending(current)) { |
338 | if (0 == ret) | 338 | if (0 == ret) |
339 | ret = -EINTR; | 339 | ret = -EINTR; |
@@ -362,7 +362,7 @@ static ssize_t dsp_read(struct file *file, char __user *buffer, | |||
362 | if (dev->dmasound.read_offset == dev->dmasound.bufsize) | 362 | if (dev->dmasound.read_offset == dev->dmasound.bufsize) |
363 | dev->dmasound.read_offset = 0; | 363 | dev->dmasound.read_offset = 0; |
364 | } | 364 | } |
365 | up(&dev->dmasound.lock); | 365 | mutex_unlock(&dev->dmasound.lock); |
366 | remove_wait_queue(&dev->dmasound.wq, &wait); | 366 | remove_wait_queue(&dev->dmasound.wq, &wait); |
367 | return ret; | 367 | return ret; |
368 | } | 368 | } |
@@ -435,13 +435,13 @@ static int dsp_ioctl(struct inode *inode, struct file *file, | |||
435 | case SNDCTL_DSP_STEREO: | 435 | case SNDCTL_DSP_STEREO: |
436 | if (get_user(val, p)) | 436 | if (get_user(val, p)) |
437 | return -EFAULT; | 437 | return -EFAULT; |
438 | down(&dev->dmasound.lock); | 438 | mutex_lock(&dev->dmasound.lock); |
439 | dev->dmasound.channels = val ? 2 : 1; | 439 | dev->dmasound.channels = val ? 2 : 1; |
440 | if (dev->dmasound.recording_on) { | 440 | if (dev->dmasound.recording_on) { |
441 | dsp_rec_stop(dev); | 441 | dsp_rec_stop(dev); |
442 | dsp_rec_start(dev); | 442 | dsp_rec_start(dev); |
443 | } | 443 | } |
444 | up(&dev->dmasound.lock); | 444 | mutex_unlock(&dev->dmasound.lock); |
445 | return put_user(dev->dmasound.channels-1, p); | 445 | return put_user(dev->dmasound.channels-1, p); |
446 | 446 | ||
447 | case SNDCTL_DSP_CHANNELS: | 447 | case SNDCTL_DSP_CHANNELS: |
@@ -449,13 +449,13 @@ static int dsp_ioctl(struct inode *inode, struct file *file, | |||
449 | return -EFAULT; | 449 | return -EFAULT; |
450 | if (val != 1 && val != 2) | 450 | if (val != 1 && val != 2) |
451 | return -EINVAL; | 451 | return -EINVAL; |
452 | down(&dev->dmasound.lock); | 452 | mutex_lock(&dev->dmasound.lock); |
453 | dev->dmasound.channels = val; | 453 | dev->dmasound.channels = val; |
454 | if (dev->dmasound.recording_on) { | 454 | if (dev->dmasound.recording_on) { |
455 | dsp_rec_stop(dev); | 455 | dsp_rec_stop(dev); |
456 | dsp_rec_start(dev); | 456 | dsp_rec_start(dev); |
457 | } | 457 | } |
458 | up(&dev->dmasound.lock); | 458 | mutex_unlock(&dev->dmasound.lock); |
459 | /* fall through */ | 459 | /* fall through */ |
460 | case SOUND_PCM_READ_CHANNELS: | 460 | case SOUND_PCM_READ_CHANNELS: |
461 | return put_user(dev->dmasound.channels, p); | 461 | return put_user(dev->dmasound.channels, p); |
@@ -478,13 +478,13 @@ static int dsp_ioctl(struct inode *inode, struct file *file, | |||
478 | case AFMT_U16_BE: | 478 | case AFMT_U16_BE: |
479 | case AFMT_S16_LE: | 479 | case AFMT_S16_LE: |
480 | case AFMT_S16_BE: | 480 | case AFMT_S16_BE: |
481 | down(&dev->dmasound.lock); | 481 | mutex_lock(&dev->dmasound.lock); |
482 | dev->dmasound.afmt = val; | 482 | dev->dmasound.afmt = val; |
483 | if (dev->dmasound.recording_on) { | 483 | if (dev->dmasound.recording_on) { |
484 | dsp_rec_stop(dev); | 484 | dsp_rec_stop(dev); |
485 | dsp_rec_start(dev); | 485 | dsp_rec_start(dev); |
486 | } | 486 | } |
487 | up(&dev->dmasound.lock); | 487 | mutex_unlock(&dev->dmasound.lock); |
488 | return put_user(dev->dmasound.afmt, p); | 488 | return put_user(dev->dmasound.afmt, p); |
489 | default: | 489 | default: |
490 | return -EINVAL; | 490 | return -EINVAL; |
@@ -509,10 +509,10 @@ static int dsp_ioctl(struct inode *inode, struct file *file, | |||
509 | return 0; | 509 | return 0; |
510 | 510 | ||
511 | case SNDCTL_DSP_RESET: | 511 | case SNDCTL_DSP_RESET: |
512 | down(&dev->dmasound.lock); | 512 | mutex_lock(&dev->dmasound.lock); |
513 | if (dev->dmasound.recording_on) | 513 | if (dev->dmasound.recording_on) |
514 | dsp_rec_stop(dev); | 514 | dsp_rec_stop(dev); |
515 | up(&dev->dmasound.lock); | 515 | mutex_unlock(&dev->dmasound.lock); |
516 | return 0; | 516 | return 0; |
517 | case SNDCTL_DSP_GETBLKSIZE: | 517 | case SNDCTL_DSP_GETBLKSIZE: |
518 | return put_user(dev->dmasound.blksize, p); | 518 | return put_user(dev->dmasound.blksize, p); |
@@ -556,10 +556,10 @@ static unsigned int dsp_poll(struct file *file, struct poll_table_struct *wait) | |||
556 | poll_wait(file, &dev->dmasound.wq, wait); | 556 | poll_wait(file, &dev->dmasound.wq, wait); |
557 | 557 | ||
558 | if (0 == dev->dmasound.read_count) { | 558 | if (0 == dev->dmasound.read_count) { |
559 | down(&dev->dmasound.lock); | 559 | mutex_lock(&dev->dmasound.lock); |
560 | if (!dev->dmasound.recording_on) | 560 | if (!dev->dmasound.recording_on) |
561 | dsp_rec_start(dev); | 561 | dsp_rec_start(dev); |
562 | up(&dev->dmasound.lock); | 562 | mutex_unlock(&dev->dmasound.lock); |
563 | } else | 563 | } else |
564 | mask |= (POLLIN | POLLRDNORM); | 564 | mask |= (POLLIN | POLLRDNORM); |
565 | return mask; | 565 | return mask; |
@@ -852,7 +852,7 @@ int saa7134_oss_init1(struct saa7134_dev *dev) | |||
852 | return -1; | 852 | return -1; |
853 | 853 | ||
854 | /* general */ | 854 | /* general */ |
855 | init_MUTEX(&dev->dmasound.lock); | 855 | mutex_init(&dev->dmasound.lock); |
856 | init_waitqueue_head(&dev->dmasound.wq); | 856 | init_waitqueue_head(&dev->dmasound.wq); |
857 | 857 | ||
858 | switch (dev->pci->device) { | 858 | switch (dev->pci->device) { |
diff --git a/drivers/media/video/saa7134/saa7134-video.c b/drivers/media/video/saa7134/saa7134-video.c index e97426bc85df..72f389a51a13 100644 --- a/drivers/media/video/saa7134/saa7134-video.c +++ b/drivers/media/video/saa7134/saa7134-video.c | |||
@@ -460,17 +460,17 @@ static int res_get(struct saa7134_dev *dev, struct saa7134_fh *fh, unsigned int | |||
460 | return 1; | 460 | return 1; |
461 | 461 | ||
462 | /* is it free? */ | 462 | /* is it free? */ |
463 | down(&dev->lock); | 463 | mutex_lock(&dev->lock); |
464 | if (dev->resources & bit) { | 464 | if (dev->resources & bit) { |
465 | /* no, someone else uses it */ | 465 | /* no, someone else uses it */ |
466 | up(&dev->lock); | 466 | mutex_unlock(&dev->lock); |
467 | return 0; | 467 | return 0; |
468 | } | 468 | } |
469 | /* it's free, grab it */ | 469 | /* it's free, grab it */ |
470 | fh->resources |= bit; | 470 | fh->resources |= bit; |
471 | dev->resources |= bit; | 471 | dev->resources |= bit; |
472 | dprintk("res: get %d\n",bit); | 472 | dprintk("res: get %d\n",bit); |
473 | up(&dev->lock); | 473 | mutex_unlock(&dev->lock); |
474 | return 1; | 474 | return 1; |
475 | } | 475 | } |
476 | 476 | ||
@@ -492,11 +492,11 @@ void res_free(struct saa7134_dev *dev, struct saa7134_fh *fh, unsigned int bits) | |||
492 | if ((fh->resources & bits) != bits) | 492 | if ((fh->resources & bits) != bits) |
493 | BUG(); | 493 | BUG(); |
494 | 494 | ||
495 | down(&dev->lock); | 495 | mutex_lock(&dev->lock); |
496 | fh->resources &= ~bits; | 496 | fh->resources &= ~bits; |
497 | dev->resources &= ~bits; | 497 | dev->resources &= ~bits; |
498 | dprintk("res: put %d\n",bits); | 498 | dprintk("res: put %d\n",bits); |
499 | up(&dev->lock); | 499 | mutex_unlock(&dev->lock); |
500 | } | 500 | } |
501 | 501 | ||
502 | /* ------------------------------------------------------------------ */ | 502 | /* ------------------------------------------------------------------ */ |
@@ -1340,21 +1340,21 @@ video_poll(struct file *file, struct poll_table_struct *wait) | |||
1340 | if (!list_empty(&fh->cap.stream)) | 1340 | if (!list_empty(&fh->cap.stream)) |
1341 | buf = list_entry(fh->cap.stream.next, struct videobuf_buffer, stream); | 1341 | buf = list_entry(fh->cap.stream.next, struct videobuf_buffer, stream); |
1342 | } else { | 1342 | } else { |
1343 | down(&fh->cap.lock); | 1343 | mutex_lock(&fh->cap.lock); |
1344 | if (UNSET == fh->cap.read_off) { | 1344 | if (UNSET == fh->cap.read_off) { |
1345 | /* need to capture a new frame */ | 1345 | /* need to capture a new frame */ |
1346 | if (res_locked(fh->dev,RESOURCE_VIDEO)) { | 1346 | if (res_locked(fh->dev,RESOURCE_VIDEO)) { |
1347 | up(&fh->cap.lock); | 1347 | mutex_unlock(&fh->cap.lock); |
1348 | return POLLERR; | 1348 | return POLLERR; |
1349 | } | 1349 | } |
1350 | if (0 != fh->cap.ops->buf_prepare(&fh->cap,fh->cap.read_buf,fh->cap.field)) { | 1350 | if (0 != fh->cap.ops->buf_prepare(&fh->cap,fh->cap.read_buf,fh->cap.field)) { |
1351 | up(&fh->cap.lock); | 1351 | mutex_unlock(&fh->cap.lock); |
1352 | return POLLERR; | 1352 | return POLLERR; |
1353 | } | 1353 | } |
1354 | fh->cap.ops->buf_queue(&fh->cap,fh->cap.read_buf); | 1354 | fh->cap.ops->buf_queue(&fh->cap,fh->cap.read_buf); |
1355 | fh->cap.read_off = 0; | 1355 | fh->cap.read_off = 0; |
1356 | } | 1356 | } |
1357 | up(&fh->cap.lock); | 1357 | mutex_unlock(&fh->cap.lock); |
1358 | buf = fh->cap.read_buf; | 1358 | buf = fh->cap.read_buf; |
1359 | } | 1359 | } |
1360 | 1360 | ||
@@ -1561,14 +1561,14 @@ static int saa7134_s_fmt(struct saa7134_dev *dev, struct saa7134_fh *fh, | |||
1561 | if (0 != err) | 1561 | if (0 != err) |
1562 | return err; | 1562 | return err; |
1563 | 1563 | ||
1564 | down(&dev->lock); | 1564 | mutex_lock(&dev->lock); |
1565 | fh->win = f->fmt.win; | 1565 | fh->win = f->fmt.win; |
1566 | fh->nclips = f->fmt.win.clipcount; | 1566 | fh->nclips = f->fmt.win.clipcount; |
1567 | if (fh->nclips > 8) | 1567 | if (fh->nclips > 8) |
1568 | fh->nclips = 8; | 1568 | fh->nclips = 8; |
1569 | if (copy_from_user(fh->clips,f->fmt.win.clips, | 1569 | if (copy_from_user(fh->clips,f->fmt.win.clips, |
1570 | sizeof(struct v4l2_clip)*fh->nclips)) { | 1570 | sizeof(struct v4l2_clip)*fh->nclips)) { |
1571 | up(&dev->lock); | 1571 | mutex_unlock(&dev->lock); |
1572 | return -EFAULT; | 1572 | return -EFAULT; |
1573 | } | 1573 | } |
1574 | 1574 | ||
@@ -1578,7 +1578,7 @@ static int saa7134_s_fmt(struct saa7134_dev *dev, struct saa7134_fh *fh, | |||
1578 | start_preview(dev,fh); | 1578 | start_preview(dev,fh); |
1579 | spin_unlock_irqrestore(&dev->slock,flags); | 1579 | spin_unlock_irqrestore(&dev->slock,flags); |
1580 | } | 1580 | } |
1581 | up(&dev->lock); | 1581 | mutex_unlock(&dev->lock); |
1582 | return 0; | 1582 | return 0; |
1583 | case V4L2_BUF_TYPE_VBI_CAPTURE: | 1583 | case V4L2_BUF_TYPE_VBI_CAPTURE: |
1584 | saa7134_vbi_fmt(dev,f); | 1584 | saa7134_vbi_fmt(dev,f); |
@@ -1612,9 +1612,9 @@ int saa7134_common_ioctl(struct saa7134_dev *dev, | |||
1612 | return get_control(dev,arg); | 1612 | return get_control(dev,arg); |
1613 | case VIDIOC_S_CTRL: | 1613 | case VIDIOC_S_CTRL: |
1614 | { | 1614 | { |
1615 | down(&dev->lock); | 1615 | mutex_lock(&dev->lock); |
1616 | err = set_control(dev,NULL,arg); | 1616 | err = set_control(dev,NULL,arg); |
1617 | up(&dev->lock); | 1617 | mutex_unlock(&dev->lock); |
1618 | return err; | 1618 | return err; |
1619 | } | 1619 | } |
1620 | /* --- input switching --------------------------------------- */ | 1620 | /* --- input switching --------------------------------------- */ |
@@ -1664,9 +1664,9 @@ int saa7134_common_ioctl(struct saa7134_dev *dev, | |||
1664 | return -EINVAL; | 1664 | return -EINVAL; |
1665 | if (NULL == card_in(dev,*i).name) | 1665 | if (NULL == card_in(dev,*i).name) |
1666 | return -EINVAL; | 1666 | return -EINVAL; |
1667 | down(&dev->lock); | 1667 | mutex_lock(&dev->lock); |
1668 | video_mux(dev,*i); | 1668 | video_mux(dev,*i); |
1669 | up(&dev->lock); | 1669 | mutex_unlock(&dev->lock); |
1670 | return 0; | 1670 | return 0; |
1671 | } | 1671 | } |
1672 | 1672 | ||
@@ -1766,7 +1766,7 @@ static int video_do_ioctl(struct inode *inode, struct file *file, | |||
1766 | if (i == TVNORMS) | 1766 | if (i == TVNORMS) |
1767 | return -EINVAL; | 1767 | return -EINVAL; |
1768 | 1768 | ||
1769 | down(&dev->lock); | 1769 | mutex_lock(&dev->lock); |
1770 | if (res_check(fh, RESOURCE_OVERLAY)) { | 1770 | if (res_check(fh, RESOURCE_OVERLAY)) { |
1771 | spin_lock_irqsave(&dev->slock,flags); | 1771 | spin_lock_irqsave(&dev->slock,flags); |
1772 | stop_preview(dev,fh); | 1772 | stop_preview(dev,fh); |
@@ -1776,7 +1776,7 @@ static int video_do_ioctl(struct inode *inode, struct file *file, | |||
1776 | } else | 1776 | } else |
1777 | set_tvnorm(dev,&tvnorms[i]); | 1777 | set_tvnorm(dev,&tvnorms[i]); |
1778 | saa7134_tvaudio_do_scan(dev); | 1778 | saa7134_tvaudio_do_scan(dev); |
1779 | up(&dev->lock); | 1779 | mutex_unlock(&dev->lock); |
1780 | return 0; | 1780 | return 0; |
1781 | } | 1781 | } |
1782 | 1782 | ||
@@ -1909,13 +1909,13 @@ static int video_do_ioctl(struct inode *inode, struct file *file, | |||
1909 | return -EINVAL; | 1909 | return -EINVAL; |
1910 | if (1 == fh->radio && V4L2_TUNER_RADIO != f->type) | 1910 | if (1 == fh->radio && V4L2_TUNER_RADIO != f->type) |
1911 | return -EINVAL; | 1911 | return -EINVAL; |
1912 | down(&dev->lock); | 1912 | mutex_lock(&dev->lock); |
1913 | dev->ctl_freq = f->frequency; | 1913 | dev->ctl_freq = f->frequency; |
1914 | 1914 | ||
1915 | saa7134_i2c_call_clients(dev,VIDIOC_S_FREQUENCY,f); | 1915 | saa7134_i2c_call_clients(dev,VIDIOC_S_FREQUENCY,f); |
1916 | 1916 | ||
1917 | saa7134_tvaudio_do_scan(dev); | 1917 | saa7134_tvaudio_do_scan(dev); |
1918 | up(&dev->lock); | 1918 | mutex_unlock(&dev->lock); |
1919 | return 0; | 1919 | return 0; |
1920 | } | 1920 | } |
1921 | 1921 | ||
diff --git a/drivers/media/video/saa7134/saa7134.h b/drivers/media/video/saa7134/saa7134.h index ff39a63c7372..691c10be459d 100644 --- a/drivers/media/video/saa7134/saa7134.h +++ b/drivers/media/video/saa7134/saa7134.h | |||
@@ -29,6 +29,7 @@ | |||
29 | #include <linux/input.h> | 29 | #include <linux/input.h> |
30 | #include <linux/notifier.h> | 30 | #include <linux/notifier.h> |
31 | #include <linux/delay.h> | 31 | #include <linux/delay.h> |
32 | #include <linux/mutex.h> | ||
32 | 33 | ||
33 | #include <asm/io.h> | 34 | #include <asm/io.h> |
34 | 35 | ||
@@ -364,7 +365,7 @@ struct saa7134_fh { | |||
364 | 365 | ||
365 | /* dmasound dsp status */ | 366 | /* dmasound dsp status */ |
366 | struct saa7134_dmasound { | 367 | struct saa7134_dmasound { |
367 | struct semaphore lock; | 368 | struct mutex lock; |
368 | int minor_mixer; | 369 | int minor_mixer; |
369 | int minor_dsp; | 370 | int minor_dsp; |
370 | unsigned int users_dsp; | 371 | unsigned int users_dsp; |
@@ -428,7 +429,7 @@ struct saa7134_mpeg_ops { | |||
428 | /* global device status */ | 429 | /* global device status */ |
429 | struct saa7134_dev { | 430 | struct saa7134_dev { |
430 | struct list_head devlist; | 431 | struct list_head devlist; |
431 | struct semaphore lock; | 432 | struct mutex lock; |
432 | spinlock_t slock; | 433 | spinlock_t slock; |
433 | #ifdef VIDIOC_G_PRIORITY | 434 | #ifdef VIDIOC_G_PRIORITY |
434 | struct v4l2_prio_state prio; | 435 | struct v4l2_prio_state prio; |
diff --git a/drivers/media/video/video-buf-dvb.c b/drivers/media/video/video-buf-dvb.c index 0a4004a4393c..caf3e7e2f219 100644 --- a/drivers/media/video/video-buf-dvb.c +++ b/drivers/media/video/video-buf-dvb.c | |||
@@ -96,7 +96,7 @@ static int videobuf_dvb_start_feed(struct dvb_demux_feed *feed) | |||
96 | if (!demux->dmx.frontend) | 96 | if (!demux->dmx.frontend) |
97 | return -EINVAL; | 97 | return -EINVAL; |
98 | 98 | ||
99 | down(&dvb->lock); | 99 | mutex_lock(&dvb->lock); |
100 | dvb->nfeeds++; | 100 | dvb->nfeeds++; |
101 | rc = dvb->nfeeds; | 101 | rc = dvb->nfeeds; |
102 | 102 | ||
@@ -110,7 +110,7 @@ static int videobuf_dvb_start_feed(struct dvb_demux_feed *feed) | |||
110 | } | 110 | } |
111 | 111 | ||
112 | out: | 112 | out: |
113 | up(&dvb->lock); | 113 | mutex_unlock(&dvb->lock); |
114 | return rc; | 114 | return rc; |
115 | } | 115 | } |
116 | 116 | ||
@@ -120,14 +120,14 @@ static int videobuf_dvb_stop_feed(struct dvb_demux_feed *feed) | |||
120 | struct videobuf_dvb *dvb = demux->priv; | 120 | struct videobuf_dvb *dvb = demux->priv; |
121 | int err = 0; | 121 | int err = 0; |
122 | 122 | ||
123 | down(&dvb->lock); | 123 | mutex_lock(&dvb->lock); |
124 | dvb->nfeeds--; | 124 | dvb->nfeeds--; |
125 | if (0 == dvb->nfeeds && NULL != dvb->thread) { | 125 | if (0 == dvb->nfeeds && NULL != dvb->thread) { |
126 | // FIXME: cx8802_cancel_buffers(dev); | 126 | // FIXME: cx8802_cancel_buffers(dev); |
127 | err = kthread_stop(dvb->thread); | 127 | err = kthread_stop(dvb->thread); |
128 | dvb->thread = NULL; | 128 | dvb->thread = NULL; |
129 | } | 129 | } |
130 | up(&dvb->lock); | 130 | mutex_unlock(&dvb->lock); |
131 | return err; | 131 | return err; |
132 | } | 132 | } |
133 | 133 | ||
@@ -139,7 +139,7 @@ int videobuf_dvb_register(struct videobuf_dvb *dvb, | |||
139 | { | 139 | { |
140 | int result; | 140 | int result; |
141 | 141 | ||
142 | init_MUTEX(&dvb->lock); | 142 | mutex_init(&dvb->lock); |
143 | 143 | ||
144 | /* register adapter */ | 144 | /* register adapter */ |
145 | result = dvb_register_adapter(&dvb->adapter, dvb->name, module); | 145 | result = dvb_register_adapter(&dvb->adapter, dvb->name, module); |
diff --git a/drivers/media/video/video-buf.c b/drivers/media/video/video-buf.c index 9ef477523d27..cb1c228e29f8 100644 --- a/drivers/media/video/video-buf.c +++ b/drivers/media/video/video-buf.c | |||
@@ -385,7 +385,7 @@ void videobuf_queue_init(struct videobuf_queue* q, | |||
385 | q->ops = ops; | 385 | q->ops = ops; |
386 | q->priv_data = priv; | 386 | q->priv_data = priv; |
387 | 387 | ||
388 | init_MUTEX(&q->lock); | 388 | mutex_init(&q->lock); |
389 | INIT_LIST_HEAD(&q->stream); | 389 | INIT_LIST_HEAD(&q->stream); |
390 | } | 390 | } |
391 | 391 | ||
@@ -549,7 +549,7 @@ videobuf_reqbufs(struct videobuf_queue *q, | |||
549 | if (!list_empty(&q->stream)) | 549 | if (!list_empty(&q->stream)) |
550 | return -EBUSY; | 550 | return -EBUSY; |
551 | 551 | ||
552 | down(&q->lock); | 552 | mutex_lock(&q->lock); |
553 | count = req->count; | 553 | count = req->count; |
554 | if (count > VIDEO_MAX_FRAME) | 554 | if (count > VIDEO_MAX_FRAME) |
555 | count = VIDEO_MAX_FRAME; | 555 | count = VIDEO_MAX_FRAME; |
@@ -566,7 +566,7 @@ videobuf_reqbufs(struct videobuf_queue *q, | |||
566 | req->count = count; | 566 | req->count = count; |
567 | 567 | ||
568 | done: | 568 | done: |
569 | up(&q->lock); | 569 | mutex_unlock(&q->lock); |
570 | return retval; | 570 | return retval; |
571 | } | 571 | } |
572 | 572 | ||
@@ -592,7 +592,7 @@ videobuf_qbuf(struct videobuf_queue *q, | |||
592 | unsigned long flags; | 592 | unsigned long flags; |
593 | int retval; | 593 | int retval; |
594 | 594 | ||
595 | down(&q->lock); | 595 | mutex_lock(&q->lock); |
596 | retval = -EBUSY; | 596 | retval = -EBUSY; |
597 | if (q->reading) | 597 | if (q->reading) |
598 | goto done; | 598 | goto done; |
@@ -652,7 +652,7 @@ videobuf_qbuf(struct videobuf_queue *q, | |||
652 | retval = 0; | 652 | retval = 0; |
653 | 653 | ||
654 | done: | 654 | done: |
655 | up(&q->lock); | 655 | mutex_unlock(&q->lock); |
656 | return retval; | 656 | return retval; |
657 | } | 657 | } |
658 | 658 | ||
@@ -663,7 +663,7 @@ videobuf_dqbuf(struct videobuf_queue *q, | |||
663 | struct videobuf_buffer *buf; | 663 | struct videobuf_buffer *buf; |
664 | int retval; | 664 | int retval; |
665 | 665 | ||
666 | down(&q->lock); | 666 | mutex_lock(&q->lock); |
667 | retval = -EBUSY; | 667 | retval = -EBUSY; |
668 | if (q->reading) | 668 | if (q->reading) |
669 | goto done; | 669 | goto done; |
@@ -693,7 +693,7 @@ videobuf_dqbuf(struct videobuf_queue *q, | |||
693 | videobuf_status(b,buf,q->type); | 693 | videobuf_status(b,buf,q->type); |
694 | 694 | ||
695 | done: | 695 | done: |
696 | up(&q->lock); | 696 | mutex_unlock(&q->lock); |
697 | return retval; | 697 | return retval; |
698 | } | 698 | } |
699 | 699 | ||
@@ -704,7 +704,7 @@ int videobuf_streamon(struct videobuf_queue *q) | |||
704 | unsigned long flags; | 704 | unsigned long flags; |
705 | int retval; | 705 | int retval; |
706 | 706 | ||
707 | down(&q->lock); | 707 | mutex_lock(&q->lock); |
708 | retval = -EBUSY; | 708 | retval = -EBUSY; |
709 | if (q->reading) | 709 | if (q->reading) |
710 | goto done; | 710 | goto done; |
@@ -721,7 +721,7 @@ int videobuf_streamon(struct videobuf_queue *q) | |||
721 | spin_unlock_irqrestore(q->irqlock,flags); | 721 | spin_unlock_irqrestore(q->irqlock,flags); |
722 | 722 | ||
723 | done: | 723 | done: |
724 | up(&q->lock); | 724 | mutex_unlock(&q->lock); |
725 | return retval; | 725 | return retval; |
726 | } | 726 | } |
727 | 727 | ||
@@ -729,7 +729,7 @@ int videobuf_streamoff(struct videobuf_queue *q) | |||
729 | { | 729 | { |
730 | int retval = -EINVAL; | 730 | int retval = -EINVAL; |
731 | 731 | ||
732 | down(&q->lock); | 732 | mutex_lock(&q->lock); |
733 | if (!q->streaming) | 733 | if (!q->streaming) |
734 | goto done; | 734 | goto done; |
735 | videobuf_queue_cancel(q); | 735 | videobuf_queue_cancel(q); |
@@ -737,7 +737,7 @@ int videobuf_streamoff(struct videobuf_queue *q) | |||
737 | retval = 0; | 737 | retval = 0; |
738 | 738 | ||
739 | done: | 739 | done: |
740 | up(&q->lock); | 740 | mutex_unlock(&q->lock); |
741 | return retval; | 741 | return retval; |
742 | } | 742 | } |
743 | 743 | ||
@@ -792,7 +792,7 @@ ssize_t videobuf_read_one(struct videobuf_queue *q, | |||
792 | unsigned size, nbufs, bytes; | 792 | unsigned size, nbufs, bytes; |
793 | int retval; | 793 | int retval; |
794 | 794 | ||
795 | down(&q->lock); | 795 | mutex_lock(&q->lock); |
796 | 796 | ||
797 | nbufs = 1; size = 0; | 797 | nbufs = 1; size = 0; |
798 | q->ops->buf_setup(q,&nbufs,&size); | 798 | q->ops->buf_setup(q,&nbufs,&size); |
@@ -860,7 +860,7 @@ ssize_t videobuf_read_one(struct videobuf_queue *q, | |||
860 | } | 860 | } |
861 | 861 | ||
862 | done: | 862 | done: |
863 | up(&q->lock); | 863 | mutex_unlock(&q->lock); |
864 | return retval; | 864 | return retval; |
865 | } | 865 | } |
866 | 866 | ||
@@ -922,7 +922,7 @@ ssize_t videobuf_read_stream(struct videobuf_queue *q, | |||
922 | unsigned long flags; | 922 | unsigned long flags; |
923 | 923 | ||
924 | dprintk(2,"%s\n",__FUNCTION__); | 924 | dprintk(2,"%s\n",__FUNCTION__); |
925 | down(&q->lock); | 925 | mutex_lock(&q->lock); |
926 | retval = -EBUSY; | 926 | retval = -EBUSY; |
927 | if (q->streaming) | 927 | if (q->streaming) |
928 | goto done; | 928 | goto done; |
@@ -996,7 +996,7 @@ ssize_t videobuf_read_stream(struct videobuf_queue *q, | |||
996 | } | 996 | } |
997 | 997 | ||
998 | done: | 998 | done: |
999 | up(&q->lock); | 999 | mutex_unlock(&q->lock); |
1000 | return retval; | 1000 | return retval; |
1001 | } | 1001 | } |
1002 | 1002 | ||
@@ -1007,7 +1007,7 @@ unsigned int videobuf_poll_stream(struct file *file, | |||
1007 | struct videobuf_buffer *buf = NULL; | 1007 | struct videobuf_buffer *buf = NULL; |
1008 | unsigned int rc = 0; | 1008 | unsigned int rc = 0; |
1009 | 1009 | ||
1010 | down(&q->lock); | 1010 | mutex_lock(&q->lock); |
1011 | if (q->streaming) { | 1011 | if (q->streaming) { |
1012 | if (!list_empty(&q->stream)) | 1012 | if (!list_empty(&q->stream)) |
1013 | buf = list_entry(q->stream.next, | 1013 | buf = list_entry(q->stream.next, |
@@ -1035,7 +1035,7 @@ unsigned int videobuf_poll_stream(struct file *file, | |||
1035 | buf->state == STATE_ERROR) | 1035 | buf->state == STATE_ERROR) |
1036 | rc = POLLIN|POLLRDNORM; | 1036 | rc = POLLIN|POLLRDNORM; |
1037 | } | 1037 | } |
1038 | up(&q->lock); | 1038 | mutex_unlock(&q->lock); |
1039 | return rc; | 1039 | return rc; |
1040 | } | 1040 | } |
1041 | 1041 | ||
@@ -1064,7 +1064,7 @@ videobuf_vm_close(struct vm_area_struct *vma) | |||
1064 | map->count--; | 1064 | map->count--; |
1065 | if (0 == map->count) { | 1065 | if (0 == map->count) { |
1066 | dprintk(1,"munmap %p q=%p\n",map,q); | 1066 | dprintk(1,"munmap %p q=%p\n",map,q); |
1067 | down(&q->lock); | 1067 | mutex_lock(&q->lock); |
1068 | for (i = 0; i < VIDEO_MAX_FRAME; i++) { | 1068 | for (i = 0; i < VIDEO_MAX_FRAME; i++) { |
1069 | if (NULL == q->bufs[i]) | 1069 | if (NULL == q->bufs[i]) |
1070 | continue; | 1070 | continue; |
@@ -1076,7 +1076,7 @@ videobuf_vm_close(struct vm_area_struct *vma) | |||
1076 | q->bufs[i]->baddr = 0; | 1076 | q->bufs[i]->baddr = 0; |
1077 | q->ops->buf_release(q,q->bufs[i]); | 1077 | q->ops->buf_release(q,q->bufs[i]); |
1078 | } | 1078 | } |
1079 | up(&q->lock); | 1079 | mutex_unlock(&q->lock); |
1080 | kfree(map); | 1080 | kfree(map); |
1081 | } | 1081 | } |
1082 | return; | 1082 | return; |
@@ -1170,7 +1170,7 @@ int videobuf_mmap_mapper(struct videobuf_queue *q, | |||
1170 | unsigned int first,last,size,i; | 1170 | unsigned int first,last,size,i; |
1171 | int retval; | 1171 | int retval; |
1172 | 1172 | ||
1173 | down(&q->lock); | 1173 | mutex_lock(&q->lock); |
1174 | retval = -EINVAL; | 1174 | retval = -EINVAL; |
1175 | if (!(vma->vm_flags & VM_WRITE)) { | 1175 | if (!(vma->vm_flags & VM_WRITE)) { |
1176 | dprintk(1,"mmap app bug: PROT_WRITE please\n"); | 1176 | dprintk(1,"mmap app bug: PROT_WRITE please\n"); |
@@ -1238,7 +1238,7 @@ int videobuf_mmap_mapper(struct videobuf_queue *q, | |||
1238 | retval = 0; | 1238 | retval = 0; |
1239 | 1239 | ||
1240 | done: | 1240 | done: |
1241 | up(&q->lock); | 1241 | mutex_unlock(&q->lock); |
1242 | return retval; | 1242 | return retval; |
1243 | } | 1243 | } |
1244 | 1244 | ||
diff --git a/drivers/media/video/videodev.c b/drivers/media/video/videodev.c index 908fbec776ac..75e3d41382f2 100644 --- a/drivers/media/video/videodev.c +++ b/drivers/media/video/videodev.c | |||
@@ -224,13 +224,13 @@ int video_exclusive_open(struct inode *inode, struct file *file) | |||
224 | struct video_device *vfl = video_devdata(file); | 224 | struct video_device *vfl = video_devdata(file); |
225 | int retval = 0; | 225 | int retval = 0; |
226 | 226 | ||
227 | down(&vfl->lock); | 227 | mutex_lock(&vfl->lock); |
228 | if (vfl->users) { | 228 | if (vfl->users) { |
229 | retval = -EBUSY; | 229 | retval = -EBUSY; |
230 | } else { | 230 | } else { |
231 | vfl->users++; | 231 | vfl->users++; |
232 | } | 232 | } |
233 | up(&vfl->lock); | 233 | mutex_unlock(&vfl->lock); |
234 | return retval; | 234 | return retval; |
235 | } | 235 | } |
236 | 236 | ||
@@ -328,7 +328,7 @@ int video_register_device(struct video_device *vfd, int type, int nr) | |||
328 | sprintf(vfd->devfs_name, "v4l/%s%d", name_base, i - base); | 328 | sprintf(vfd->devfs_name, "v4l/%s%d", name_base, i - base); |
329 | devfs_mk_cdev(MKDEV(VIDEO_MAJOR, vfd->minor), | 329 | devfs_mk_cdev(MKDEV(VIDEO_MAJOR, vfd->minor), |
330 | S_IFCHR | S_IRUSR | S_IWUSR, vfd->devfs_name); | 330 | S_IFCHR | S_IRUSR | S_IWUSR, vfd->devfs_name); |
331 | init_MUTEX(&vfd->lock); | 331 | mutex_init(&vfd->lock); |
332 | 332 | ||
333 | /* sysfs class */ | 333 | /* sysfs class */ |
334 | memset(&vfd->class_dev, 0x00, sizeof(vfd->class_dev)); | 334 | memset(&vfd->class_dev, 0x00, sizeof(vfd->class_dev)); |
diff --git a/drivers/media/video/vino.c b/drivers/media/video/vino.c index c8fd8238904d..0229819d0aac 100644 --- a/drivers/media/video/vino.c +++ b/drivers/media/video/vino.c | |||
@@ -42,6 +42,7 @@ | |||
42 | #include <linux/videodev.h> | 42 | #include <linux/videodev.h> |
43 | #include <linux/videodev2.h> | 43 | #include <linux/videodev2.h> |
44 | #include <linux/video_decoder.h> | 44 | #include <linux/video_decoder.h> |
45 | #include <linux/mutex.h> | ||
45 | 46 | ||
46 | #include <asm/paccess.h> | 47 | #include <asm/paccess.h> |
47 | #include <asm/io.h> | 48 | #include <asm/io.h> |
@@ -245,7 +246,7 @@ struct vino_framebuffer_queue { | |||
245 | struct vino_framebuffer *buffer[VINO_FRAMEBUFFER_COUNT_MAX]; | 246 | struct vino_framebuffer *buffer[VINO_FRAMEBUFFER_COUNT_MAX]; |
246 | 247 | ||
247 | spinlock_t queue_lock; | 248 | spinlock_t queue_lock; |
248 | struct semaphore queue_sem; | 249 | struct mutex queue_mutex; |
249 | wait_queue_head_t frame_wait_queue; | 250 | wait_queue_head_t frame_wait_queue; |
250 | }; | 251 | }; |
251 | 252 | ||
@@ -283,7 +284,7 @@ struct vino_channel_settings { | |||
283 | /* the driver is currently processing the queue */ | 284 | /* the driver is currently processing the queue */ |
284 | int capturing; | 285 | int capturing; |
285 | 286 | ||
286 | struct semaphore sem; | 287 | struct mutex mutex; |
287 | spinlock_t capture_lock; | 288 | spinlock_t capture_lock; |
288 | 289 | ||
289 | unsigned int users; | 290 | unsigned int users; |
@@ -1131,11 +1132,11 @@ static void vino_queue_free(struct vino_framebuffer_queue *q) | |||
1131 | if (q->type != VINO_MEMORY_MMAP) | 1132 | if (q->type != VINO_MEMORY_MMAP) |
1132 | return; | 1133 | return; |
1133 | 1134 | ||
1134 | down(&q->queue_sem); | 1135 | mutex_lock(&q->queue_mutex); |
1135 | 1136 | ||
1136 | vino_queue_free_with_count(q, q->length); | 1137 | vino_queue_free_with_count(q, q->length); |
1137 | 1138 | ||
1138 | up(&q->queue_sem); | 1139 | mutex_unlock(&q->queue_mutex); |
1139 | } | 1140 | } |
1140 | 1141 | ||
1141 | static int vino_queue_init(struct vino_framebuffer_queue *q, | 1142 | static int vino_queue_init(struct vino_framebuffer_queue *q, |
@@ -1159,7 +1160,7 @@ static int vino_queue_init(struct vino_framebuffer_queue *q, | |||
1159 | if (*length < 1) | 1160 | if (*length < 1) |
1160 | return -EINVAL; | 1161 | return -EINVAL; |
1161 | 1162 | ||
1162 | down(&q->queue_sem); | 1163 | mutex_lock(&q->queue_mutex); |
1163 | 1164 | ||
1164 | if (*length > VINO_FRAMEBUFFER_COUNT_MAX) | 1165 | if (*length > VINO_FRAMEBUFFER_COUNT_MAX) |
1165 | *length = VINO_FRAMEBUFFER_COUNT_MAX; | 1166 | *length = VINO_FRAMEBUFFER_COUNT_MAX; |
@@ -1211,7 +1212,7 @@ static int vino_queue_init(struct vino_framebuffer_queue *q, | |||
1211 | q->magic = VINO_QUEUE_MAGIC; | 1212 | q->magic = VINO_QUEUE_MAGIC; |
1212 | } | 1213 | } |
1213 | 1214 | ||
1214 | up(&q->queue_sem); | 1215 | mutex_unlock(&q->queue_mutex); |
1215 | 1216 | ||
1216 | return ret; | 1217 | return ret; |
1217 | } | 1218 | } |
@@ -4045,7 +4046,7 @@ static int vino_open(struct inode *inode, struct file *file) | |||
4045 | dprintk("open(): channel = %c\n", | 4046 | dprintk("open(): channel = %c\n", |
4046 | (vcs->channel == VINO_CHANNEL_A) ? 'A' : 'B'); | 4047 | (vcs->channel == VINO_CHANNEL_A) ? 'A' : 'B'); |
4047 | 4048 | ||
4048 | down(&vcs->sem); | 4049 | mutex_lock(&vcs->mutex); |
4049 | 4050 | ||
4050 | if (vcs->users) { | 4051 | if (vcs->users) { |
4051 | dprintk("open(): driver busy\n"); | 4052 | dprintk("open(): driver busy\n"); |
@@ -4062,7 +4063,7 @@ static int vino_open(struct inode *inode, struct file *file) | |||
4062 | vcs->users++; | 4063 | vcs->users++; |
4063 | 4064 | ||
4064 | out: | 4065 | out: |
4065 | up(&vcs->sem); | 4066 | mutex_unlock(&vcs->mutex); |
4066 | 4067 | ||
4067 | dprintk("open(): %s!\n", ret ? "failed" : "complete"); | 4068 | dprintk("open(): %s!\n", ret ? "failed" : "complete"); |
4068 | 4069 | ||
@@ -4075,7 +4076,7 @@ static int vino_close(struct inode *inode, struct file *file) | |||
4075 | struct vino_channel_settings *vcs = video_get_drvdata(dev); | 4076 | struct vino_channel_settings *vcs = video_get_drvdata(dev); |
4076 | dprintk("close():\n"); | 4077 | dprintk("close():\n"); |
4077 | 4078 | ||
4078 | down(&vcs->sem); | 4079 | mutex_lock(&vcs->mutex); |
4079 | 4080 | ||
4080 | vcs->users--; | 4081 | vcs->users--; |
4081 | 4082 | ||
@@ -4087,7 +4088,7 @@ static int vino_close(struct inode *inode, struct file *file) | |||
4087 | vino_queue_free(&vcs->fb_queue); | 4088 | vino_queue_free(&vcs->fb_queue); |
4088 | } | 4089 | } |
4089 | 4090 | ||
4090 | up(&vcs->sem); | 4091 | mutex_unlock(&vcs->mutex); |
4091 | 4092 | ||
4092 | return 0; | 4093 | return 0; |
4093 | } | 4094 | } |
@@ -4130,7 +4131,7 @@ static int vino_mmap(struct file *file, struct vm_area_struct *vma) | |||
4130 | 4131 | ||
4131 | // TODO: reject mmap if already mapped | 4132 | // TODO: reject mmap if already mapped |
4132 | 4133 | ||
4133 | if (down_interruptible(&vcs->sem)) | 4134 | if (mutex_lock_interruptible(&vcs->mutex)) |
4134 | return -EINTR; | 4135 | return -EINTR; |
4135 | 4136 | ||
4136 | if (vcs->reading) { | 4137 | if (vcs->reading) { |
@@ -4214,7 +4215,7 @@ found: | |||
4214 | vma->vm_ops = &vino_vm_ops; | 4215 | vma->vm_ops = &vino_vm_ops; |
4215 | 4216 | ||
4216 | out: | 4217 | out: |
4217 | up(&vcs->sem); | 4218 | mutex_unlock(&vcs->mutex); |
4218 | 4219 | ||
4219 | return ret; | 4220 | return ret; |
4220 | } | 4221 | } |
@@ -4374,12 +4375,12 @@ static int vino_ioctl(struct inode *inode, struct file *file, | |||
4374 | struct vino_channel_settings *vcs = video_get_drvdata(dev); | 4375 | struct vino_channel_settings *vcs = video_get_drvdata(dev); |
4375 | int ret; | 4376 | int ret; |
4376 | 4377 | ||
4377 | if (down_interruptible(&vcs->sem)) | 4378 | if (mutex_lock_interruptible(&vcs->mutex)) |
4378 | return -EINTR; | 4379 | return -EINTR; |
4379 | 4380 | ||
4380 | ret = video_usercopy(inode, file, cmd, arg, vino_do_ioctl); | 4381 | ret = video_usercopy(inode, file, cmd, arg, vino_do_ioctl); |
4381 | 4382 | ||
4382 | up(&vcs->sem); | 4383 | mutex_unlock(&vcs->mutex); |
4383 | 4384 | ||
4384 | return ret; | 4385 | return ret; |
4385 | } | 4386 | } |
@@ -4564,10 +4565,10 @@ static int vino_init_channel_settings(struct vino_channel_settings *vcs, | |||
4564 | 4565 | ||
4565 | vcs->capturing = 0; | 4566 | vcs->capturing = 0; |
4566 | 4567 | ||
4567 | init_MUTEX(&vcs->sem); | 4568 | mutex_init(&vcs->mutex); |
4568 | spin_lock_init(&vcs->capture_lock); | 4569 | spin_lock_init(&vcs->capture_lock); |
4569 | 4570 | ||
4570 | init_MUTEX(&vcs->fb_queue.queue_sem); | 4571 | mutex_init(&vcs->fb_queue.queue_mutex); |
4571 | spin_lock_init(&vcs->fb_queue.queue_lock); | 4572 | spin_lock_init(&vcs->fb_queue.queue_lock); |
4572 | init_waitqueue_head(&vcs->fb_queue.frame_wait_queue); | 4573 | init_waitqueue_head(&vcs->fb_queue.frame_wait_queue); |
4573 | 4574 | ||