diff options
Diffstat (limited to 'drivers/media/video/usbvideo/vicam.c')
-rw-r--r-- | drivers/media/video/usbvideo/vicam.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/drivers/media/video/usbvideo/vicam.c b/drivers/media/video/usbvideo/vicam.c index 2eb45829791c..7a127d6bfdee 100644 --- a/drivers/media/video/usbvideo/vicam.c +++ b/drivers/media/video/usbvideo/vicam.c | |||
@@ -472,9 +472,8 @@ vicam_ioctl(struct inode *inode, struct file *file, unsigned int ioctlnr, unsign | |||
472 | static int | 472 | static int |
473 | vicam_open(struct inode *inode, struct file *file) | 473 | vicam_open(struct inode *inode, struct file *file) |
474 | { | 474 | { |
475 | struct video_device *dev = video_devdata(file); | 475 | struct vicam_camera *cam = video_drvdata(file); |
476 | struct vicam_camera *cam = | 476 | |
477 | (struct vicam_camera *) dev->priv; | ||
478 | DBG("open\n"); | 477 | DBG("open\n"); |
479 | 478 | ||
480 | if (!cam) { | 479 | if (!cam) { |
@@ -488,20 +487,24 @@ vicam_open(struct inode *inode, struct file *file) | |||
488 | * rely on this fact forever. | 487 | * rely on this fact forever. |
489 | */ | 488 | */ |
490 | 489 | ||
490 | lock_kernel(); | ||
491 | if (cam->open_count > 0) { | 491 | if (cam->open_count > 0) { |
492 | printk(KERN_INFO | 492 | printk(KERN_INFO |
493 | "vicam_open called on already opened camera"); | 493 | "vicam_open called on already opened camera"); |
494 | unlock_kernel(); | ||
494 | return -EBUSY; | 495 | return -EBUSY; |
495 | } | 496 | } |
496 | 497 | ||
497 | cam->raw_image = kmalloc(VICAM_MAX_READ_SIZE, GFP_KERNEL); | 498 | cam->raw_image = kmalloc(VICAM_MAX_READ_SIZE, GFP_KERNEL); |
498 | if (!cam->raw_image) { | 499 | if (!cam->raw_image) { |
500 | unlock_kernel(); | ||
499 | return -ENOMEM; | 501 | return -ENOMEM; |
500 | } | 502 | } |
501 | 503 | ||
502 | cam->framebuf = rvmalloc(VICAM_MAX_FRAME_SIZE * VICAM_FRAMES); | 504 | cam->framebuf = rvmalloc(VICAM_MAX_FRAME_SIZE * VICAM_FRAMES); |
503 | if (!cam->framebuf) { | 505 | if (!cam->framebuf) { |
504 | kfree(cam->raw_image); | 506 | kfree(cam->raw_image); |
507 | unlock_kernel(); | ||
505 | return -ENOMEM; | 508 | return -ENOMEM; |
506 | } | 509 | } |
507 | 510 | ||
@@ -509,6 +512,7 @@ vicam_open(struct inode *inode, struct file *file) | |||
509 | if (!cam->cntrlbuf) { | 512 | if (!cam->cntrlbuf) { |
510 | kfree(cam->raw_image); | 513 | kfree(cam->raw_image); |
511 | rvfree(cam->framebuf, VICAM_MAX_FRAME_SIZE * VICAM_FRAMES); | 514 | rvfree(cam->framebuf, VICAM_MAX_FRAME_SIZE * VICAM_FRAMES); |
515 | unlock_kernel(); | ||
512 | return -ENOMEM; | 516 | return -ENOMEM; |
513 | } | 517 | } |
514 | 518 | ||
@@ -526,6 +530,7 @@ vicam_open(struct inode *inode, struct file *file) | |||
526 | cam->open_count++; | 530 | cam->open_count++; |
527 | 531 | ||
528 | file->private_data = cam; | 532 | file->private_data = cam; |
533 | unlock_kernel(); | ||
529 | 534 | ||
530 | return 0; | 535 | return 0; |
531 | } | 536 | } |
@@ -795,6 +800,7 @@ static struct video_device vicam_template = { | |||
795 | .name = "ViCam-based USB Camera", | 800 | .name = "ViCam-based USB Camera", |
796 | .fops = &vicam_fops, | 801 | .fops = &vicam_fops, |
797 | .minor = -1, | 802 | .minor = -1, |
803 | .release = video_device_release_empty, | ||
798 | }; | 804 | }; |
799 | 805 | ||
800 | /* table of devices that work with this driver */ | 806 | /* table of devices that work with this driver */ |
@@ -859,9 +865,8 @@ vicam_probe( struct usb_interface *intf, const struct usb_device_id *id) | |||
859 | 865 | ||
860 | mutex_init(&cam->cam_lock); | 866 | mutex_init(&cam->cam_lock); |
861 | 867 | ||
862 | memcpy(&cam->vdev, &vicam_template, | 868 | memcpy(&cam->vdev, &vicam_template, sizeof(vicam_template)); |
863 | sizeof (vicam_template)); | 869 | video_set_drvdata(&cam->vdev, cam); |
864 | cam->vdev.priv = cam; // sort of a reverse mapping for those functions that get vdev only | ||
865 | 870 | ||
866 | cam->udev = dev; | 871 | cam->udev = dev; |
867 | cam->bulkEndpoint = bulkEndpoint; | 872 | cam->bulkEndpoint = bulkEndpoint; |