aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/gdth.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/gdth.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/gdth.c')
-rw-r--r--drivers/scsi/gdth.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c
index b860d650a563..e927607bbf89 100644
--- a/drivers/scsi/gdth.c
+++ b/drivers/scsi/gdth.c
@@ -120,7 +120,7 @@
120#include <linux/timer.h> 120#include <linux/timer.h>
121#include <linux/dma-mapping.h> 121#include <linux/dma-mapping.h>
122#include <linux/list.h> 122#include <linux/list.h>
123#include <linux/smp_lock.h> 123#include <linux/mutex.h>
124#include <linux/slab.h> 124#include <linux/slab.h>
125 125
126#ifdef GDTH_RTC 126#ifdef GDTH_RTC
@@ -140,6 +140,7 @@
140#include <scsi/scsi_host.h> 140#include <scsi/scsi_host.h>
141#include "gdth.h" 141#include "gdth.h"
142 142
143static DEFINE_MUTEX(gdth_mutex);
143static void gdth_delay(int milliseconds); 144static void gdth_delay(int milliseconds);
144static void gdth_eval_mapping(u32 size, u32 *cyls, int *heads, int *secs); 145static void gdth_eval_mapping(u32 size, u32 *cyls, int *heads, int *secs);
145static irqreturn_t gdth_interrupt(int irq, void *dev_id); 146static irqreturn_t gdth_interrupt(int irq, void *dev_id);
@@ -4042,12 +4043,12 @@ static int gdth_open(struct inode *inode, struct file *filep)
4042{ 4043{
4043 gdth_ha_str *ha; 4044 gdth_ha_str *ha;
4044 4045
4045 lock_kernel(); 4046 mutex_lock(&gdth_mutex);
4046 list_for_each_entry(ha, &gdth_instances, list) { 4047 list_for_each_entry(ha, &gdth_instances, list) {
4047 if (!ha->sdev) 4048 if (!ha->sdev)
4048 ha->sdev = scsi_get_host_dev(ha->shost); 4049 ha->sdev = scsi_get_host_dev(ha->shost);
4049 } 4050 }
4050 unlock_kernel(); 4051 mutex_unlock(&gdth_mutex);
4051 4052
4052 TRACE(("gdth_open()\n")); 4053 TRACE(("gdth_open()\n"));
4053 return 0; 4054 return 0;
@@ -4615,9 +4616,9 @@ static long gdth_unlocked_ioctl(struct file *file, unsigned int cmd,
4615{ 4616{
4616 int ret; 4617 int ret;
4617 4618
4618 lock_kernel(); 4619 mutex_lock(&gdth_mutex);
4619 ret = gdth_ioctl(file, cmd, arg); 4620 ret = gdth_ioctl(file, cmd, arg);
4620 unlock_kernel(); 4621 mutex_unlock(&gdth_mutex);
4621 4622
4622 return ret; 4623 return ret;
4623} 4624}