diff options
author | Arnd Bergmann <arnd@arndb.de> | 2010-07-11 07:18:53 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-07-12 23:21:47 -0400 |
commit | 76a64921dad9acd76270dc74249f0dfe11c84bb8 (patch) | |
tree | 42eaa62b3c886e46b29bbae354fe87bf8475d970 /drivers/isdn | |
parent | d361fd599a991ff6c1d522a599c635b35d61ef30 (diff) |
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: Arnd Bergmann <arnd@arndb.de>
Cc: Karsten Keil <isdn@linux-pingi.de>
Cc: netdev@vger.kernel.org
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/isdn')
-rw-r--r-- | drivers/isdn/capi/capi.c | 6 | ||||
-rw-r--r-- | drivers/isdn/divert/divert_procfs.c | 7 | ||||
-rw-r--r-- | drivers/isdn/hardware/eicon/divamnt.c | 7 | ||||
-rw-r--r-- | drivers/isdn/hardware/eicon/divasi.c | 2 | ||||
-rw-r--r-- | drivers/isdn/hardware/eicon/divasmain.c | 2 | ||||
-rw-r--r-- | drivers/isdn/hysdn/hysdn_procconf.c | 21 | ||||
-rw-r--r-- | drivers/isdn/hysdn/hysdn_proclog.c | 15 | ||||
-rw-r--r-- | drivers/isdn/i4l/isdn_common.c | 27 | ||||
-rw-r--r-- | drivers/isdn/mISDN/timerdev.c | 7 |
9 files changed, 48 insertions, 46 deletions
diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c index 0cabe31f26df..b0a4a691cbaa 100644 --- a/drivers/isdn/capi/capi.c +++ b/drivers/isdn/capi/capi.c | |||
@@ -20,7 +20,6 @@ | |||
20 | #include <linux/signal.h> | 20 | #include <linux/signal.h> |
21 | #include <linux/mutex.h> | 21 | #include <linux/mutex.h> |
22 | #include <linux/mm.h> | 22 | #include <linux/mm.h> |
23 | #include <linux/smp_lock.h> | ||
24 | #include <linux/timer.h> | 23 | #include <linux/timer.h> |
25 | #include <linux/wait.h> | 24 | #include <linux/wait.h> |
26 | #include <linux/tty.h> | 25 | #include <linux/tty.h> |
@@ -50,6 +49,7 @@ MODULE_LICENSE("GPL"); | |||
50 | 49 | ||
51 | /* -------- driver information -------------------------------------- */ | 50 | /* -------- driver information -------------------------------------- */ |
52 | 51 | ||
52 | static DEFINE_MUTEX(capi_mutex); | ||
53 | static struct class *capi_class; | 53 | static struct class *capi_class; |
54 | static int capi_major = 68; /* allocated */ | 54 | static int capi_major = 68; /* allocated */ |
55 | 55 | ||
@@ -985,9 +985,9 @@ capi_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
985 | { | 985 | { |
986 | int ret; | 986 | int ret; |
987 | 987 | ||
988 | lock_kernel(); | 988 | mutex_lock(&capi_mutex); |
989 | ret = capi_ioctl(file, cmd, arg); | 989 | ret = capi_ioctl(file, cmd, arg); |
990 | unlock_kernel(); | 990 | mutex_unlock(&capi_mutex); |
991 | 991 | ||
992 | return ret; | 992 | return ret; |
993 | } | 993 | } |
diff --git a/drivers/isdn/divert/divert_procfs.c b/drivers/isdn/divert/divert_procfs.c index c53e2417e7d4..33ec9e467772 100644 --- a/drivers/isdn/divert/divert_procfs.c +++ b/drivers/isdn/divert/divert_procfs.c | |||
@@ -20,7 +20,7 @@ | |||
20 | #include <linux/sched.h> | 20 | #include <linux/sched.h> |
21 | #include <linux/isdnif.h> | 21 | #include <linux/isdnif.h> |
22 | #include <net/net_namespace.h> | 22 | #include <net/net_namespace.h> |
23 | #include <linux/smp_lock.h> | 23 | #include <linux/mutex.h> |
24 | #include "isdn_divert.h" | 24 | #include "isdn_divert.h" |
25 | 25 | ||
26 | 26 | ||
@@ -28,6 +28,7 @@ | |||
28 | /* Variables for interface queue */ | 28 | /* Variables for interface queue */ |
29 | /*********************************/ | 29 | /*********************************/ |
30 | ulong if_used = 0; /* number of interface users */ | 30 | ulong if_used = 0; /* number of interface users */ |
31 | static DEFINE_MUTEX(isdn_divert_mutex); | ||
31 | static struct divert_info *divert_info_head = NULL; /* head of queue */ | 32 | static struct divert_info *divert_info_head = NULL; /* head of queue */ |
32 | static struct divert_info *divert_info_tail = NULL; /* pointer to last entry */ | 33 | static struct divert_info *divert_info_tail = NULL; /* pointer to last entry */ |
33 | static DEFINE_SPINLOCK(divert_info_lock);/* lock for queue */ | 34 | 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 | { | 262 | { |
262 | long ret; | 263 | long ret; |
263 | 264 | ||
264 | lock_kernel(); | 265 | mutex_lock(&isdn_divert_mutex); |
265 | ret = isdn_divert_ioctl_unlocked(file, cmd, arg); | 266 | ret = isdn_divert_ioctl_unlocked(file, cmd, arg); |
266 | unlock_kernel(); | 267 | mutex_unlock(&isdn_divert_mutex); |
267 | 268 | ||
268 | return ret; | 269 | return ret; |
269 | } | 270 | } |
diff --git a/drivers/isdn/hardware/eicon/divamnt.c b/drivers/isdn/hardware/eicon/divamnt.c index 1e85f743214e..f1d464f1e107 100644 --- a/drivers/isdn/hardware/eicon/divamnt.c +++ b/drivers/isdn/hardware/eicon/divamnt.c | |||
@@ -14,7 +14,7 @@ | |||
14 | #include <linux/init.h> | 14 | #include <linux/init.h> |
15 | #include <linux/kernel.h> | 15 | #include <linux/kernel.h> |
16 | #include <linux/poll.h> | 16 | #include <linux/poll.h> |
17 | #include <linux/smp_lock.h> | 17 | #include <linux/mutex.h> |
18 | #include <asm/uaccess.h> | 18 | #include <asm/uaccess.h> |
19 | 19 | ||
20 | #include "platform.h" | 20 | #include "platform.h" |
@@ -22,6 +22,7 @@ | |||
22 | #include "divasync.h" | 22 | #include "divasync.h" |
23 | #include "debug_if.h" | 23 | #include "debug_if.h" |
24 | 24 | ||
25 | static DEFINE_MUTEX(maint_mutex); | ||
25 | static char *main_revision = "$Revision: 1.32.6.10 $"; | 26 | static char *main_revision = "$Revision: 1.32.6.10 $"; |
26 | 27 | ||
27 | static int major; | 28 | static int major; |
@@ -130,7 +131,7 @@ static int maint_open(struct inode *ino, struct file *filep) | |||
130 | { | 131 | { |
131 | int ret; | 132 | int ret; |
132 | 133 | ||
133 | lock_kernel(); | 134 | mutex_lock(&maint_mutex); |
134 | /* only one open is allowed, so we test | 135 | /* only one open is allowed, so we test |
135 | it atomically */ | 136 | it atomically */ |
136 | if (test_and_set_bit(0, &opened)) | 137 | if (test_and_set_bit(0, &opened)) |
@@ -139,7 +140,7 @@ static int maint_open(struct inode *ino, struct file *filep) | |||
139 | filep->private_data = NULL; | 140 | filep->private_data = NULL; |
140 | ret = nonseekable_open(ino, filep); | 141 | ret = nonseekable_open(ino, filep); |
141 | } | 142 | } |
142 | unlock_kernel(); | 143 | mutex_unlock(&maint_mutex); |
143 | return ret; | 144 | return ret; |
144 | } | 145 | } |
145 | 146 | ||
diff --git a/drivers/isdn/hardware/eicon/divasi.c b/drivers/isdn/hardware/eicon/divasi.c index f577719ab3fa..42d3b8346034 100644 --- a/drivers/isdn/hardware/eicon/divasi.c +++ b/drivers/isdn/hardware/eicon/divasi.c | |||
@@ -18,7 +18,6 @@ | |||
18 | #include <linux/proc_fs.h> | 18 | #include <linux/proc_fs.h> |
19 | #include <linux/skbuff.h> | 19 | #include <linux/skbuff.h> |
20 | #include <linux/seq_file.h> | 20 | #include <linux/seq_file.h> |
21 | #include <linux/smp_lock.h> | ||
22 | #include <asm/uaccess.h> | 21 | #include <asm/uaccess.h> |
23 | 22 | ||
24 | #include "platform.h" | 23 | #include "platform.h" |
@@ -402,7 +401,6 @@ static unsigned int um_idi_poll(struct file *file, poll_table * wait) | |||
402 | 401 | ||
403 | static int um_idi_open(struct inode *inode, struct file *file) | 402 | static int um_idi_open(struct inode *inode, struct file *file) |
404 | { | 403 | { |
405 | cycle_kernel_lock(); | ||
406 | return (0); | 404 | return (0); |
407 | } | 405 | } |
408 | 406 | ||
diff --git a/drivers/isdn/hardware/eicon/divasmain.c b/drivers/isdn/hardware/eicon/divasmain.c index fbbcb27fb681..16a874bb1561 100644 --- a/drivers/isdn/hardware/eicon/divasmain.c +++ b/drivers/isdn/hardware/eicon/divasmain.c | |||
@@ -21,7 +21,6 @@ | |||
21 | #include <linux/list.h> | 21 | #include <linux/list.h> |
22 | #include <linux/poll.h> | 22 | #include <linux/poll.h> |
23 | #include <linux/kmod.h> | 23 | #include <linux/kmod.h> |
24 | #include <linux/smp_lock.h> | ||
25 | 24 | ||
26 | #include "platform.h" | 25 | #include "platform.h" |
27 | #undef ID_MASK | 26 | #undef ID_MASK |
@@ -581,7 +580,6 @@ xdi_copy_from_user(void *os_handle, void *dst, const void __user *src, int lengt | |||
581 | */ | 580 | */ |
582 | static int divas_open(struct inode *inode, struct file *file) | 581 | static int divas_open(struct inode *inode, struct file *file) |
583 | { | 582 | { |
584 | cycle_kernel_lock(); | ||
585 | return (0); | 583 | return (0); |
586 | } | 584 | } |
587 | 585 | ||
diff --git a/drivers/isdn/hysdn/hysdn_procconf.c b/drivers/isdn/hysdn/hysdn_procconf.c index 80966462d6dc..96b3e39c3356 100644 --- a/drivers/isdn/hysdn/hysdn_procconf.c +++ b/drivers/isdn/hysdn/hysdn_procconf.c | |||
@@ -17,11 +17,12 @@ | |||
17 | #include <linux/proc_fs.h> | 17 | #include <linux/proc_fs.h> |
18 | #include <linux/pci.h> | 18 | #include <linux/pci.h> |
19 | #include <linux/slab.h> | 19 | #include <linux/slab.h> |
20 | #include <linux/smp_lock.h> | 20 | #include <linux/mutex.h> |
21 | #include <net/net_namespace.h> | 21 | #include <net/net_namespace.h> |
22 | 22 | ||
23 | #include "hysdn_defs.h" | 23 | #include "hysdn_defs.h" |
24 | 24 | ||
25 | static DEFINE_MUTEX(hysdn_conf_mutex); | ||
25 | static char *hysdn_procconf_revision = "$Revision: 1.8.6.4 $"; | 26 | static char *hysdn_procconf_revision = "$Revision: 1.8.6.4 $"; |
26 | 27 | ||
27 | #define INFO_OUT_LEN 80 /* length of info line including lf */ | 28 | #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 | char *cp, *tmp; | 235 | char *cp, *tmp; |
235 | 236 | ||
236 | /* now search the addressed card */ | 237 | /* now search the addressed card */ |
237 | lock_kernel(); | 238 | mutex_lock(&hysdn_conf_mutex); |
238 | card = card_root; | 239 | card = card_root; |
239 | while (card) { | 240 | while (card) { |
240 | pd = card->procconf; | 241 | pd = card->procconf; |
@@ -243,7 +244,7 @@ hysdn_conf_open(struct inode *ino, struct file *filep) | |||
243 | card = card->next; /* search next entry */ | 244 | card = card->next; /* search next entry */ |
244 | } | 245 | } |
245 | if (!card) { | 246 | if (!card) { |
246 | unlock_kernel(); | 247 | mutex_unlock(&hysdn_conf_mutex); |
247 | return (-ENODEV); /* device is unknown/invalid */ | 248 | return (-ENODEV); /* device is unknown/invalid */ |
248 | } | 249 | } |
249 | if (card->debug_flags & (LOG_PROC_OPEN | LOG_PROC_ALL)) | 250 | if (card->debug_flags & (LOG_PROC_OPEN | LOG_PROC_ALL)) |
@@ -255,7 +256,7 @@ hysdn_conf_open(struct inode *ino, struct file *filep) | |||
255 | /* write only access -> write boot file or conf line */ | 256 | /* write only access -> write boot file or conf line */ |
256 | 257 | ||
257 | if (!(cnf = kmalloc(sizeof(struct conf_writedata), GFP_KERNEL))) { | 258 | if (!(cnf = kmalloc(sizeof(struct conf_writedata), GFP_KERNEL))) { |
258 | unlock_kernel(); | 259 | mutex_unlock(&hysdn_conf_mutex); |
259 | return (-EFAULT); | 260 | return (-EFAULT); |
260 | } | 261 | } |
261 | cnf->card = card; | 262 | cnf->card = card; |
@@ -267,7 +268,7 @@ hysdn_conf_open(struct inode *ino, struct file *filep) | |||
267 | /* read access -> output card info data */ | 268 | /* read access -> output card info data */ |
268 | 269 | ||
269 | if (!(tmp = kmalloc(INFO_OUT_LEN * 2 + 2, GFP_KERNEL))) { | 270 | if (!(tmp = kmalloc(INFO_OUT_LEN * 2 + 2, GFP_KERNEL))) { |
270 | unlock_kernel(); | 271 | mutex_unlock(&hysdn_conf_mutex); |
271 | return (-EFAULT); /* out of memory */ | 272 | return (-EFAULT); /* out of memory */ |
272 | } | 273 | } |
273 | filep->private_data = tmp; /* start of string */ | 274 | filep->private_data = tmp; /* start of string */ |
@@ -301,10 +302,10 @@ hysdn_conf_open(struct inode *ino, struct file *filep) | |||
301 | *cp++ = '\n'; | 302 | *cp++ = '\n'; |
302 | *cp = 0; /* end of string */ | 303 | *cp = 0; /* end of string */ |
303 | } else { /* simultaneous read/write access forbidden ! */ | 304 | } else { /* simultaneous read/write access forbidden ! */ |
304 | unlock_kernel(); | 305 | mutex_unlock(&hysdn_conf_mutex); |
305 | return (-EPERM); /* no permission this time */ | 306 | return (-EPERM); /* no permission this time */ |
306 | } | 307 | } |
307 | unlock_kernel(); | 308 | mutex_unlock(&hysdn_conf_mutex); |
308 | return nonseekable_open(ino, filep); | 309 | return nonseekable_open(ino, filep); |
309 | } /* hysdn_conf_open */ | 310 | } /* hysdn_conf_open */ |
310 | 311 | ||
@@ -319,7 +320,7 @@ hysdn_conf_close(struct inode *ino, struct file *filep) | |||
319 | int retval = 0; | 320 | int retval = 0; |
320 | struct proc_dir_entry *pd; | 321 | struct proc_dir_entry *pd; |
321 | 322 | ||
322 | lock_kernel(); | 323 | mutex_lock(&hysdn_conf_mutex); |
323 | /* search the addressed card */ | 324 | /* search the addressed card */ |
324 | card = card_root; | 325 | card = card_root; |
325 | while (card) { | 326 | while (card) { |
@@ -329,7 +330,7 @@ hysdn_conf_close(struct inode *ino, struct file *filep) | |||
329 | card = card->next; /* search next entry */ | 330 | card = card->next; /* search next entry */ |
330 | } | 331 | } |
331 | if (!card) { | 332 | if (!card) { |
332 | unlock_kernel(); | 333 | mutex_unlock(&hysdn_conf_mutex); |
333 | return (-ENODEV); /* device is unknown/invalid */ | 334 | return (-ENODEV); /* device is unknown/invalid */ |
334 | } | 335 | } |
335 | if (card->debug_flags & (LOG_PROC_OPEN | LOG_PROC_ALL)) | 336 | if (card->debug_flags & (LOG_PROC_OPEN | LOG_PROC_ALL)) |
@@ -352,7 +353,7 @@ hysdn_conf_close(struct inode *ino, struct file *filep) | |||
352 | 353 | ||
353 | kfree(filep->private_data); /* release memory */ | 354 | kfree(filep->private_data); /* release memory */ |
354 | } | 355 | } |
355 | unlock_kernel(); | 356 | mutex_unlock(&hysdn_conf_mutex); |
356 | return (retval); | 357 | return (retval); |
357 | } /* hysdn_conf_close */ | 358 | } /* hysdn_conf_close */ |
358 | 359 | ||
diff --git a/drivers/isdn/hysdn/hysdn_proclog.c b/drivers/isdn/hysdn/hysdn_proclog.c index e83f6fda32fe..37a9dd337308 100644 --- a/drivers/isdn/hysdn/hysdn_proclog.c +++ b/drivers/isdn/hysdn/hysdn_proclog.c | |||
@@ -15,13 +15,14 @@ | |||
15 | #include <linux/proc_fs.h> | 15 | #include <linux/proc_fs.h> |
16 | #include <linux/sched.h> | 16 | #include <linux/sched.h> |
17 | #include <linux/slab.h> | 17 | #include <linux/slab.h> |
18 | #include <linux/smp_lock.h> | 18 | #include <linux/mutex.h> |
19 | 19 | ||
20 | #include "hysdn_defs.h" | 20 | #include "hysdn_defs.h" |
21 | 21 | ||
22 | /* the proc subdir for the interface is defined in the procconf module */ | 22 | /* the proc subdir for the interface is defined in the procconf module */ |
23 | extern struct proc_dir_entry *hysdn_proc_entry; | 23 | extern struct proc_dir_entry *hysdn_proc_entry; |
24 | 24 | ||
25 | static DEFINE_MUTEX(hysdn_log_mutex); | ||
25 | static void put_log_buffer(hysdn_card * card, char *cp); | 26 | static void put_log_buffer(hysdn_card * card, char *cp); |
26 | 27 | ||
27 | /*************************************************/ | 28 | /*************************************************/ |
@@ -251,7 +252,7 @@ hysdn_log_open(struct inode *ino, struct file *filep) | |||
251 | struct procdata *pd = NULL; | 252 | struct procdata *pd = NULL; |
252 | unsigned long flags; | 253 | unsigned long flags; |
253 | 254 | ||
254 | lock_kernel(); | 255 | mutex_lock(&hysdn_log_mutex); |
255 | card = card_root; | 256 | card = card_root; |
256 | while (card) { | 257 | while (card) { |
257 | pd = card->proclog; | 258 | pd = card->proclog; |
@@ -260,7 +261,7 @@ hysdn_log_open(struct inode *ino, struct file *filep) | |||
260 | card = card->next; /* search next entry */ | 261 | card = card->next; /* search next entry */ |
261 | } | 262 | } |
262 | if (!card) { | 263 | if (!card) { |
263 | unlock_kernel(); | 264 | mutex_unlock(&hysdn_log_mutex); |
264 | return (-ENODEV); /* device is unknown/invalid */ | 265 | return (-ENODEV); /* device is unknown/invalid */ |
265 | } | 266 | } |
266 | filep->private_data = card; /* remember our own card */ | 267 | filep->private_data = card; /* remember our own card */ |
@@ -278,10 +279,10 @@ hysdn_log_open(struct inode *ino, struct file *filep) | |||
278 | filep->private_data = &pd->log_head; | 279 | filep->private_data = &pd->log_head; |
279 | spin_unlock_irqrestore(&card->hysdn_lock, flags); | 280 | spin_unlock_irqrestore(&card->hysdn_lock, flags); |
280 | } else { /* simultaneous read/write access forbidden ! */ | 281 | } else { /* simultaneous read/write access forbidden ! */ |
281 | unlock_kernel(); | 282 | mutex_unlock(&hysdn_log_mutex); |
282 | return (-EPERM); /* no permission this time */ | 283 | return (-EPERM); /* no permission this time */ |
283 | } | 284 | } |
284 | unlock_kernel(); | 285 | mutex_unlock(&hysdn_log_mutex); |
285 | return nonseekable_open(ino, filep); | 286 | return nonseekable_open(ino, filep); |
286 | } /* hysdn_log_open */ | 287 | } /* hysdn_log_open */ |
287 | 288 | ||
@@ -300,7 +301,7 @@ hysdn_log_close(struct inode *ino, struct file *filep) | |||
300 | hysdn_card *card; | 301 | hysdn_card *card; |
301 | int retval = 0; | 302 | int retval = 0; |
302 | 303 | ||
303 | lock_kernel(); | 304 | mutex_lock(&hysdn_log_mutex); |
304 | if ((filep->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_WRITE) { | 305 | if ((filep->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_WRITE) { |
305 | /* write only access -> write debug level written */ | 306 | /* write only access -> write debug level written */ |
306 | retval = 0; /* success */ | 307 | retval = 0; /* success */ |
@@ -339,7 +340,7 @@ hysdn_log_close(struct inode *ino, struct file *filep) | |||
339 | kfree(inf); | 340 | kfree(inf); |
340 | } | 341 | } |
341 | } /* read access */ | 342 | } /* read access */ |
342 | unlock_kernel(); | 343 | mutex_unlock(&hysdn_log_mutex); |
343 | 344 | ||
344 | return (retval); | 345 | return (retval); |
345 | } /* hysdn_log_close */ | 346 | } /* hysdn_log_close */ |
diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c index a44cdb492ea9..15632bd2f643 100644 --- a/drivers/isdn/i4l/isdn_common.c +++ b/drivers/isdn/i4l/isdn_common.c | |||
@@ -17,7 +17,7 @@ | |||
17 | #include <linux/slab.h> | 17 | #include <linux/slab.h> |
18 | #include <linux/vmalloc.h> | 18 | #include <linux/vmalloc.h> |
19 | #include <linux/isdn.h> | 19 | #include <linux/isdn.h> |
20 | #include <linux/smp_lock.h> | 20 | #include <linux/mutex.h> |
21 | #include "isdn_common.h" | 21 | #include "isdn_common.h" |
22 | #include "isdn_tty.h" | 22 | #include "isdn_tty.h" |
23 | #include "isdn_net.h" | 23 | #include "isdn_net.h" |
@@ -42,6 +42,7 @@ MODULE_LICENSE("GPL"); | |||
42 | 42 | ||
43 | isdn_dev *dev; | 43 | isdn_dev *dev; |
44 | 44 | ||
45 | static DEFINE_MUTEX(isdn_mutex); | ||
45 | static char *isdn_revision = "$Revision: 1.1.2.3 $"; | 46 | static char *isdn_revision = "$Revision: 1.1.2.3 $"; |
46 | 47 | ||
47 | extern char *isdn_net_revision; | 48 | extern char *isdn_net_revision; |
@@ -1070,7 +1071,7 @@ isdn_read(struct file *file, char __user *buf, size_t count, loff_t * off) | |||
1070 | int retval; | 1071 | int retval; |
1071 | char *p; | 1072 | char *p; |
1072 | 1073 | ||
1073 | lock_kernel(); | 1074 | mutex_lock(&isdn_mutex); |
1074 | if (minor == ISDN_MINOR_STATUS) { | 1075 | if (minor == ISDN_MINOR_STATUS) { |
1075 | if (!file->private_data) { | 1076 | if (!file->private_data) { |
1076 | if (file->f_flags & O_NONBLOCK) { | 1077 | 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 | #endif | 1164 | #endif |
1164 | retval = -ENODEV; | 1165 | retval = -ENODEV; |
1165 | out: | 1166 | out: |
1166 | unlock_kernel(); | 1167 | mutex_unlock(&isdn_mutex); |
1167 | return retval; | 1168 | return retval; |
1168 | } | 1169 | } |
1169 | 1170 | ||
@@ -1180,7 +1181,7 @@ isdn_write(struct file *file, const char __user *buf, size_t count, loff_t * off | |||
1180 | if (!dev->drivers) | 1181 | if (!dev->drivers) |
1181 | return -ENODEV; | 1182 | return -ENODEV; |
1182 | 1183 | ||
1183 | lock_kernel(); | 1184 | mutex_lock(&isdn_mutex); |
1184 | if (minor <= ISDN_MINOR_BMAX) { | 1185 | if (minor <= ISDN_MINOR_BMAX) { |
1185 | printk(KERN_WARNING "isdn_write minor %d obsolete!\n", minor); | 1186 | printk(KERN_WARNING "isdn_write minor %d obsolete!\n", minor); |
1186 | drvidx = isdn_minor2drv(minor); | 1187 | drvidx = isdn_minor2drv(minor); |
@@ -1225,7 +1226,7 @@ isdn_write(struct file *file, const char __user *buf, size_t count, loff_t * off | |||
1225 | #endif | 1226 | #endif |
1226 | retval = -ENODEV; | 1227 | retval = -ENODEV; |
1227 | out: | 1228 | out: |
1228 | unlock_kernel(); | 1229 | mutex_unlock(&isdn_mutex); |
1229 | return retval; | 1230 | return retval; |
1230 | } | 1231 | } |
1231 | 1232 | ||
@@ -1236,7 +1237,7 @@ isdn_poll(struct file *file, poll_table * wait) | |||
1236 | unsigned int minor = iminor(file->f_path.dentry->d_inode); | 1237 | unsigned int minor = iminor(file->f_path.dentry->d_inode); |
1237 | int drvidx = isdn_minor2drv(minor - ISDN_MINOR_CTRL); | 1238 | int drvidx = isdn_minor2drv(minor - ISDN_MINOR_CTRL); |
1238 | 1239 | ||
1239 | lock_kernel(); | 1240 | mutex_lock(&isdn_mutex); |
1240 | if (minor == ISDN_MINOR_STATUS) { | 1241 | if (minor == ISDN_MINOR_STATUS) { |
1241 | poll_wait(file, &(dev->info_waitq), wait); | 1242 | poll_wait(file, &(dev->info_waitq), wait); |
1242 | /* mask = POLLOUT | POLLWRNORM; */ | 1243 | /* mask = POLLOUT | POLLWRNORM; */ |
@@ -1266,7 +1267,7 @@ isdn_poll(struct file *file, poll_table * wait) | |||
1266 | #endif | 1267 | #endif |
1267 | mask = POLLERR; | 1268 | mask = POLLERR; |
1268 | out: | 1269 | out: |
1269 | unlock_kernel(); | 1270 | mutex_unlock(&isdn_mutex); |
1270 | return mask; | 1271 | return mask; |
1271 | } | 1272 | } |
1272 | 1273 | ||
@@ -1727,9 +1728,9 @@ isdn_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
1727 | { | 1728 | { |
1728 | int ret; | 1729 | int ret; |
1729 | 1730 | ||
1730 | lock_kernel(); | 1731 | mutex_lock(&isdn_mutex); |
1731 | ret = isdn_ioctl(file, cmd, arg); | 1732 | ret = isdn_ioctl(file, cmd, arg); |
1732 | unlock_kernel(); | 1733 | mutex_unlock(&isdn_mutex); |
1733 | 1734 | ||
1734 | return ret; | 1735 | return ret; |
1735 | } | 1736 | } |
@@ -1745,7 +1746,7 @@ isdn_open(struct inode *ino, struct file *filep) | |||
1745 | int chidx; | 1746 | int chidx; |
1746 | int retval = -ENODEV; | 1747 | int retval = -ENODEV; |
1747 | 1748 | ||
1748 | lock_kernel(); | 1749 | mutex_lock(&isdn_mutex); |
1749 | if (minor == ISDN_MINOR_STATUS) { | 1750 | if (minor == ISDN_MINOR_STATUS) { |
1750 | infostruct *p; | 1751 | infostruct *p; |
1751 | 1752 | ||
@@ -1796,7 +1797,7 @@ isdn_open(struct inode *ino, struct file *filep) | |||
1796 | #endif | 1797 | #endif |
1797 | out: | 1798 | out: |
1798 | nonseekable_open(ino, filep); | 1799 | nonseekable_open(ino, filep); |
1799 | unlock_kernel(); | 1800 | mutex_unlock(&isdn_mutex); |
1800 | return retval; | 1801 | return retval; |
1801 | } | 1802 | } |
1802 | 1803 | ||
@@ -1805,7 +1806,7 @@ isdn_close(struct inode *ino, struct file *filep) | |||
1805 | { | 1806 | { |
1806 | uint minor = iminor(ino); | 1807 | uint minor = iminor(ino); |
1807 | 1808 | ||
1808 | lock_kernel(); | 1809 | mutex_lock(&isdn_mutex); |
1809 | if (minor == ISDN_MINOR_STATUS) { | 1810 | if (minor == ISDN_MINOR_STATUS) { |
1810 | infostruct *p = dev->infochain; | 1811 | infostruct *p = dev->infochain; |
1811 | infostruct *q = NULL; | 1812 | infostruct *q = NULL; |
@@ -1839,7 +1840,7 @@ isdn_close(struct inode *ino, struct file *filep) | |||
1839 | #endif | 1840 | #endif |
1840 | 1841 | ||
1841 | out: | 1842 | out: |
1842 | unlock_kernel(); | 1843 | mutex_unlock(&isdn_mutex); |
1843 | return 0; | 1844 | return 0; |
1844 | } | 1845 | } |
1845 | 1846 | ||
diff --git a/drivers/isdn/mISDN/timerdev.c b/drivers/isdn/mISDN/timerdev.c index 81048b8ed8ad..de43c8c70ad0 100644 --- a/drivers/isdn/mISDN/timerdev.c +++ b/drivers/isdn/mISDN/timerdev.c | |||
@@ -24,9 +24,10 @@ | |||
24 | #include <linux/miscdevice.h> | 24 | #include <linux/miscdevice.h> |
25 | #include <linux/module.h> | 25 | #include <linux/module.h> |
26 | #include <linux/mISDNif.h> | 26 | #include <linux/mISDNif.h> |
27 | #include <linux/smp_lock.h> | 27 | #include <linux/mutex.h> |
28 | #include "core.h" | 28 | #include "core.h" |
29 | 29 | ||
30 | static DEFINE_MUTEX(mISDN_mutex); | ||
30 | static u_int *debug; | 31 | static u_int *debug; |
31 | 32 | ||
32 | 33 | ||
@@ -224,7 +225,7 @@ mISDN_ioctl(struct file *filep, unsigned int cmd, unsigned long arg) | |||
224 | if (*debug & DEBUG_TIMER) | 225 | if (*debug & DEBUG_TIMER) |
225 | printk(KERN_DEBUG "%s(%p, %x, %lx)\n", __func__, | 226 | printk(KERN_DEBUG "%s(%p, %x, %lx)\n", __func__, |
226 | filep, cmd, arg); | 227 | filep, cmd, arg); |
227 | lock_kernel(); | 228 | mutex_lock(&mISDN_mutex); |
228 | switch (cmd) { | 229 | switch (cmd) { |
229 | case IMADDTIMER: | 230 | case IMADDTIMER: |
230 | if (get_user(tout, (int __user *)arg)) { | 231 | if (get_user(tout, (int __user *)arg)) { |
@@ -256,7 +257,7 @@ mISDN_ioctl(struct file *filep, unsigned int cmd, unsigned long arg) | |||
256 | default: | 257 | default: |
257 | ret = -EINVAL; | 258 | ret = -EINVAL; |
258 | } | 259 | } |
259 | unlock_kernel(); | 260 | mutex_unlock(&mISDN_mutex); |
260 | return ret; | 261 | return ret; |
261 | } | 262 | } |
262 | 263 | ||