aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/isdn/hysdn
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2010-07-11 07:18:53 -0400
committerDavid S. Miller <davem@davemloft.net>2010-07-12 23:21:47 -0400
commit76a64921dad9acd76270dc74249f0dfe11c84bb8 (patch)
tree42eaa62b3c886e46b29bbae354fe87bf8475d970 /drivers/isdn/hysdn
parentd361fd599a991ff6c1d522a599c635b35d61ef30 (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/hysdn')
-rw-r--r--drivers/isdn/hysdn/hysdn_procconf.c21
-rw-r--r--drivers/isdn/hysdn/hysdn_proclog.c15
2 files changed, 19 insertions, 17 deletions
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
25static DEFINE_MUTEX(hysdn_conf_mutex);
25static char *hysdn_procconf_revision = "$Revision: 1.8.6.4 $"; 26static 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 */
23extern struct proc_dir_entry *hysdn_proc_entry; 23extern struct proc_dir_entry *hysdn_proc_entry;
24 24
25static DEFINE_MUTEX(hysdn_log_mutex);
25static void put_log_buffer(hysdn_card * card, char *cp); 26static 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 */