aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/media/vicam.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/media/vicam.c')
-rw-r--r--drivers/usb/media/vicam.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/drivers/usb/media/vicam.c b/drivers/usb/media/vicam.c
index 5df144073871..1d06e53ec7c5 100644
--- a/drivers/usb/media/vicam.c
+++ b/drivers/usb/media/vicam.c
@@ -42,6 +42,7 @@
42#include <linux/vmalloc.h> 42#include <linux/vmalloc.h>
43#include <linux/slab.h> 43#include <linux/slab.h>
44#include <linux/proc_fs.h> 44#include <linux/proc_fs.h>
45#include <linux/mutex.h>
45#include "usbvideo.h" 46#include "usbvideo.h"
46 47
47// #define VICAM_DEBUG 48// #define VICAM_DEBUG
@@ -407,7 +408,7 @@ struct vicam_camera {
407 struct usb_device *udev; // usb device 408 struct usb_device *udev; // usb device
408 409
409 /* guard against simultaneous accesses to the camera */ 410 /* guard against simultaneous accesses to the camera */
410 struct semaphore cam_lock; 411 struct mutex cam_lock;
411 412
412 int is_initialized; 413 int is_initialized;
413 u8 open_count; 414 u8 open_count;
@@ -461,12 +462,12 @@ static int send_control_msg(struct vicam_camera *cam,
461 u16 size) 462 u16 size)
462{ 463{
463 int status = -ENODEV; 464 int status = -ENODEV;
464 down(&cam->cam_lock); 465 mutex_lock(&cam->cam_lock);
465 if (cam->udev) { 466 if (cam->udev) {
466 status = __send_control_msg(cam, request, value, 467 status = __send_control_msg(cam, request, value,
467 index, cp, size); 468 index, cp, size);
468 } 469 }
469 up(&cam->cam_lock); 470 mutex_unlock(&cam->cam_lock);
470 return status; 471 return status;
471} 472}
472static int 473static int
@@ -763,6 +764,7 @@ vicam_open(struct inode *inode, struct file *file)
763 if (!cam) { 764 if (!cam) {
764 printk(KERN_ERR 765 printk(KERN_ERR
765 "vicam video_device improperly initialized"); 766 "vicam video_device improperly initialized");
767 return -EINVAL;
766 } 768 }
767 769
768 /* the videodev_lock held above us protects us from 770 /* the videodev_lock held above us protects us from
@@ -831,13 +833,13 @@ vicam_close(struct inode *inode, struct file *file)
831 rvfree(cam->framebuf, VICAM_MAX_FRAME_SIZE * VICAM_FRAMES); 833 rvfree(cam->framebuf, VICAM_MAX_FRAME_SIZE * VICAM_FRAMES);
832 kfree(cam->cntrlbuf); 834 kfree(cam->cntrlbuf);
833 835
834 down(&cam->cam_lock); 836 mutex_lock(&cam->cam_lock);
835 837
836 cam->open_count--; 838 cam->open_count--;
837 open_count = cam->open_count; 839 open_count = cam->open_count;
838 udev = cam->udev; 840 udev = cam->udev;
839 841
840 up(&cam->cam_lock); 842 mutex_unlock(&cam->cam_lock);
841 843
842 if (!open_count && !udev) { 844 if (!open_count && !udev) {
843 kfree(cam); 845 kfree(cam);
@@ -960,7 +962,7 @@ read_frame(struct vicam_camera *cam, int framenum)
960 request[8] = 0; 962 request[8] = 0;
961 // bytes 9-15 do not seem to affect exposure or image quality 963 // bytes 9-15 do not seem to affect exposure or image quality
962 964
963 down(&cam->cam_lock); 965 mutex_lock(&cam->cam_lock);
964 966
965 if (!cam->udev) { 967 if (!cam->udev) {
966 goto done; 968 goto done;
@@ -985,7 +987,7 @@ read_frame(struct vicam_camera *cam, int framenum)
985 } 987 }
986 988
987 done: 989 done:
988 up(&cam->cam_lock); 990 mutex_unlock(&cam->cam_lock);
989} 991}
990 992
991static ssize_t 993static ssize_t
@@ -1309,7 +1311,7 @@ vicam_probe( struct usb_interface *intf, const struct usb_device_id *id)
1309 1311
1310 cam->shutter_speed = 15; 1312 cam->shutter_speed = 15;
1311 1313
1312 init_MUTEX(&cam->cam_lock); 1314 mutex_init(&cam->cam_lock);
1313 1315
1314 memcpy(&cam->vdev, &vicam_template, 1316 memcpy(&cam->vdev, &vicam_template,
1315 sizeof (vicam_template)); 1317 sizeof (vicam_template));
@@ -1351,7 +1353,7 @@ vicam_disconnect(struct usb_interface *intf)
1351 1353
1352 /* stop the camera from being used */ 1354 /* stop the camera from being used */
1353 1355
1354 down(&cam->cam_lock); 1356 mutex_lock(&cam->cam_lock);
1355 1357
1356 /* mark the camera as gone */ 1358 /* mark the camera as gone */
1357 1359
@@ -1368,7 +1370,7 @@ vicam_disconnect(struct usb_interface *intf)
1368 1370
1369 open_count = cam->open_count; 1371 open_count = cam->open_count;
1370 1372
1371 up(&cam->cam_lock); 1373 mutex_unlock(&cam->cam_lock);
1372 1374
1373 if (!open_count) { 1375 if (!open_count) {
1374 kfree(cam); 1376 kfree(cam);