Commit 76a64921 authored by Arnd Bergmann's avatar Arnd Bergmann Committed by David S. Miller

isdn: autoconvert trivial BKL users to private mutex

All these files use the big kernel lock in a trivial
way to serialize their private file operations,
typically resulting from an earlier semi-automatic
pushdown from VFS.

None of these drivers appears to want to lock against
other code, and they all use the BKL as the top-level
lock in their file operations, meaning that there
is no lock-order inversion problem.

Consequently, we can remove the BKL completely,
replacing it with a per-file mutex in every case.
Using a scripted approach means we can avoid
typos.

file=$1
name=$2
if grep -q lock_kernel ${file} ; then
    if grep -q 'include.*linux.mutex.h' ${file} ; then
            sed -i '/include.*<linux\/smp_lock.h>/d' ${file}
    else
            sed -i 's/include.*<linux\/smp_lock.h>.*$/include <linux\/mutex.h>/g' ${file}
    fi
    sed -i ${file} \
        -e "/^#include.*linux.mutex.h/,$ {
                1,/^\(static\|int\|long\)/ {
                     /^\(static\|int\|long\)/istatic DEFINE_MUTEX(${name}_mutex);

} }"  \
    -e "s/\(un\)*lock_kernel\>[ ]*()/mutex_\1lock(\&${name}_mutex)/g" \
    -e '/[      ]*cycle_kernel_lock();/d'
else
    sed -i -e '/include.*\<smp_lock.h\>/d' ${file}  \
                -e '/cycle_kernel_lock()/d'
