aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/usbvideo/vicam.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/usbvideo/vicam.c')
-rw-r--r--drivers/media/video/usbvideo/vicam.c29
1 files changed, 14 insertions, 15 deletions
diff --git a/drivers/media/video/usbvideo/vicam.c b/drivers/media/video/usbvideo/vicam.c
index 5d6fd01f918..dc17cce2fbb 100644
--- a/drivers/media/video/usbvideo/vicam.c
+++ b/drivers/media/video/usbvideo/vicam.c
@@ -43,7 +43,6 @@
43#include <linux/vmalloc.h> 43#include <linux/vmalloc.h>
44#include <linux/mm.h> 44#include <linux/mm.h>
45#include <linux/slab.h> 45#include <linux/slab.h>
46#include <linux/smp_lock.h>
47#include <linux/mutex.h> 46#include <linux/mutex.h>
48#include <linux/firmware.h> 47#include <linux/firmware.h>
49#include <linux/ihex.h> 48#include <linux/ihex.h>
@@ -483,29 +482,28 @@ vicam_open(struct file *file)
483 return -EINVAL; 482 return -EINVAL;
484 } 483 }
485 484
486 /* the videodev_lock held above us protects us from 485 /* cam_lock/open_count protects us from simultaneous opens
487 * simultaneous opens...for now. we probably shouldn't 486 * ... for now. we probably shouldn't rely on this fact forever.
488 * rely on this fact forever.
489 */ 487 */
490 488
491 lock_kernel(); 489 mutex_lock(&cam->cam_lock);
492 if (cam->open_count > 0) { 490 if (cam->open_count > 0) {
493 printk(KERN_INFO 491 printk(KERN_INFO
494 "vicam_open called on already opened camera"); 492 "vicam_open called on already opened camera");
495 unlock_kernel(); 493 mutex_unlock(&cam->cam_lock);
496 return -EBUSY; 494 return -EBUSY;
497 } 495 }
498 496
499 cam->raw_image = kmalloc(VICAM_MAX_READ_SIZE, GFP_KERNEL); 497 cam->raw_image = kmalloc(VICAM_MAX_READ_SIZE, GFP_KERNEL);
500 if (!cam->raw_image) { 498 if (!cam->raw_image) {
501 unlock_kernel(); 499 mutex_unlock(&cam->cam_lock);
502 return -ENOMEM; 500 return -ENOMEM;
503 } 501 }
504 502
505 cam->framebuf = rvmalloc(VICAM_MAX_FRAME_SIZE * VICAM_FRAMES); 503 cam->framebuf = rvmalloc(VICAM_MAX_FRAME_SIZE * VICAM_FRAMES);
506 if (!cam->framebuf) { 504 if (!cam->framebuf) {
507 kfree(cam->raw_image); 505 kfree(cam->raw_image);
508 unlock_kernel(); 506 mutex_unlock(&cam->cam_lock);
509 return -ENOMEM; 507 return -ENOMEM;
510 } 508 }
511 509
@@ -513,10 +511,17 @@ vicam_open(struct file *file)
513 if (!cam->cntrlbuf) { 511 if (!cam->cntrlbuf) {
514 kfree(cam->raw_image); 512 kfree(cam->raw_image);
515 rvfree(cam->framebuf, VICAM_MAX_FRAME_SIZE * VICAM_FRAMES); 513 rvfree(cam->framebuf, VICAM_MAX_FRAME_SIZE * VICAM_FRAMES);
516 unlock_kernel(); 514 mutex_unlock(&cam->cam_lock);
517 return -ENOMEM; 515 return -ENOMEM;
518 } 516 }
519 517
518 cam->needsDummyRead = 1;
519 cam->open_count++;
520
521 file->private_data = cam;
522 mutex_unlock(&cam->cam_lock);
523
524
520 // First upload firmware, then turn the camera on 525 // First upload firmware, then turn the camera on
521 526
522 if (!cam->is_initialized) { 527 if (!cam->is_initialized) {
@@ -527,12 +532,6 @@ vicam_open(struct file *file)
527 532
528 set_camera_power(cam, 1); 533 set_camera_power(cam, 1);
529 534
530 cam->needsDummyRead = 1;
531 cam->open_count++;
532
533 file->private_data = cam;
534 unlock_kernel();
535
536 return 0; 535 return 0;
537} 536}
538 537