aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/dvb-core/dvbdev.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/dvb/dvb-core/dvbdev.c')
-rw-r--r--drivers/media/dvb/dvb-core/dvbdev.c142
1 files changed, 71 insertions, 71 deletions
diff --git a/drivers/media/dvb/dvb-core/dvbdev.c b/drivers/media/dvb/dvb-core/dvbdev.c
index 477b4fa56430..a4aee8665854 100644
--- a/drivers/media/dvb/dvb-core/dvbdev.c
+++ b/drivers/media/dvb/dvb-core/dvbdev.c
@@ -47,7 +47,7 @@ static LIST_HEAD(dvb_adapter_list);
47static DECLARE_MUTEX(dvbdev_register_lock); 47static DECLARE_MUTEX(dvbdev_register_lock);
48 48
49static const char * const dnames[] = { 49static const char * const dnames[] = {
50 "video", "audio", "sec", "frontend", "demux", "dvr", "ca", 50 "video", "audio", "sec", "frontend", "demux", "dvr", "ca",
51 "net", "osd" 51 "net", "osd"
52}; 52};
53 53
@@ -90,15 +90,15 @@ static int dvb_device_open(struct inode *inode, struct file *file)
90 90
91 file->private_data = dvbdev; 91 file->private_data = dvbdev;
92 old_fops = file->f_op; 92 old_fops = file->f_op;
93 file->f_op = fops_get(dvbdev->fops); 93 file->f_op = fops_get(dvbdev->fops);
94 if(file->f_op->open) 94 if(file->f_op->open)
95 err = file->f_op->open(inode,file); 95 err = file->f_op->open(inode,file);
96 if (err) { 96 if (err) {
97 fops_put(file->f_op); 97 fops_put(file->f_op);
98 file->f_op = fops_get(old_fops); 98 file->f_op = fops_get(old_fops);
99 } 99 }
100 fops_put(old_fops); 100 fops_put(old_fops);
101 return err; 101 return err;
102 } 102 }
103 return -ENODEV; 103 return -ENODEV;
104} 104}
@@ -117,21 +117,21 @@ static struct cdev dvb_device_cdev = {
117 117
118int dvb_generic_open(struct inode *inode, struct file *file) 118int dvb_generic_open(struct inode *inode, struct file *file)
119{ 119{
120 struct dvb_device *dvbdev = file->private_data; 120 struct dvb_device *dvbdev = file->private_data;
121 121
122 if (!dvbdev) 122 if (!dvbdev)
123 return -ENODEV; 123 return -ENODEV;
124 124
125 if (!dvbdev->users) 125 if (!dvbdev->users)
126 return -EBUSY; 126 return -EBUSY;
127 127
128 if ((file->f_flags & O_ACCMODE) == O_RDONLY) { 128 if ((file->f_flags & O_ACCMODE) == O_RDONLY) {
129 if (!dvbdev->readers) 129 if (!dvbdev->readers)
130 return -EBUSY; 130 return -EBUSY;
131 dvbdev->readers--; 131 dvbdev->readers--;
132 } else { 132 } else {
133 if (!dvbdev->writers) 133 if (!dvbdev->writers)
134 return -EBUSY; 134 return -EBUSY;
135 dvbdev->writers--; 135 dvbdev->writers--;
136 } 136 }
137 137
@@ -143,10 +143,10 @@ EXPORT_SYMBOL(dvb_generic_open);
143 143
144int dvb_generic_release(struct inode *inode, struct file *file) 144int dvb_generic_release(struct inode *inode, struct file *file)
145{ 145{
146 struct dvb_device *dvbdev = file->private_data; 146 struct dvb_device *dvbdev = file->private_data;
147 147
148 if (!dvbdev) 148 if (!dvbdev)
149 return -ENODEV; 149 return -ENODEV;
150 150
151 if ((file->f_flags & O_ACCMODE) == O_RDONLY) { 151 if ((file->f_flags & O_ACCMODE) == O_RDONLY) {
152 dvbdev->readers++; 152 dvbdev->readers++;
@@ -163,10 +163,10 @@ EXPORT_SYMBOL(dvb_generic_release);
163int dvb_generic_ioctl(struct inode *inode, struct file *file, 163int dvb_generic_ioctl(struct inode *inode, struct file *file,
164 unsigned int cmd, unsigned long arg) 164 unsigned int cmd, unsigned long arg)
165{ 165{
166 struct dvb_device *dvbdev = file->private_data; 166 struct dvb_device *dvbdev = file->private_data;
167 167
168 if (!dvbdev) 168 if (!dvbdev)
169 return -ENODEV; 169 return -ENODEV;
170 170
171 if (!dvbdev->kernel_ioctl) 171 if (!dvbdev->kernel_ioctl)
172 return -EINVAL; 172 return -EINVAL;
@@ -334,63 +334,63 @@ EXPORT_SYMBOL(dvb_unregister_adapter);
334 to the v4l "videodev.o" module, which is unnecessary for some 334 to the v4l "videodev.o" module, which is unnecessary for some
335 cards (ie. the budget dvb-cards don't need the v4l module...) */ 335 cards (ie. the budget dvb-cards don't need the v4l module...) */
336int dvb_usercopy(struct inode *inode, struct file *file, 336int dvb_usercopy(struct inode *inode, struct file *file,
337 unsigned int cmd, unsigned long arg, 337 unsigned int cmd, unsigned long arg,
338 int (*func)(struct inode *inode, struct file *file, 338 int (*func)(struct inode *inode, struct file *file,
339 unsigned int cmd, void *arg)) 339 unsigned int cmd, void *arg))
340{ 340{
341 char sbuf[128]; 341 char sbuf[128];
342 void *mbuf = NULL; 342 void *mbuf = NULL;
343 void *parg = NULL; 343 void *parg = NULL;
344 int err = -EINVAL; 344 int err = -EINVAL;
345 345
346 /* Copy arguments into temp kernel buffer */ 346 /* Copy arguments into temp kernel buffer */
347 switch (_IOC_DIR(cmd)) { 347 switch (_IOC_DIR(cmd)) {
348 case _IOC_NONE: 348 case _IOC_NONE:
349 /* 349 /*
350 * For this command, the pointer is actually an integer 350 * For this command, the pointer is actually an integer
351 * argument. 351 * argument.
352 */ 352 */
353 parg = (void *) arg; 353 parg = (void *) arg;
354 break; 354 break;
355 case _IOC_READ: /* some v4l ioctls are marked wrong ... */ 355 case _IOC_READ: /* some v4l ioctls are marked wrong ... */
356 case _IOC_WRITE: 356 case _IOC_WRITE:
357 case (_IOC_WRITE | _IOC_READ): 357 case (_IOC_WRITE | _IOC_READ):
358 if (_IOC_SIZE(cmd) <= sizeof(sbuf)) { 358 if (_IOC_SIZE(cmd) <= sizeof(sbuf)) {
359 parg = sbuf; 359 parg = sbuf;
360 } else { 360 } else {
361 /* too big to allocate from stack */ 361 /* too big to allocate from stack */
362 mbuf = kmalloc(_IOC_SIZE(cmd),GFP_KERNEL); 362 mbuf = kmalloc(_IOC_SIZE(cmd),GFP_KERNEL);
363 if (NULL == mbuf) 363 if (NULL == mbuf)
364 return -ENOMEM; 364 return -ENOMEM;
365 parg = mbuf; 365 parg = mbuf;
366 } 366 }
367 367
368 err = -EFAULT; 368 err = -EFAULT;
369 if (copy_from_user(parg, (void __user *)arg, _IOC_SIZE(cmd))) 369 if (copy_from_user(parg, (void __user *)arg, _IOC_SIZE(cmd)))
370 goto out; 370 goto out;
371 break; 371 break;
372 } 372 }
373 373
374 /* call driver */ 374 /* call driver */
375 if ((err = func(inode, file, cmd, parg)) == -ENOIOCTLCMD) 375 if ((err = func(inode, file, cmd, parg)) == -ENOIOCTLCMD)
376 err = -EINVAL; 376 err = -EINVAL;
377 377
378 if (err < 0) 378 if (err < 0)
379 goto out; 379 goto out;
380 380
381 /* Copy results into user buffer */ 381 /* Copy results into user buffer */
382 switch (_IOC_DIR(cmd)) 382 switch (_IOC_DIR(cmd))
383 { 383 {
384 case _IOC_READ: 384 case _IOC_READ:
385 case (_IOC_WRITE | _IOC_READ): 385 case (_IOC_WRITE | _IOC_READ):
386 if (copy_to_user((void __user *)arg, parg, _IOC_SIZE(cmd))) 386 if (copy_to_user((void __user *)arg, parg, _IOC_SIZE(cmd)))
387 err = -EFAULT; 387 err = -EFAULT;
388 break; 388 break;
389 } 389 }
390 390
391out: 391out:
392 kfree(mbuf); 392 kfree(mbuf);
393 return err; 393 return err;
394} 394}
395 395
396static int __init init_dvbdev(void) 396static int __init init_dvbdev(void)
@@ -427,10 +427,10 @@ error:
427 427
428static void __exit exit_dvbdev(void) 428static void __exit exit_dvbdev(void)
429{ 429{
430 devfs_remove("dvb"); 430 devfs_remove("dvb");
431 class_destroy(dvb_class); 431 class_destroy(dvb_class);
432 cdev_del(&dvb_device_cdev); 432 cdev_del(&dvb_device_cdev);
433 unregister_chrdev_region(MKDEV(DVB_MAJOR, 0), MAX_DVB_MINORS); 433 unregister_chrdev_region(MKDEV(DVB_MAJOR, 0), MAX_DVB_MINORS);
434} 434}
435 435
436module_init(init_dvbdev); 436module_init(init_dvbdev);