fi
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Cc: Karsten Keil <isdn@linux-pingi.de>
Cc: netdev@vger.kernel.org
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d361fd59
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
#include <linux/signal.h> #include <linux/signal.h>
#include <linux/mutex.h> #include <linux/mutex.h>
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/smp_lock.h>
#include <linux/timer.h> #include <linux/timer.h>
#include <linux/wait.h> #include <linux/wait.h>
#include <linux/tty.h> #include <linux/tty.h>
...@@ -50,6 +49,7 @@ MODULE_LICENSE("GPL"); ...@@ -50,6 +49,7 @@ MODULE_LICENSE("GPL");
/* -------- driver information -------------------------------------- */ /* -------- driver information -------------------------------------- */
static DEFINE_MUTEX(capi_mutex);
static struct class *capi_class; static struct class *capi_class;
static int capi_major = 68; /* allocated */ static int capi_major = 68; /* allocated */
...@@ -985,9 +985,9 @@ capi_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ...@@ -985,9 +985,9 @@ capi_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{ {
int ret; int ret;
lock_kernel(); mutex_lock(&capi_mutex);
ret = capi_ioctl(file, cmd, arg); ret = capi_ioctl(file, cmd, arg);
unlock_kernel(); mutex_unlock(&capi_mutex);
return ret; return ret;
} }
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/isdnif.h> #include <linux/isdnif.h>
#include <net/net_namespace.h> #include <net/net_namespace.h>
#include <linux/smp_lock.h> #include <linux/mutex.h>
#include "isdn_divert.h" #include "isdn_divert.h"
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
/* Variables for interface queue */ /* Variables for interface queue */
/*********************************/ /*********************************/
ulong if_used = 0; /* number of interface users */ ulong if_used = 0; /* number of interface users */
static DEFINE_MUTEX(isdn_divert_mutex);
static struct divert_info *divert_info_head = NULL; /* head of queue */ static struct divert_info *divert_info_head = NULL; /* head of queue */
static struct divert_info *divert_info_tail = NULL; /* pointer to last entry */ static struct divert_info *divert_info_tail = NULL; /* pointer to last entry */
static DEFINE_SPINLOCK(divert_info_lock);/* lock for queue */ static DEFINE_SPINLOCK(divert_info_lock);/* lock for queue */
...@@ -261,9 +262,9 @@ static long isdn_divert_ioctl(struct file *file, uint cmd, ulong arg) ...@@ -261,9 +262,9 @@ static long isdn_divert_ioctl(struct file *file, uint cmd, ulong arg)
{ {
long ret; long ret;
lock_kernel(); mutex_lock(&isdn_divert_mutex);
ret = isdn_divert_ioctl_unlocked(file, cmd, arg); ret = isdn_divert_ioctl_unlocked(file, cmd, arg);
unlock_kernel(); mutex_unlock(&isdn_divert_mutex);
return ret; return ret;
} }
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
#include <linux/init.h> #include <linux/init.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/poll.h> #include <linux/poll.h>
#include <linux/smp_lock.h> #include <linux/mutex.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include "platform.h" #include "platform.h"
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "divasync.h" #include "divasync.h"
#include "debug_if.h" #include "debug_if.h"
static DEFINE_MUTEX(maint_mutex);
static char *main_revision = "$Revision: 1.32.6.10 $"; static char *main_revision = "$Revision: 1.32.6.10 $";
static int major; static int major;
...@@ -130,7 +131,7 @@ static int maint_open(struct inode *ino, struct file *filep) ...@@ -130,7 +131,7 @@ static int maint_open(struct inode *ino, struct file *filep)
{ {
int ret; int ret;
lock_kernel(); mutex_lock(&maint_mutex);
/* only one open is allowed, so we test /* only one open is allowed, so we test
it atomically */ it atomically */
if (test_and_set_bit(0, &opened)) if (test_and_set_bit(0, &opened))
...@@ -139,7 +140,7 @@ static int maint_open(struct inode *ino, struct file *filep) ...@@ -139,7 +140,7 @@ static int maint_open(struct inode *ino, struct file *filep)
filep->private_data = NULL; filep->private_data = NULL;
ret = nonseekable_open(ino, filep); ret = nonseekable_open(ino, filep);
} }
unlock_kernel(); mutex_unlock(&maint_mutex);
return ret; return ret;
} }
......
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
#include <linux/proc_fs.h> #include <linux/proc_fs.h>
#include <linux/skbuff.h> #include <linux/skbuff.h>
#include <linux/seq_file.h> #include <linux/seq_file.h>
#include <linux/smp_lock.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include "platform.h" #include "platform.h"
...@@ -402,7 +401,6 @@ static unsigned int um_idi_poll(struct file *file, poll_table * wait) ...@@ -402,7 +401,6 @@ static unsigned int um_idi_poll(struct file *file, poll_table * wait)
static int um_idi_open(struct inode *inode, struct file *file) static int um_idi_open(struct inode *inode, struct file *file)
{ {
cycle_kernel_lock();
return (0); return (0);
} }
......
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
#include <linux/list.h> #include <linux/list.h>
#include <linux/poll.h> #include <linux/poll.h>
#include <linux/kmod.h> #include <linux/kmod.h>
#include <linux/smp_lock.h>
#include "platform.h" #include "platform.h"
#undef ID_MASK #undef ID_MASK
...@@ -581,7 +580,6 @@ xdi_copy_from_user(void *os_handle, void *dst, const void __user *src, int lengt ...@@ -581,7 +580,6 @@ xdi_copy_from_user(void *os_handle, void *dst, const void __user *src, int lengt
*/ */
static int divas_open(struct inode *inode, struct file *file) static int divas_open(struct inode *inode, struct file *file)
{ {
cycle_kernel_lock();
return (0); return (0);
} }
......
...@@ -17,11 +17,12 @@ ...@@ -17,11 +17,12 @@
#include <linux/proc_fs.h> #include <linux/proc_fs.h>
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/smp_lock.h> #include <linux/mutex.h>
#include <net/net_namespace.h> #include <net/net_namespace.h>
#include "hysdn_defs.h" #include "hysdn_defs.h"
static DEFINE_MUTEX(hysdn_conf_mutex);
static char *hysdn_procconf_revision = "$Revision: 1.8.6.4 $"; static char *hysdn_procconf_revision = "$Revision: 1.8.6.4 $";
#define INFO_OUT_LEN 80 /* length of info line including lf */ #define INFO_OUT_LEN 80 /* length of info line including lf */
...@@ -234,7 +235,7 @@ hysdn_conf_open(struct inode *ino, struct file *filep) ...@@ -234,7 +235,7 @@ hysdn_conf_open(struct inode *ino, struct file *filep)
char *cp, *tmp; char *cp, *tmp;
/* now search the addressed card */ /* now search the addressed card */
lock_kernel(); mutex_lock(&hysdn_conf_mutex);
card = card_root; card = card_root;
while (card) { while (card) {
pd = card->procconf; pd = card->procconf;
...@@ -243,7 +244,7 @@ hysdn_conf_open(struct inode *ino, struct file *filep) ...@@ -243,7 +244,7 @@ hysdn_conf_open(struct inode *ino, struct file *filep)
card = card->next; /* search next entry */ card = card->next; /* search next entry */
} }
if (!card) { if (!card) {
unlock_kernel(); mutex_unlock(&hysdn_conf_mutex);
return (-ENODEV); /* device is unknown/invalid */ return (-ENODEV); /* device is unknown/invalid */
} }
if (card->debug_flags & (LOG_PROC_OPEN | LOG_PROC_ALL)) if (card->debug_flags & (LOG_PROC_OPEN | LOG_PROC_ALL))
...@@ -255,7 +256,7 @@ hysdn_conf_open(struct inode *ino, struct file *filep) ...@@ -255,7 +256,7 @@ hysdn_conf_open(struct inode *ino, struct file *filep)
/* write only access -> write boot file or conf line */ /* write only access -> write boot file or conf line */
if (!(cnf = kmalloc(sizeof(struct conf_writedata), GFP_KERNEL))) { if (!(cnf = kmalloc(sizeof(struct conf_writedata), GFP_KERNEL))) {
unlock_kernel(); mutex_unlock(&hysdn_conf_mutex);
return (-EFAULT); return (-EFAULT);
} }
cnf->card = card; cnf->card = card;
...@@ -267,7 +268,7 @@ hysdn_conf_open(struct inode *ino, struct file *filep) ...@@ -267,7 +268,7 @@ hysdn_conf_open(struct inode *ino, struct file *filep)
/* read access -> output card info data */ /* read access -> output card info data */
if (!(tmp = kmalloc(INFO_OUT_LEN * 2 + 2, GFP_KERNEL))) { if (!(tmp = kmalloc(INFO_OUT_LEN * 2 + 2, GFP_KERNEL))) {
unlock_kernel(); mutex_unlock(&hysdn_conf_mutex);
return (-EFAULT); /* out of memory */ return (-EFAULT); /* out of memory */
} }
filep->private_data = tmp; /* start of string */ filep->private_data = tmp; /* start of string */
...@@ -301,10 +302,10 @@ hysdn_conf_open(struct inode *ino, struct file *filep) ...@@ -301,10 +302,10 @@ hysdn_conf_open(struct inode *ino, struct file *filep)
*cp++ = '\n'; *cp++ = '\n';
*cp = 0; /* end of string */ *cp = 0; /* end of string */
} else { /* simultaneous read/write access forbidden ! */ } else { /* simultaneous read/write access forbidden ! */
unlock_kernel(); mutex_unlock(&hysdn_conf_mutex);
return (-EPERM); /* no permission this time */ return (-EPERM); /* no permission this time */
} }
unlock_kernel(); mutex_unlock(&hysdn_conf_mutex);
return nonseekable_open(ino, filep); return nonseekable_open(ino, filep);
} /* hysdn_conf_open */ } /* hysdn_conf_open */
...@@ -319,7 +320,7 @@ hysdn_conf_close(struct inode *ino, struct file *filep) ...@@ -319,7 +320,7 @@ hysdn_conf_close(struct inode *ino, struct file *filep)
int retval = 0; int retval = 0;
struct proc_dir_entry *pd; struct proc_dir_entry *pd;
lock_kernel(); mutex_lock(&hysdn_conf_mutex);
/* search the addressed card */ /* search the addressed card */
card = card_root; card = card_root;
while (card) { while (card) {
...@@ -329,7 +330,7 @@ hysdn_conf_close(struct inode *ino, struct file *filep) ...@@ -329,7 +330,7 @@ hysdn_conf_close(struct inode *ino, struct file *filep)
card = card->next; /* search next entry */ card = card->next; /* search next entry */
} }
if (!card) { if (!card) {
unlock_kernel(); mutex_unlock(&hysdn_conf_mutex);
return (-ENODEV); /* device is unknown/invalid */ return (-ENODEV); /* device is unknown/invalid */
} }
if (card->debug_flags & (LOG_PROC_OPEN | LOG_PROC_ALL)) if (card->debug_flags & (LOG_PROC_OPEN | LOG_PROC_ALL))
...@@ -352,7 +353,7 @@ hysdn_conf_close(struct inode *ino, struct file *filep) ...@@ -352,7 +353,7 @@ hysdn_conf_close(struct inode *ino, struct file *filep)
kfree(filep->private_data); /* release memory */ kfree(filep->private_data); /* release memory */
} }
unlock_kernel(); mutex_unlock(&hysdn_conf_mutex);
return (retval); return (retval);
} /* hysdn_conf_close */ } /* hysdn_conf_close */
......
...@@ -15,13 +15,14 @@ ...@@ -15,13 +15,14 @@
#include <linux/proc_fs.h> #include <linux/proc_fs.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/smp_lock.h> #include <linux/mutex.h>
#include "hysdn_defs.h" #include "hysdn_defs.h"
/* the proc subdir for the interface is defined in the procconf module */ /* the proc subdir for the interface is defined in the procconf module */
extern struct proc_dir_entry *hysdn_proc_entry; extern struct proc_dir_entry *hysdn_proc_entry;
static DEFINE_MUTEX(hysdn_log_mutex);
static void put_log_buffer(hysdn_card * card, char *cp); static void put_log_buffer(hysdn_card * card, char *cp);
/*************************************************/ /*************************************************/
...@@ -251,7 +252,7 @@ hysdn_log_open(struct inode *ino, struct file *filep) ...@@ -251,7 +252,7 @@ hysdn_log_open(struct inode *ino, struct file *filep)
struct procdata *pd = NULL; struct procdata *pd = NULL;
unsigned long flags; unsigned long flags;
lock_kernel(); mutex_lock(&hysdn_log_mutex);
card = card_root; card = card_root;
while (card) { while (card) {
pd = card->proclog; pd = card->proclog;
...@@ -260,7 +261,7 @@ hysdn_log_open(struct inode *ino, struct file *filep) ...@@ -260,7 +261,7 @@ hysdn_log_open(struct inode *ino, struct file *filep)
card = card->next; /* search next entry */ card = card->next; /* search next entry */
} }
if (!card) { if (!card) {
unlock_kernel(); mutex_unlock(&hysdn_log_mutex);
return (-ENODEV); /* device is unknown/invalid */ return (-ENODEV); /* device is unknown/invalid */
} }
filep->private_data = card; /* remember our own card */ filep->private_data = card; /* remember our own card */
...@@ -278,10 +279,10 @@ hysdn_log_open(struct inode *ino, struct file *filep) ...@@ -278,10 +279,10 @@ hysdn_log_open(struct inode *ino, struct file *filep)
filep->private_data = &pd->log_head; filep->private_data = &pd->log_head;
spin_unlock_irqrestore(&card->hysdn_lock, flags); spin_unlock_irqrestore(&card->hysdn_lock, flags);
} else { /* simultaneous read/write access forbidden ! */ } else { /* simultaneous read/write access forbidden ! */
unlock_kernel(); mutex_unlock(&hysdn_log_mutex);
return (-EPERM); /* no permission this time */ return (-EPERM); /* no permission this time */
} }
unlock_kernel(); mutex_unlock(&hysdn_log_mutex);
return nonseekable_open(ino, filep); return nonseekable_open(ino, filep);
} /* hysdn_log_open */ } /* hysdn_log_open */
...@@ -300,7 +301,7 @@ hysdn_log_close(struct inode *ino, struct file *filep) ...@@ -300,7 +301,7 @@ hysdn_log_close(struct inode *ino, struct file *filep)
hysdn_card *card; hysdn_card *card;
int retval = 0; int retval = 0;
lock_kernel(); mutex_lock(&hysdn_log_mutex);
if ((filep->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_WRITE) { if ((filep->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_WRITE) {
/* write only access -> write debug level written */ /* write only access -> write debug level written */
retval = 0; /* success */ retval = 0; /* success */
...@@ -339,7 +340,7 @@ hysdn_log_close(struct inode *ino, struct file *filep) ...@@ -339,7 +340,7 @@ hysdn_log_close(struct inode *ino, struct file *filep)
kfree(inf); kfree(inf);
} }
} /* read access */ } /* read access */
unlock_kernel(); mutex_unlock(&hysdn_log_mutex);
return (retval); return (retval);
} /* hysdn_log_close */ } /* hysdn_log_close */
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/vmalloc.h> #include <linux/vmalloc.h>
#include <linux/isdn.h> #include <linux/isdn.h>
#include <linux/smp_lock.h> #include <linux/mutex.h>
#include "isdn_common.h" #include "isdn_common.h"
#include "isdn_tty.h" #include "isdn_tty.h"
#include "isdn_net.h" #include "isdn_net.h"
...@@ -42,6 +42,7 @@ MODULE_LICENSE("GPL"); ...@@ -42,6 +42,7 @@ MODULE_LICENSE("GPL");
isdn_dev *dev; isdn_dev *dev;
static DEFINE_MUTEX(isdn_mutex);
static char *isdn_revision = "$Revision: 1.1.2.3 $"; static char *isdn_revision = "$Revision: 1.1.2.3 $";
extern char *isdn_net_revision; extern char *isdn_net_revision;
...@@ -1070,7 +1071,7 @@ isdn_read(struct file *file, char __user *buf, size_t count, loff_t * off) ...@@ -1070,7 +1071,7 @@ isdn_read(struct file *file, char __user *buf, size_t count, loff_t * off)
int retval; int retval;
char *p; char *p;
lock_kernel(); mutex_lock(&isdn_mutex);
if (minor == ISDN_MINOR_STATUS) { if (minor == ISDN_MINOR_STATUS) {
if (!file->private_data) { if (!file->private_data) {
if (file->f_flags & O_NONBLOCK) { if (file->f_flags & O_NONBLOCK) {
...@@ -1163,7 +1164,7 @@ isdn_read(struct file *file, char __user *buf, size_t count, loff_t * off) ...@@ -1163,7 +1164,7 @@ isdn_read(struct file *file, char __user *buf, size_t count, loff_t * off)
#endif #endif
retval = -ENODEV; retval = -ENODEV;
out: out:
unlock_kernel(); mutex_unlock(&isdn_mutex);
return retval; return retval;
} }
...@@ -1180,7 +1181,7 @@ isdn_write(struct file *file, const char __user *buf, size_t count, loff_t * off ...@@ -1180,7 +1181,7 @@ isdn_write(struct file *file, const char __user *buf, size_t count, loff_t * off
if (!dev->drivers) if (!dev->drivers)
return -ENODEV; return -ENODEV;
lock_kernel(); mutex_lock(&isdn_mutex);
if (minor <= ISDN_MINOR_BMAX) { if (minor <= ISDN_MINOR_BMAX) {
printk(KERN_WARNING "isdn_write minor %d obsolete!\n", minor); printk(KERN_WARNING "isdn_write minor %d obsolete!\n", minor);
drvidx = isdn_minor2drv(minor); drvidx = isdn_minor2drv(minor);
...@@ -1225,7 +1226,7 @@ isdn_write(struct file *file, const char __user *buf, size_t count, loff_t * off ...@@ -1225,7 +1226,7 @@ isdn_write(struct file *file, const char __user *buf, size_t count, loff_t * off
#endif #endif
retval = -ENODEV; retval = -ENODEV;
out: out:
unlock_kernel(); mutex_unlock(&isdn_mutex);
return retval; return retval;
} }
...@@ -1236,7 +1237,7 @@ isdn_poll(struct file *file, poll_table * wait) ...@@ -1236,7 +1237,7 @@ isdn_poll(struct file *file, poll_table * wait)
unsigned int minor = iminor(file->f_path.dentry->d_inode); unsigned int minor = iminor(file->f_path.dentry->d_inode);
int drvidx = isdn_minor2drv(minor - ISDN_MINOR_CTRL); int drvidx = isdn_minor2drv(minor - ISDN_MINOR_CTRL);
lock_kernel(); mutex_lock(&isdn_mutex);
if (minor == ISDN_MINOR_STATUS) { if (minor == ISDN_MINOR_STATUS) {
poll_wait(file, &(dev->info_waitq), wait); poll_wait(file, &(dev->info_waitq), wait);
/* mask = POLLOUT | POLLWRNORM; */ /* mask = POLLOUT | POLLWRNORM; */
...@@ -1266,7 +1267,7 @@ isdn_poll(struct file *file, poll_table * wait) ...@@ -1266,7 +1267,7 @@ isdn_poll(struct file *file, poll_table * wait)
#endif #endif
mask = POLLERR; mask = POLLERR;
out: out:
unlock_kernel(); mutex_unlock(&isdn_mutex);
return mask; return mask;
} }
...@@ -1727,9 +1728,9 @@ isdn_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ...@@ -1727,9 +1728,9 @@ isdn_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{ {
int ret; int ret;
lock_kernel(); mutex_lock(&isdn_mutex);
ret = isdn_ioctl(file, cmd, arg); ret = isdn_ioctl(file, cmd, arg);
unlock_kernel(); mutex_unlock(&isdn_mutex);
return ret; return ret;
} }
...@@ -1745,7 +1746,7 @@ isdn_open(struct inode *ino, struct file *filep) ...@@ -1745,7 +1746,7 @@ isdn_open(struct inode *ino, struct file *filep)
int chidx; int chidx;
int retval = -ENODEV; int retval = -ENODEV;
lock_kernel(); mutex_lock(&isdn_mutex);
if (minor == ISDN_MINOR_STATUS) { if (minor == ISDN_MINOR_STATUS) {
infostruct *p; infostruct *p;
...@@ -1796,7 +1797,7 @@ isdn_open(struct inode *ino, struct file *filep) ...@@ -1796,7 +1797,7 @@ isdn_open(struct inode *ino, struct file *filep)
#endif #endif
out: out:
nonseekable_open(ino, filep); nonseekable_open(ino, filep);
unlock_kernel(); mutex_unlock(&isdn_mutex);
return retval; return retval;
} }
...@@ -1805,7 +1806,7 @@ isdn_close(struct inode *ino, struct file *filep) ...@@ -1805,7 +1806,7 @@ isdn_close(struct inode *ino, struct file *filep)
{ {
uint minor = iminor(ino); uint minor = iminor(ino);
lock_kernel(); mutex_lock(&isdn_mutex);
if (minor == ISDN_MINOR_STATUS) { if (minor == ISDN_MINOR_STATUS) {
infostruct *p = dev->infochain; infostruct *p = dev->infochain;
infostruct *q = NULL; infostruct *q = NULL;
...@@ -1839,7 +1840,7 @@ isdn_close(struct inode *ino, struct file *filep) ...@@ -1839,7 +1840,7 @@ isdn_close(struct inode *ino, struct file *filep)
#endif #endif
out: out:
unlock_kernel(); mutex_unlock(&isdn_mutex);
return 0; return 0;
} }
......
...@@ -24,9 +24,10 @@ ...@@ -24,9 +24,10 @@
#include <linux/miscdevice.h> #include <linux/miscdevice.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/mISDNif.h> #include <linux/mISDNif.h>
#include <linux/smp_lock.h> #include <linux/mutex.h>
#include "core.h" #include "core.h"
static DEFINE_MUTEX(mISDN_mutex);
static u_int *debug; static u_int *debug;
...@@ -224,7 +225,7 @@ mISDN_ioctl(struct file *filep, unsigned int cmd, unsigned long arg) ...@@ -224,7 +225,7 @@ mISDN_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
if (*debug & DEBUG_TIMER) if (*debug & DEBUG_TIMER)
printk(KERN_DEBUG "%s(%p, %x, %lx)\n", __func__, printk(KERN_DEBUG "%s(%p, %x, %lx)\n", __func__,
filep, cmd, arg); filep, cmd, arg);
lock_kernel(); mutex_lock(&mISDN_mutex);
switch (cmd) { switch (cmd) {
case IMADDTIMER: case IMADDTIMER:
if (get_user(tout, (int __user *)arg)) { if (get_user(tout, (int __user *)arg)) {
...@@ -256,7 +257,7 @@ mISDN_ioctl(struct file *filep, unsigned int cmd, unsigned long arg) ...@@ -256,7 +257,7 @@ mISDN_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
default: default:
ret = -EINVAL; ret = -EINVAL;
} }
unlock_kernel(); mutex_unlock(&mISDN_mutex);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment