aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/mbcs.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/char/mbcs.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/char/mbcs.c')
-rw-r--r--drivers/char/mbcs.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/char/mbcs.c b/drivers/char/mbcs.c
index 83bef4efe376..1aeaaba680d2 100644
--- a/drivers/char/mbcs.c
+++ b/drivers/char/mbcs.c
@@ -25,7 +25,6 @@
25#include <linux/mm.h> 25#include <linux/mm.h>
26#include <linux/uio.h> 26#include <linux/uio.h>
27#include <linux/mutex.h> 27#include <linux/mutex.h>
28#include <linux/smp_lock.h>
29#include <linux/slab.h> 28#include <linux/slab.h>
30#include <asm/io.h> 29#include <asm/io.h>
31#include <asm/uaccess.h> 30#include <asm/uaccess.h>
@@ -42,6 +41,7 @@
42#else 41#else
43#define DBG(fmt...) 42#define DBG(fmt...)
44#endif 43#endif
44static DEFINE_MUTEX(mbcs_mutex);
45static int mbcs_major; 45static int mbcs_major;
46 46
47static LIST_HEAD(soft_list); 47static LIST_HEAD(soft_list);
@@ -385,19 +385,19 @@ static int mbcs_open(struct inode *ip, struct file *fp)
385 struct mbcs_soft *soft; 385 struct mbcs_soft *soft;
386 int minor; 386 int minor;
387 387
388 lock_kernel(); 388 mutex_lock(&mbcs_mutex);
389 minor = iminor(ip); 389 minor = iminor(ip);
390 390
391 /* Nothing protects access to this list... */ 391 /* Nothing protects access to this list... */
392 list_for_each_entry(soft, &soft_list, list) { 392 list_for_each_entry(soft, &soft_list, list) {
393 if (soft->nasid == minor) { 393 if (soft->nasid == minor) {
394 fp->private_data = soft->cxdev; 394 fp->private_data = soft->cxdev;
395 unlock_kernel(); 395 mutex_unlock(&mbcs_mutex);
396 return 0; 396 return 0;
397 } 397 }
398 } 398 }
399 399
400 unlock_kernel(); 400 mutex_unlock(&mbcs_mutex);
401 return -ENODEV; 401 return -ENODEV;
402} 402}
403 403