--- em8300-0.18.0/modules/em8300_main.c 2009-12-21 00:24:56.000000000 +0200 +++ em8300-0.18.0-n/modules/em8300_main.c 2011-01-14 17:24:18.798732449 +0200 @@ -51,6 +51,11 @@ #include <linux/i2c.h> #include <linux/i2c-algo-bit.h> +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36) +/* for lock_kernel() */ +#include <linux/smp_lock.h> +#endif + #include "em8300_compat24.h" #include "encoder.h" @@ -211,6 +216,20 @@ return -EINVAL; } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36) +static long em8300_io_ioctl_unlocked(struct file *filp, unsigned int cmd, unsigned long arg) +{ + int err; + + /* TODO: convert to a private lock, or remove BKL if unnecessary */ + lock_kernel(); + err = em8300_io_ioctl(filp->f_dentry->d_inode, filp, cmd, arg); + unlock_kernel(); + + return err; +} +#endif + static int em8300_io_open(struct inode *inode, struct file *filp) { int card = EM8300_IMINOR(inode) / 4; @@ -481,7 +500,11 @@ struct file_operations em8300_fops = { .owner = THIS_MODULE, .write = em8300_io_write, +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36) + .unlocked_ioctl = em8300_io_ioctl_unlocked, +#else .ioctl = em8300_io_ioctl, +#endif .mmap = em8300_io_mmap, .poll = em8300_poll, .open = em8300_io_open, @@ -498,6 +521,20 @@ return em8300_audio_ioctl(em, cmd, arg); } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36) +static long em8300_dsp_ioctl_unlocked(struct file *filp, unsigned int cmd, unsigned long arg) +{ + int err; + + /* TODO: convert to a private lock, or remove BKL if unnecessary */ + lock_kernel(); + err = em8300_dsp_ioctl(filp->f_dentry->d_inode, filp, cmd, arg); + unlock_kernel(); + + return err; +} +#endif + static int em8300_dsp_open(struct inode *inode, struct file *filp) { int dsp_number = ((EM8300_IMINOR(inode) >> 4) & 0x0f); @@ -584,7 +621,11 @@ static struct file_operations em8300_dsp_audio_fops = { .owner = THIS_MODULE, .write = em8300_dsp_write, +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36) + .unlocked_ioctl = em8300_dsp_ioctl_unlocked, +#else .ioctl = em8300_dsp_ioctl, +#endif .poll = em8300_dsp_poll, .open = em8300_dsp_open, .release = em8300_dsp_release, --- em8300-0.18.0/modules/em8300_ioctl32.c 2009-12-21 00:24:55.000000000 +0200 +++ em8300-0.18.0-n/modules/em8300_ioctl32.c 2011-01-14 18:01:41.054562875 +0200 @@ -76,8 +76,8 @@ if (!err) { set_fs(KERNEL_DS); - err = filp->f_op->ioctl(filp->f_dentry->d_inode, filp, - EM8300_IOCTL_INIT, (unsigned long)&karg); + err = filp->f_op->unlocked_ioctl(filp, + EM8300_IOCTL_INIT, (unsigned long)&karg); set_fs(old_fs); kfree(karg.ucode); @@ -94,7 +94,7 @@ case EM8300_IOCTL32_INIT: return em8300_do_ioctl32_init(arg, filp); default: - return filp->f_op->ioctl(filp->f_dentry->d_inode, filp, cmd, arg); + return filp->f_op->unlocked_ioctl(filp, cmd, arg); } } @@ -108,7 +108,7 @@ if (cmd==EM8300_IOCTL32_INIT) { return em8300_do_ioctl32_init(arg, filp); } else { - return filp->f_op->ioctl(filp->f_dentry->d_inode, filp, cmd, arg); + return filp->f_op->unlocked_ioctl(filp, cmd, arg); } }