--- drivers/dahdi/dahdi-base.c.orig 2011-01-12 15:38:44.000000000 +0200 +++ drivers/dahdi/dahdi-base.c 2011-01-12 20:35:47.000000000 +0200 @@ -49,7 +49,7 @@ #include #ifdef HAVE_UNLOCKED_IOCTL -#include +#include #endif #include @@ -384,6 +384,10 @@ static spinlock_t bigzaplock = SPIN_LOCK_UNLOCKED; #endif +#ifdef HAVE_UNLOCKED_IOCTL +static struct mutex dahdiioctllock; +#endif + struct dahdi_zone { atomic_t refcount; char name[40]; /* Informational, only */ @@ -5838,12 +5842,7 @@ return 0; } -#ifdef HAVE_UNLOCKED_IOCTL -static long dahdi_ioctl(struct file *file, unsigned int cmd, unsigned long data) -#else -static int dahdi_ioctl(struct inode *inode, struct file *file, - unsigned int cmd, unsigned long data) -#endif +static long dahdi_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long data) { int unit = UNIT(file); struct dahdi_chan *chan; @@ -5851,7 +5850,7 @@ int ret; #ifdef HAVE_UNLOCKED_IOCTL - lock_kernel(); + mutex_lock(&dahdiioctllock); #endif if (!unit) { @@ -5897,11 +5896,19 @@ unlock_exit: #ifdef HAVE_UNLOCKED_IOCTL - unlock_kernel(); + mutex_unlock(&dahdiioctllock); #endif return ret; } +#ifndef HAVE_UNLOCKED_IOCTL +static int dahdi_ioctl(struct inode *inode, struct file *file, + unsigned int cmd, unsigned long data) +{ + return dahdi_unlocked_ioctl(file, cmd, data); +} +#endif + #ifdef HAVE_COMPAT_IOCTL static long dahdi_ioctl_compat(struct file *file, unsigned int cmd, unsigned long data) @@ -5909,7 +5916,7 @@ if (cmd == DAHDI_SFCONFIG) return -ENOTTY; /* Not supported yet */ - return dahdi_ioctl(file, cmd, data); + return dahdi_unlocked_ioctl(file, cmd, data); } #endif @@ -8603,7 +8610,7 @@ .open = dahdi_open, .release = dahdi_release, #ifdef HAVE_UNLOCKED_IOCTL - .unlocked_ioctl = dahdi_ioctl, + .unlocked_ioctl = dahdi_unlocked_ioctl, #ifdef HAVE_COMPAT_IOCTL .compat_ioctl = dahdi_ioctl_compat, #endif