aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/videodev.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/videodev.c')
-rw-r--r--drivers/media/video/videodev.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/drivers/media/video/videodev.c b/drivers/media/video/videodev.c
index d5be2598714..078880e4c8c 100644
--- a/drivers/media/video/videodev.c
+++ b/drivers/media/video/videodev.c
@@ -29,7 +29,6 @@
29#include <linux/devfs_fs_kernel.h> 29#include <linux/devfs_fs_kernel.h>
30#include <asm/uaccess.h> 30#include <asm/uaccess.h>
31#include <asm/system.h> 31#include <asm/system.h>
32#include <asm/semaphore.h>
33 32
34#include <linux/videodev.h> 33#include <linux/videodev.h>
35 34
@@ -83,7 +82,7 @@ static struct class video_class = {
83 */ 82 */
84 83
85static struct video_device *video_device[VIDEO_NUM_DEVICES]; 84static struct video_device *video_device[VIDEO_NUM_DEVICES];
86static DECLARE_MUTEX(videodev_lock); 85static DEFINE_MUTEX(videodev_lock);
87 86
88struct video_device* video_devdata(struct file *file) 87struct video_device* video_devdata(struct file *file)
89{ 88{
@@ -102,15 +101,15 @@ static int video_open(struct inode *inode, struct file *file)
102 101
103 if(minor>=VIDEO_NUM_DEVICES) 102 if(minor>=VIDEO_NUM_DEVICES)
104 return -ENODEV; 103 return -ENODEV;
105 down(&videodev_lock); 104 mutex_lock(&videodev_lock);
106 vfl=video_device[minor]; 105 vfl=video_device[minor];
107 if(vfl==NULL) { 106 if(vfl==NULL) {
108 up(&videodev_lock); 107 mutex_unlock(&videodev_lock);
109 request_module("char-major-%d-%d", VIDEO_MAJOR, minor); 108 request_module("char-major-%d-%d", VIDEO_MAJOR, minor);
110 down(&videodev_lock); 109 mutex_lock(&videodev_lock);
111 vfl=video_device[minor]; 110 vfl=video_device[minor];
112 if (vfl==NULL) { 111 if (vfl==NULL) {
113 up(&videodev_lock); 112 mutex_unlock(&videodev_lock);
114 return -ENODEV; 113 return -ENODEV;
115 } 114 }
116 } 115 }
@@ -123,7 +122,7 @@ static int video_open(struct inode *inode, struct file *file)
123 file->f_op = fops_get(old_fops); 122 file->f_op = fops_get(old_fops);
124 } 123 }
125 fops_put(old_fops); 124 fops_put(old_fops);
126 up(&videodev_lock); 125 mutex_unlock(&videodev_lock);
127 return err; 126 return err;
128} 127}
129 128
@@ -304,12 +303,12 @@ int video_register_device(struct video_device *vfd, int type, int nr)
304 } 303 }
305 304
306 /* pick a minor number */ 305 /* pick a minor number */
307 down(&videodev_lock); 306 mutex_lock(&videodev_lock);
308 if (nr >= 0 && nr < end-base) { 307 if (nr >= 0 && nr < end-base) {
309 /* use the one the driver asked for */ 308 /* use the one the driver asked for */
310 i = base+nr; 309 i = base+nr;
311 if (NULL != video_device[i]) { 310 if (NULL != video_device[i]) {
312 up(&videodev_lock); 311 mutex_unlock(&videodev_lock);
313 return -ENFILE; 312 return -ENFILE;
314 } 313 }
315 } else { 314 } else {
@@ -318,13 +317,13 @@ int video_register_device(struct video_device *vfd, int type, int nr)
318 if (NULL == video_device[i]) 317 if (NULL == video_device[i])
319 break; 318 break;
320 if (i == end) { 319 if (i == end) {
321 up(&videodev_lock); 320 mutex_unlock(&videodev_lock);
322 return -ENFILE; 321 return -ENFILE;
323 } 322 }
324 } 323 }
325 video_device[i]=vfd; 324 video_device[i]=vfd;
326 vfd->minor=i; 325 vfd->minor=i;
327 up(&videodev_lock); 326 mutex_unlock(&videodev_lock);
328 327
329 sprintf(vfd->devfs_name, "v4l/%s%d", name_base, i - base); 328 sprintf(vfd->devfs_name, "v4l/%s%d", name_base, i - base);
330 devfs_mk_cdev(MKDEV(VIDEO_MAJOR, vfd->minor), 329 devfs_mk_cdev(MKDEV(VIDEO_MAJOR, vfd->minor),
@@ -362,14 +361,14 @@ int video_register_device(struct video_device *vfd, int type, int nr)
362 361
363void video_unregister_device(struct video_device *vfd) 362void video_unregister_device(struct video_device *vfd)
364{ 363{
365 down(&videodev_lock); 364 mutex_lock(&videodev_lock);
366 if(video_device[vfd->minor]!=vfd) 365 if(video_device[vfd->minor]!=vfd)
367 panic("videodev: bad unregister"); 366 panic("videodev: bad unregister");
368 367
369 devfs_remove(vfd->devfs_name); 368 devfs_remove(vfd->devfs_name);
370 video_device[vfd->minor]=NULL; 369 video_device[vfd->minor]=NULL;
371 class_device_unregister(&vfd->class_dev); 370 class_device_unregister(&vfd->class_dev);
372 up(&videodev_lock); 371 mutex_unlock(&videodev_lock);
373} 372}
374 373
375 374