1 #include <linux/errno.h>
3 #include <linux/string.h>
4 #include <linux/module.h>
5 #include <linux/ioctl.h>
6 #include <linux/slab.h>
7 #include <linux/smp_lock.h>
8 #include <asm/uaccess.h>
10 void dvb_kernel_thread_setup (const char *thread_name)
14 daemonize (thread_name);
16 sigfillset (¤t->blocked);
21 /* if the miracle happens and "generic_usercopy()" is included into
22 the kernel, then this can vanish. please don't make the mistake and
23 define this as video_usercopy(). this will introduce a dependecy
24 to the v4l "videodev.o" module, which is unnecessary for some
25 cards (ie. the budget dvb-cards don't need the v4l module...) */
26 int dvb_usercopy(struct inode *inode, struct file *file,
27 unsigned int cmd, unsigned long arg,
28 int (*func)(struct inode *inode, struct file *file,
29 unsigned int cmd, void *arg))
36 /* Copy arguments into temp kernel buffer */
37 switch (_IOC_DIR(cmd)) {
40 * For this command, the pointer is actually an integer
45 case _IOC_READ: /* some v4l ioctls are marked wrong ... */
47 case (_IOC_WRITE | _IOC_READ):
48 if (_IOC_SIZE(cmd) <= sizeof(sbuf)) {
51 /* too big to allocate from stack */
52 mbuf = kmalloc(_IOC_SIZE(cmd),GFP_KERNEL);
59 if (copy_from_user(parg, (void __user *)arg, _IOC_SIZE(cmd)))
65 if ((err = func(inode, file, cmd, parg)) == -ENOIOCTLCMD)
71 /* Copy results into user buffer */
72 switch (_IOC_DIR(cmd))
75 case (_IOC_WRITE | _IOC_READ):
76 if (copy_to_user((void __user *)arg, parg, _IOC_SIZE(cmd)))
88 EXPORT_SYMBOL(dvb_usercopy);
89 EXPORT_SYMBOL(dvb_kernel_thread_setup);