aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/watchdog/cpwd.c
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2010-06-02 08:28:52 -0400
committerArnd Bergmann <arnd@arndb.de>2010-10-05 09:01:04 -0400
commit613655fa39ff6957754fa8ceb8559980920eb8ee (patch)
treead19600cb81207b24188683d7fc4ae88013339d1 /drivers/watchdog/cpwd.c
parent609146fdb319cebce93be550938ab852f7bade90 (diff)
drivers: 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. These drivers do not seem to be under active maintainance from my brief investigation. Apologies to those maintainers that I have missed. 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>
Diffstat (limited to 'drivers/watchdog/cpwd.c')
-rw-r--r--drivers/watchdog/cpwd.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/drivers/watchdog/cpwd.c b/drivers/watchdog/cpwd.c
index 566343b3c131..b7d96e6236a1 100644
--- a/drivers/watchdog/cpwd.c
+++ b/drivers/watchdog/cpwd.c
@@ -25,7 +25,7 @@
25#include <linux/ioport.h> 25#include <linux/ioport.h>
26#include <linux/timer.h> 26#include <linux/timer.h>
27#include <linux/slab.h> 27#include <linux/slab.h>
28#include <linux/smp_lock.h> 28#include <linux/mutex.h>
29#include <linux/io.h> 29#include <linux/io.h>
30#include <linux/of.h> 30#include <linux/of.h>
31#include <linux/of_device.h> 31#include <linux/of_device.h>
@@ -89,6 +89,7 @@ struct cpwd {
89 } devs[WD_NUMDEVS]; 89 } devs[WD_NUMDEVS];
90}; 90};
91 91
92static DEFINE_MUTEX(cpwd_mutex);
92static struct cpwd *cpwd_device; 93static struct cpwd *cpwd_device;
93 94
94/* Sun uses Altera PLD EPF8820ATC144-4 95/* Sun uses Altera PLD EPF8820ATC144-4
@@ -368,7 +369,7 @@ static int cpwd_open(struct inode *inode, struct file *f)
368{ 369{
369 struct cpwd *p = cpwd_device; 370 struct cpwd *p = cpwd_device;
370 371
371 lock_kernel(); 372 mutex_lock(&cpwd_mutex);
372 switch (iminor(inode)) { 373 switch (iminor(inode)) {
373 case WD0_MINOR: 374 case WD0_MINOR:
374 case WD1_MINOR: 375 case WD1_MINOR:
@@ -376,7 +377,7 @@ static int cpwd_open(struct inode *inode, struct file *f)
376 break; 377 break;
377 378
378 default: 379 default:
379 unlock_kernel(); 380 mutex_unlock(&cpwd_mutex);
380 return -ENODEV; 381 return -ENODEV;
381 } 382 }
382 383
@@ -386,13 +387,13 @@ static int cpwd_open(struct inode *inode, struct file *f)
386 IRQF_SHARED, DRIVER_NAME, p)) { 387 IRQF_SHARED, DRIVER_NAME, p)) {
387 printk(KERN_ERR PFX "Cannot register IRQ %d\n", 388 printk(KERN_ERR PFX "Cannot register IRQ %d\n",
388 p->irq); 389 p->irq);
389 unlock_kernel(); 390 mutex_unlock(&cpwd_mutex);
390 return -EBUSY; 391 return -EBUSY;
391 } 392 }
392 p->initialized = true; 393 p->initialized = true;
393 } 394 }
394 395
395 unlock_kernel(); 396 mutex_unlock(&cpwd_mutex);
396 397
397 return nonseekable_open(inode, f); 398 return nonseekable_open(inode, f);
398} 399}
@@ -482,9 +483,9 @@ static long cpwd_compat_ioctl(struct file *file, unsigned int cmd,
482 case WIOCSTART: 483 case WIOCSTART:
483 case WIOCSTOP: 484 case WIOCSTOP:
484 case WIOCGSTAT: 485 case WIOCGSTAT:
485 lock_kernel(); 486 mutex_lock(&cpwd_mutex);
486 rval = cpwd_ioctl(file, cmd, arg); 487 rval = cpwd_ioctl(file, cmd, arg);
487 unlock_kernel(); 488 mutex_unlock(&cpwd_mutex);
488 break; 489 break;
489 490
490 /* everything else is handled by the generic compat layer */ 491 /* everything else is handled by the generic compat layer */