aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/dpt_i2o.c
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2010-06-02 08:28:52 -0400
committerArnd Bergmann <arnd@arndb.de>2010-09-15 15:00:45 -0400
commitc45d15d24eb2b49bf734e1e5e7e103befb76b19b (patch)
treedd768c089fd3393e8fa2c4f4fb50cedb1044037d /drivers/scsi/dpt_i2o.c
parent49553c2ef88749dd502687f4eb9c258bb10a4f44 (diff)
scsi: 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: linux-scsi@vger.kernel.org Cc: "James E.J. Bottomley" <James.Bottomley@suse.de>
Diffstat (limited to 'drivers/scsi/dpt_i2o.c')
-rw-r--r--drivers/scsi/dpt_i2o.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c
index ffc1edf5e80d..410ac1def8a6 100644
--- a/drivers/scsi/dpt_i2o.c
+++ b/drivers/scsi/dpt_i2o.c
@@ -49,7 +49,6 @@ MODULE_DESCRIPTION("Adaptec I2O RAID Driver");
49#include <linux/kernel.h> /* for printk */ 49#include <linux/kernel.h> /* for printk */
50#include <linux/sched.h> 50#include <linux/sched.h>
51#include <linux/reboot.h> 51#include <linux/reboot.h>
52#include <linux/smp_lock.h>
53#include <linux/spinlock.h> 52#include <linux/spinlock.h>
54#include <linux/dma-mapping.h> 53#include <linux/dma-mapping.h>
55 54
@@ -76,6 +75,7 @@ MODULE_DESCRIPTION("Adaptec I2O RAID Driver");
76 * Needed for our management apps 75 * Needed for our management apps
77 *============================================================================ 76 *============================================================================
78 */ 77 */
78static DEFINE_MUTEX(adpt_mutex);
79static dpt_sig_S DPTI_sig = { 79static dpt_sig_S DPTI_sig = {
80 {'d', 'P', 't', 'S', 'i', 'G'}, SIG_VERSION, 80 {'d', 'P', 't', 'S', 'i', 'G'}, SIG_VERSION,
81#ifdef __i386__ 81#ifdef __i386__
@@ -1732,12 +1732,12 @@ static int adpt_open(struct inode *inode, struct file *file)
1732 int minor; 1732 int minor;
1733 adpt_hba* pHba; 1733 adpt_hba* pHba;
1734 1734
1735 lock_kernel(); 1735 mutex_lock(&adpt_mutex);
1736 //TODO check for root access 1736 //TODO check for root access
1737 // 1737 //
1738 minor = iminor(inode); 1738 minor = iminor(inode);
1739 if (minor >= hba_count) { 1739 if (minor >= hba_count) {
1740 unlock_kernel(); 1740 mutex_unlock(&adpt_mutex);
1741 return -ENXIO; 1741 return -ENXIO;
1742 } 1742 }
1743 mutex_lock(&adpt_configuration_lock); 1743 mutex_lock(&adpt_configuration_lock);
@@ -1748,7 +1748,7 @@ static int adpt_open(struct inode *inode, struct file *file)
1748 } 1748 }
1749 if (pHba == NULL) { 1749 if (pHba == NULL) {
1750 mutex_unlock(&adpt_configuration_lock); 1750 mutex_unlock(&adpt_configuration_lock);
1751 unlock_kernel(); 1751 mutex_unlock(&adpt_mutex);
1752 return -ENXIO; 1752 return -ENXIO;
1753 } 1753 }
1754 1754
@@ -1759,7 +1759,7 @@ static int adpt_open(struct inode *inode, struct file *file)
1759 1759
1760 pHba->in_use = 1; 1760 pHba->in_use = 1;
1761 mutex_unlock(&adpt_configuration_lock); 1761 mutex_unlock(&adpt_configuration_lock);
1762 unlock_kernel(); 1762 mutex_unlock(&adpt_mutex);
1763 1763
1764 return 0; 1764 return 0;
1765} 1765}
@@ -2160,9 +2160,9 @@ static long adpt_unlocked_ioctl(struct file *file, uint cmd, ulong arg)
2160 2160
2161 inode = file->f_dentry->d_inode; 2161 inode = file->f_dentry->d_inode;
2162 2162
2163 lock_kernel(); 2163 mutex_lock(&adpt_mutex);
2164 ret = adpt_ioctl(inode, file, cmd, arg); 2164 ret = adpt_ioctl(inode, file, cmd, arg);
2165 unlock_kernel(); 2165 mutex_unlock(&adpt_mutex);
2166 2166
2167 return ret; 2167 return ret;
2168} 2168}
@@ -2176,7 +2176,7 @@ static long compat_adpt_ioctl(struct file *file,
2176 2176
2177 inode = file->f_dentry->d_inode; 2177 inode = file->f_dentry->d_inode;
2178 2178
2179 lock_kernel(); 2179 mutex_lock(&adpt_mutex);
2180 2180
2181 switch(cmd) { 2181 switch(cmd) {
2182 case DPT_SIGNATURE: 2182 case DPT_SIGNATURE:
@@ -2194,7 +2194,7 @@ static long compat_adpt_ioctl(struct file *file,
2194 ret = -ENOIOCTLCMD; 2194 ret = -ENOIOCTLCMD;
2195 } 2195 }
2196 2196
2197 unlock_kernel(); 2197 mutex_unlock(&adpt_mutex);
2198 2198
2199 return ret; 2199 return ret;
2200} 2200}