aboutsummaryrefslogtreecommitdiffstats
path: root/arch/cris
diff options
context:
space:
mode:
authorJesper Nilsson <jesper.nilsson@axis.com>2010-07-30 13:15:24 -0400
committerJesper Nilsson <jesper.nilsson@axis.com>2010-08-04 06:59:06 -0400
commit096b7bdc8663c16417ff5fbec42622302e6886e1 (patch)
treebbd80f3cf2ac7fe766f602b8d20d53dfd7759ec8 /arch/cris
parent90276a1a64e2ab732e26e3ac68febbf3ad04c517 (diff)
cris: 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> Signed-off-by: Jesper Nilsson <jesper.nilsson@axis.com>
Diffstat (limited to 'arch/cris')
-rw-r--r--arch/cris/arch-v10/drivers/eeprom.c2
-rw-r--r--arch/cris/arch-v10/drivers/i2c.c2
-rw-r--r--arch/cris/arch-v32/drivers/cryptocop.c2
-rw-r--r--arch/cris/arch-v32/drivers/i2c.c12
4 files changed, 6 insertions, 12 deletions
diff --git a/arch/cris/arch-v10/drivers/eeprom.c b/arch/cris/arch-v10/drivers/eeprom.c
index c3405507a3d1..5047a33043bd 100644
--- a/arch/cris/arch-v10/drivers/eeprom.c
+++ b/arch/cris/arch-v10/drivers/eeprom.c
@@ -28,7 +28,6 @@
28#include <linux/init.h> 28#include <linux/init.h>
29#include <linux/delay.h> 29#include <linux/delay.h>
30#include <linux/interrupt.h> 30#include <linux/interrupt.h>
31#include <linux/smp_lock.h>
32#include <linux/wait.h> 31#include <linux/wait.h>
33#include <asm/uaccess.h> 32#include <asm/uaccess.h>
34#include "i2c.h" 33#include "i2c.h"
@@ -376,7 +375,6 @@ int __init eeprom_init(void)
376/* Opens the device. */ 375/* Opens the device. */
377static int eeprom_open(struct inode * inode, struct file * file) 376static int eeprom_open(struct inode * inode, struct file * file)
378{ 377{
379 cycle_kernel_lock();
380 if(iminor(inode) != EEPROM_MINOR_NR) 378 if(iminor(inode) != EEPROM_MINOR_NR)
381 return -ENXIO; 379 return -ENXIO;
382 if(imajor(inode) != EEPROM_MAJOR_NR) 380 if(imajor(inode) != EEPROM_MAJOR_NR)
diff --git a/arch/cris/arch-v10/drivers/i2c.c b/arch/cris/arch-v10/drivers/i2c.c
index 399e089bed7a..54e2e1adf085 100644
--- a/arch/cris/arch-v10/drivers/i2c.c
+++ b/arch/cris/arch-v10/drivers/i2c.c
@@ -14,7 +14,6 @@
14 14
15#include <linux/module.h> 15#include <linux/module.h>
16#include <linux/sched.h> 16#include <linux/sched.h>
17#include <linux/smp_lock.h>
18#include <linux/errno.h> 17#include <linux/errno.h>
19#include <linux/kernel.h> 18#include <linux/kernel.h>
20#include <linux/fs.h> 19#include <linux/fs.h>
@@ -566,7 +565,6 @@ i2c_readreg(unsigned char theSlave, unsigned char theReg)
566static int 565static int
567i2c_open(struct inode *inode, struct file *filp) 566i2c_open(struct inode *inode, struct file *filp)
568{ 567{
569 cycle_kernel_lock();
570 return 0; 568 return 0;
571} 569}
572 570
diff --git a/arch/cris/arch-v32/drivers/cryptocop.c b/arch/cris/arch-v32/drivers/cryptocop.c
index 9cfbfae107c7..b07646a30509 100644
--- a/arch/cris/arch-v32/drivers/cryptocop.c
+++ b/arch/cris/arch-v32/drivers/cryptocop.c
@@ -11,7 +11,6 @@
11#include <linux/string.h> 11#include <linux/string.h>
12#include <linux/fs.h> 12#include <linux/fs.h>
13#include <linux/mm.h> 13#include <linux/mm.h>
14#include <linux/smp_lock.h>
15#include <linux/spinlock.h> 14#include <linux/spinlock.h>
16#include <linux/stddef.h> 15#include <linux/stddef.h>
17 16
@@ -2307,7 +2306,6 @@ static int cryptocop_open(struct inode *inode, struct file *filp)
2307{ 2306{
2308 int p = iminor(inode); 2307 int p = iminor(inode);
2309 2308
2310 cycle_kernel_lock();
2311 if (p != CRYPTOCOP_MINOR) return -EINVAL; 2309 if (p != CRYPTOCOP_MINOR) return -EINVAL;
2312 2310
2313 filp->private_data = NULL; 2311 filp->private_data = NULL;
diff --git a/arch/cris/arch-v32/drivers/i2c.c b/arch/cris/arch-v32/drivers/i2c.c
index 2fd6a740d895..5a3e900c9a78 100644
--- a/arch/cris/arch-v32/drivers/i2c.c
+++ b/arch/cris/arch-v32/drivers/i2c.c
@@ -32,7 +32,7 @@
32#include <linux/fs.h> 32#include <linux/fs.h>
33#include <linux/string.h> 33#include <linux/string.h>
34#include <linux/init.h> 34#include <linux/init.h>
35#include <linux/smp_lock.h> 35#include <linux/mutex.h>
36 36
37#include <asm/etraxi2c.h> 37#include <asm/etraxi2c.h>
38 38
@@ -47,6 +47,7 @@
47#define D(x) 47#define D(x)
48 48
49#define I2C_MAJOR 123 /* LOCAL/EXPERIMENTAL */ 49#define I2C_MAJOR 123 /* LOCAL/EXPERIMENTAL */
50static DEFINE_MUTEX(i2c_mutex);
50static const char i2c_name[] = "i2c"; 51static const char i2c_name[] = "i2c";
51 52
52#define CLOCK_LOW_TIME 8 53#define CLOCK_LOW_TIME 8
@@ -636,7 +637,6 @@ i2c_readreg(unsigned char theSlave, unsigned char theReg)
636static int 637static int
637i2c_open(struct inode *inode, struct file *filp) 638i2c_open(struct inode *inode, struct file *filp)
638{ 639{
639 cycle_kernel_lock();
640 return 0; 640 return 0;
641} 641}
642 642
@@ -665,11 +665,11 @@ i2c_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
665 I2C_ARGREG(arg), 665 I2C_ARGREG(arg),
666 I2C_ARGVALUE(arg))); 666 I2C_ARGVALUE(arg)));
667 667
668 lock_kernel(); 668 mutex_lock(&i2c_mutex);
669 ret = i2c_writereg(I2C_ARGSLAVE(arg), 669 ret = i2c_writereg(I2C_ARGSLAVE(arg),
670 I2C_ARGREG(arg), 670 I2C_ARGREG(arg),
671 I2C_ARGVALUE(arg)); 671 I2C_ARGVALUE(arg));
672 unlock_kernel(); 672 mutex_unlock(&i2c_mutex);
673 return ret; 673 return ret;
674 674
675 case I2C_READREG: 675 case I2C_READREG:
@@ -679,9 +679,9 @@ i2c_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
679 D(printk("i2cr %d %d ", 679 D(printk("i2cr %d %d ",
680 I2C_ARGSLAVE(arg), 680 I2C_ARGSLAVE(arg),
681 I2C_ARGREG(arg))); 681 I2C_ARGREG(arg)));
682 lock_kernel(); 682 mutex_lock(&i2c_mutex);
683 val = i2c_readreg(I2C_ARGSLAVE(arg), I2C_ARGREG(arg)); 683 val = i2c_readreg(I2C_ARGSLAVE(arg), I2C_ARGREG(arg));
684 unlock_kernel(); 684 mutex_unlock(&i2c_mutex);
685 D(printk("= %d\n", val)); 685 D(printk("= %d\n", val));
686 return val; 686 return val;
687 } 687 }