From be9de9e1165b46235ded5a201a93683bc45c3c0e Mon Sep 17 00:00:00 2001 From: leslie Date: Fri, 9 Sep 2011 06:55:13 +0800 Subject: [PATCH] sasc: add dvbloopback kernel 2.6.38 fixes --- .../sasc-ng/dvbloopback/module/dvb_loopback.c | 34 +++++++++++++++++++ .../dvbloopback/module/dvblb_forward.c | 6 ++++ 2 files changed, 40 insertions(+) diff --git a/contrib/sasc-ng/dvbloopback/module/dvb_loopback.c b/contrib/sasc-ng/dvbloopback/module/dvb_loopback.c index 2c477eb..5299dbe 100644 --- a/contrib/sasc-ng/dvbloopback/module/dvb_loopback.c +++ b/contrib/sasc-ng/dvbloopback/module/dvb_loopback.c @@ -118,10 +118,17 @@ static void rvfree(void *mem, unsigned long size) /* This is a copy of dvb_usercopy. We need to do this because it isn't exported by dvbdev */ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38) +static int dvblb_usercopy(struct file *file, + unsigned int cmd, unsigned long arg, + int (*func)(struct file *file, + unsigned int cmd, void *arg)) +#else static int dvblb_usercopy(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg, int (*func)(struct inode *inode, struct file *file, unsigned int cmd, void *arg)) +#endif { char sbuf[128]; void *mbuf = NULL; @@ -180,7 +187,11 @@ static int dvblb_usercopy(struct inode *inode, struct file *file, } /* call driver */ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38) + if ((err = func(file, cmd, parg)) == -ENOIOCTLCMD) +#else if ((err = func(inode, file, cmd, parg)) == -ENOIOCTLCMD) +#endif err = -EINVAL; if (err < 0) @@ -663,8 +674,13 @@ static ssize_t dvblb_read (struct file *f, char * buf, size_t count, loff_t *off dvb_generic_ioctl) which is called by dvblb_ioctl for device-0. It is used to forward ioctl commands back to the userspace application */ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38) +static int dvblb_looped_ioctl(struct file *f, + unsigned int cmd, void *parg) +#else static int dvblb_looped_ioctl(struct inode *inode, struct file *f, unsigned int cmd, void *parg) +#endif { int ret; struct dvb_device *dvbdev, **filemap; @@ -692,8 +708,13 @@ static int dvblb_looped_ioctl(struct inode *inode, struct file *f, return ret; } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38) +static long dvblb_ioctl(struct file *f, + unsigned int cmd, unsigned long arg) +#else static int dvblb_ioctl(struct inode *inode, struct file *f, unsigned int cmd, unsigned long arg) +#endif { void * parg = (void *)arg; struct dvb_device *dvbdev, **filemap; @@ -723,8 +744,13 @@ static int dvblb_ioctl(struct inode *inode, struct file *f, if (lbdev->forward_dev) return dvblb_forward_ioctl(lbdev, f, cmd, arg); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38) + return dvblb_usercopy (f, cmd, arg, + dvbdev->kernel_ioctl); +#else return dvblb_usercopy (inode, f, cmd, arg, dvbdev->kernel_ioctl); +#endif } /* This is the userspace control device */ dprintk2("dvblb_ioctl %d%s%d fd:%d cmd:%x\n",lbdev->parent->adapter.num, @@ -978,7 +1004,11 @@ static struct file_operations dvbdev_looped_fops = { .write = dvblb_write, .poll = dvblb_poll, .mmap = dvblb_mmap, +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38) + .unlocked_ioctl = dvblb_ioctl, +#else .ioctl = dvblb_ioctl, +#endif }; static struct dvb_device dvbdev_looped = { @@ -998,7 +1028,11 @@ static struct file_operations dvbdev_userspace_fops = { .write = dvblb_write, .poll = dvblb_poll, .mmap = dvblb_mmap, +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38) + .unlocked_ioctl = dvblb_ioctl, +#else .ioctl = dvblb_ioctl, +#endif }; static struct dvb_device dvbdev_userspace = { diff --git a/contrib/sasc-ng/dvbloopback/module/dvblb_forward.c b/contrib/sasc-ng/dvbloopback/module/dvblb_forward.c index dcb4107..6549208 100644 --- a/contrib/sasc-ng/dvbloopback/module/dvblb_forward.c +++ b/contrib/sasc-ng/dvbloopback/module/dvblb_forward.c @@ -166,9 +166,15 @@ int dvblb_forward_ioctl(struct dvblb_devinfo *lbdev, struct file *f, struct file *ftmp = find_forwardmap(lbdev, f->private_data); if (!ftmp || IS_ERR(ftmp)) return -EFAULT; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38) + if (lbdev->forward_dev->fops &&lbdev->forward_dev->fops->unlocked_ioctl) + return lbdev->forward_dev->fops->unlocked_ioctl( + ftmp, cmd, arg); +#else if (lbdev->forward_dev->fops &&lbdev->forward_dev->fops->ioctl) return lbdev->forward_dev->fops->ioctl( ftmp->f_dentry->d_inode, ftmp, cmd, arg); +#endif return -EFAULT; } -- 2.39.5