diff options
| author | Arnd Bergmann <arnd@arndb.de> | 2010-06-02 08:28:52 -0400 |
|---|---|---|
| committer | Arnd Bergmann <arnd@arndb.de> | 2010-09-15 15:00:45 -0400 |
| commit | c45d15d24eb2b49bf734e1e5e7e103befb76b19b (patch) | |
| tree | dd768c089fd3393e8fa2c4f4fb50cedb1044037d | |
| parent | 49553c2ef88749dd502687f4eb9c258bb10a4f44 (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>
| -rw-r--r-- | drivers/message/fusion/mptctl.c | 15 | ||||
| -rw-r--r-- | drivers/message/i2o/i2o_config.c | 23 | ||||
| -rw-r--r-- | drivers/scsi/3w-9xxx.c | 7 | ||||
| -rw-r--r-- | drivers/scsi/3w-sas.c | 7 | ||||
| -rw-r--r-- | drivers/scsi/3w-xxxx.c | 9 | ||||
| -rw-r--r-- | drivers/scsi/aacraid/linit.c | 15 | ||||
| -rw-r--r-- | drivers/scsi/ch.c | 8 | ||||
| -rw-r--r-- | drivers/scsi/dpt_i2o.c | 18 | ||||
| -rw-r--r-- | drivers/scsi/gdth.c | 11 | ||||
| -rw-r--r-- | drivers/scsi/megaraid.c | 8 | ||||
| -rw-r--r-- | drivers/scsi/megaraid/megaraid_mm.c | 8 | ||||
| -rw-r--r-- | drivers/scsi/megaraid/megaraid_sas.c | 2 | ||||
| -rw-r--r-- | drivers/scsi/mpt2sas/mpt2sas_ctl.c | 11 | ||||
| -rw-r--r-- | drivers/scsi/osst.c | 15 | ||||
| -rw-r--r-- | drivers/scsi/scsi_tgt_if.c | 2 | ||||
| -rw-r--r-- | drivers/scsi/sg.c | 12 |
16 files changed, 86 insertions, 85 deletions
diff --git a/drivers/message/fusion/mptctl.c b/drivers/message/fusion/mptctl.c index d8ddfdf8be14..a3856ed90aef 100644 --- a/drivers/message/fusion/mptctl.c +++ b/drivers/message/fusion/mptctl.c | |||
| @@ -54,7 +54,7 @@ | |||
| 54 | #include <linux/pci.h> | 54 | #include <linux/pci.h> |
| 55 | #include <linux/delay.h> /* for mdelay */ | 55 | #include <linux/delay.h> /* for mdelay */ |
| 56 | #include <linux/miscdevice.h> | 56 | #include <linux/miscdevice.h> |
| 57 | #include <linux/smp_lock.h> | 57 | #include <linux/mutex.h> |
| 58 | #include <linux/compat.h> | 58 | #include <linux/compat.h> |
| 59 | 59 | ||
| 60 | #include <asm/io.h> | 60 | #include <asm/io.h> |
| @@ -83,6 +83,7 @@ MODULE_VERSION(my_VERSION); | |||
| 83 | 83 | ||
| 84 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ | 84 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ |
| 85 | 85 | ||
| 86 | static DEFINE_MUTEX(mpctl_mutex); | ||
| 86 | static u8 mptctl_id = MPT_MAX_PROTOCOL_DRIVERS; | 87 | static u8 mptctl_id = MPT_MAX_PROTOCOL_DRIVERS; |
| 87 | static u8 mptctl_taskmgmt_id = MPT_MAX_PROTOCOL_DRIVERS; | 88 | static u8 mptctl_taskmgmt_id = MPT_MAX_PROTOCOL_DRIVERS; |
| 88 | 89 | ||
| @@ -601,12 +602,12 @@ mptctl_fasync(int fd, struct file *filep, int mode) | |||
| 601 | MPT_ADAPTER *ioc; | 602 | MPT_ADAPTER *ioc; |
| 602 | int ret; | 603 | int ret; |
| 603 | 604 | ||
| 604 | lock_kernel(); | 605 | mutex_lock(&mpctl_mutex); |
| 605 | list_for_each_entry(ioc, &ioc_list, list) | 606 | list_for_each_entry(ioc, &ioc_list, list) |
| 606 | ioc->aen_event_read_flag=0; | 607 | ioc->aen_event_read_flag=0; |
| 607 | 608 | ||
| 608 | ret = fasync_helper(fd, filep, mode, &async_queue); | 609 | ret = fasync_helper(fd, filep, mode, &async_queue); |
| 609 | unlock_kernel(); | 610 | mutex_unlock(&mpctl_mutex); |
| 610 | return ret; | 611 | return ret; |
| 611 | } | 612 | } |
| 612 | 613 | ||
| @@ -698,9 +699,9 @@ static long | |||
| 698 | mptctl_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | 699 | mptctl_ioctl(struct file *file, unsigned int cmd, unsigned long arg) |
| 699 | { | 700 | { |
| 700 | long ret; | 701 | long ret; |
| 701 | lock_kernel(); | 702 | mutex_lock(&mpctl_mutex); |
| 702 | ret = __mptctl_ioctl(file, cmd, arg); | 703 | ret = __mptctl_ioctl(file, cmd, arg); |
| 703 | unlock_kernel(); | 704 | mutex_unlock(&mpctl_mutex); |
| 704 | return ret; | 705 | return ret; |
| 705 | } | 706 | } |
| 706 | 707 | ||
| @@ -2926,7 +2927,7 @@ compat_mpt_command(struct file *filp, unsigned int cmd, | |||
| 2926 | static long compat_mpctl_ioctl(struct file *f, unsigned int cmd, unsigned long arg) | 2927 | static long compat_mpctl_ioctl(struct file *f, unsigned int cmd, unsigned long arg) |
| 2927 | { | 2928 | { |
| 2928 | long ret; | 2929 | long ret; |
| 2929 | lock_kernel(); | 2930 | mutex_lock(&mpctl_mutex); |
| 2930 | switch (cmd) { | 2931 | switch (cmd) { |
| 2931 | case MPTIOCINFO: | 2932 | case MPTIOCINFO: |
| 2932 | case MPTIOCINFO1: | 2933 | case MPTIOCINFO1: |
| @@ -2951,7 +2952,7 @@ static long compat_mpctl_ioctl(struct file *f, unsigned int cmd, unsigned long a | |||
| 2951 | ret = -ENOIOCTLCMD; | 2952 | ret = -ENOIOCTLCMD; |
| 2952 | break; | 2953 | break; |
| 2953 | } | 2954 | } |
| 2954 | unlock_kernel(); | 2955 | mutex_unlock(&mpctl_mutex); |
| 2955 | return ret; | 2956 | return ret; |
| 2956 | } | 2957 | } |
| 2957 | 2958 | ||
diff --git a/drivers/message/i2o/i2o_config.c b/drivers/message/i2o/i2o_config.c index 068ba0785bb4..7d3cc575c361 100644 --- a/drivers/message/i2o/i2o_config.c +++ b/drivers/message/i2o/i2o_config.c | |||
| @@ -31,7 +31,7 @@ | |||
| 31 | */ | 31 | */ |
| 32 | 32 | ||
| 33 | #include <linux/miscdevice.h> | 33 | #include <linux/miscdevice.h> |
| 34 | #include <linux/smp_lock.h> | 34 | #include <linux/mutex.h> |
| 35 | #include <linux/compat.h> | 35 | #include <linux/compat.h> |
| 36 | #include <linux/slab.h> | 36 | #include <linux/slab.h> |
| 37 | 37 | ||
| @@ -41,6 +41,7 @@ | |||
| 41 | 41 | ||
| 42 | #define SG_TABLESIZE 30 | 42 | #define SG_TABLESIZE 30 |
| 43 | 43 | ||
| 44 | static DEFINE_MUTEX(i2o_cfg_mutex); | ||
| 44 | static long i2o_cfg_ioctl(struct file *, unsigned int, unsigned long); | 45 | static long i2o_cfg_ioctl(struct file *, unsigned int, unsigned long); |
| 45 | 46 | ||
| 46 | static spinlock_t i2o_config_lock; | 47 | static spinlock_t i2o_config_lock; |
| @@ -741,7 +742,7 @@ static long i2o_cfg_compat_ioctl(struct file *file, unsigned cmd, | |||
| 741 | unsigned long arg) | 742 | unsigned long arg) |
| 742 | { | 743 | { |
| 743 | int ret; | 744 | int ret; |
| 744 | lock_kernel(); | 745 | mutex_lock(&i2o_cfg_mutex); |
| 745 | switch (cmd) { | 746 | switch (cmd) { |
| 746 | case I2OGETIOPS: | 747 | case I2OGETIOPS: |
| 747 | ret = i2o_cfg_ioctl(file, cmd, arg); | 748 | ret = i2o_cfg_ioctl(file, cmd, arg); |
| @@ -753,7 +754,7 @@ static long i2o_cfg_compat_ioctl(struct file *file, unsigned cmd, | |||
| 753 | ret = -ENOIOCTLCMD; | 754 | ret = -ENOIOCTLCMD; |
| 754 | break; | 755 | break; |
| 755 | } | 756 | } |
| 756 | unlock_kernel(); | 757 | mutex_unlock(&i2o_cfg_mutex); |
| 757 | return ret; | 758 | return ret; |
| 758 | } | 759 | } |
| 759 | 760 | ||
| @@ -981,7 +982,7 @@ static long i2o_cfg_ioctl(struct file *fp, unsigned int cmd, unsigned long arg) | |||
| 981 | { | 982 | { |
| 982 | int ret; | 983 | int ret; |
| 983 | 984 | ||
| 984 | lock_kernel(); | 985 | mutex_lock(&i2o_cfg_mutex); |
| 985 | switch (cmd) { | 986 | switch (cmd) { |
| 986 | case I2OGETIOPS: | 987 | case I2OGETIOPS: |
| 987 | ret = i2o_cfg_getiops(arg); | 988 | ret = i2o_cfg_getiops(arg); |
| @@ -1037,7 +1038,7 @@ static long i2o_cfg_ioctl(struct file *fp, unsigned int cmd, unsigned long arg) | |||
| 1037 | osm_debug("unknown ioctl called!\n"); | 1038 | osm_debug("unknown ioctl called!\n"); |
| 1038 | ret = -EINVAL; | 1039 | ret = -EINVAL; |
| 1039 | } | 1040 | } |
| 1040 | unlock_kernel(); | 1041 | mutex_unlock(&i2o_cfg_mutex); |
| 1041 | return ret; | 1042 | return ret; |
| 1042 | } | 1043 | } |
| 1043 | 1044 | ||
| @@ -1051,7 +1052,7 @@ static int cfg_open(struct inode *inode, struct file *file) | |||
| 1051 | if (!tmp) | 1052 | if (!tmp) |
| 1052 | return -ENOMEM; | 1053 | return -ENOMEM; |
| 1053 | 1054 | ||
| 1054 | lock_kernel(); | 1055 | mutex_lock(&i2o_cfg_mutex); |
| 1055 | file->private_data = (void *)(i2o_cfg_info_id++); | 1056 | file->private_data = (void *)(i2o_cfg_info_id++); |
| 1056 | tmp->fp = file; | 1057 | tmp->fp = file; |
| 1057 | tmp->fasync = NULL; | 1058 | tmp->fasync = NULL; |
| @@ -1065,7 +1066,7 @@ static int cfg_open(struct inode *inode, struct file *file) | |||
| 1065 | spin_lock_irqsave(&i2o_config_lock, flags); | 1066 | spin_lock_irqsave(&i2o_config_lock, flags); |
| 1066 | open_files = tmp; | 1067 | open_files = tmp; |
| 1067 | spin_unlock_irqrestore(&i2o_config_lock, flags); | 1068 | spin_unlock_irqrestore(&i2o_config_lock, flags); |
| 1068 | unlock_kernel(); | 1069 | mutex_unlock(&i2o_cfg_mutex); |
| 1069 | 1070 | ||
| 1070 | return 0; | 1071 | return 0; |
| 1071 | } | 1072 | } |
| @@ -1076,14 +1077,14 @@ static int cfg_fasync(int fd, struct file *fp, int on) | |||
| 1076 | struct i2o_cfg_info *p; | 1077 | struct i2o_cfg_info *p; |
| 1077 | int ret = -EBADF; | 1078 | int ret = -EBADF; |
| 1078 | 1079 | ||
| 1079 | lock_kernel(); | 1080 | mutex_lock(&i2o_cfg_mutex); |
| 1080 | for (p = open_files; p; p = p->next) | 1081 | for (p = open_files; p; p = p->next) |
| 1081 | if (p->q_id == id) | 1082 | if (p->q_id == id) |
| 1082 | break; | 1083 | break; |
| 1083 | 1084 | ||
| 1084 | if (p) | 1085 | if (p) |
| 1085 | ret = fasync_helper(fd, fp, on, &p->fasync); | 1086 | ret = fasync_helper(fd, fp, on, &p->fasync); |
| 1086 | unlock_kernel(); | 1087 | mutex_unlock(&i2o_cfg_mutex); |
| 1087 | return ret; | 1088 | return ret; |
| 1088 | } | 1089 | } |
| 1089 | 1090 | ||
| @@ -1093,7 +1094,7 @@ static int cfg_release(struct inode *inode, struct file *file) | |||
| 1093 | struct i2o_cfg_info *p, **q; | 1094 | struct i2o_cfg_info *p, **q; |
| 1094 | unsigned long flags; | 1095 | unsigned long flags; |
| 1095 | 1096 | ||
| 1096 | lock_kernel(); | 1097 | mutex_lock(&i2o_cfg_mutex); |
| 1097 | spin_lock_irqsave(&i2o_config_lock, flags); | 1098 | spin_lock_irqsave(&i2o_config_lock, flags); |
| 1098 | for (q = &open_files; (p = *q) != NULL; q = &p->next) { | 1099 | for (q = &open_files; (p = *q) != NULL; q = &p->next) { |
| 1099 | if (p->q_id == id) { | 1100 | if (p->q_id == id) { |
| @@ -1103,7 +1104,7 @@ static int cfg_release(struct inode *inode, struct file *file) | |||
| 1103 | } | 1104 | } |
| 1104 | } | 1105 | } |
| 1105 | spin_unlock_irqrestore(&i2o_config_lock, flags); | 1106 | spin_unlock_irqrestore(&i2o_config_lock, flags); |
| 1106 | unlock_kernel(); | 1107 | mutex_unlock(&i2o_cfg_mutex); |
| 1107 | 1108 | ||
| 1108 | return 0; | 1109 | return 0; |
| 1109 | } | 1110 | } |
diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c index e20b7bdd4c78..09a139f61ca4 100644 --- a/drivers/scsi/3w-9xxx.c +++ b/drivers/scsi/3w-9xxx.c | |||
| @@ -92,7 +92,6 @@ | |||
| 92 | #include <linux/pci.h> | 92 | #include <linux/pci.h> |
| 93 | #include <linux/time.h> | 93 | #include <linux/time.h> |
| 94 | #include <linux/mutex.h> | 94 | #include <linux/mutex.h> |
| 95 | #include <linux/smp_lock.h> | ||
| 96 | #include <linux/slab.h> | 95 | #include <linux/slab.h> |
| 97 | #include <asm/io.h> | 96 | #include <asm/io.h> |
| 98 | #include <asm/irq.h> | 97 | #include <asm/irq.h> |
| @@ -105,6 +104,7 @@ | |||
| 105 | 104 | ||
| 106 | /* Globals */ | 105 | /* Globals */ |
| 107 | #define TW_DRIVER_VERSION "2.26.02.014" | 106 | #define TW_DRIVER_VERSION "2.26.02.014" |
| 107 | static DEFINE_MUTEX(twa_chrdev_mutex); | ||
| 108 | static TW_Device_Extension *twa_device_extension_list[TW_MAX_SLOT]; | 108 | static TW_Device_Extension *twa_device_extension_list[TW_MAX_SLOT]; |
| 109 | static unsigned int twa_device_extension_count; | 109 | static unsigned int twa_device_extension_count; |
| 110 | static int twa_major = -1; | 110 | static int twa_major = -1; |
| @@ -658,7 +658,7 @@ static long twa_chrdev_ioctl(struct file *file, unsigned int cmd, unsigned long | |||
| 658 | int retval = TW_IOCTL_ERROR_OS_EFAULT; | 658 | int retval = TW_IOCTL_ERROR_OS_EFAULT; |
| 659 | void __user *argp = (void __user *)arg; | 659 | void __user *argp = (void __user *)arg; |
| 660 | 660 | ||
| 661 | lock_kernel(); | 661 | mutex_lock(&twa_chrdev_mutex); |
| 662 | 662 | ||
| 663 | /* Only let one of these through at a time */ | 663 | /* Only let one of these through at a time */ |
| 664 | if (mutex_lock_interruptible(&tw_dev->ioctl_lock)) { | 664 | if (mutex_lock_interruptible(&tw_dev->ioctl_lock)) { |
| @@ -879,7 +879,7 @@ out3: | |||
| 879 | out2: | 879 | out2: |
| 880 | mutex_unlock(&tw_dev->ioctl_lock); | 880 | mutex_unlock(&tw_dev->ioctl_lock); |
| 881 | out: | 881 | out: |
| 882 | unlock_kernel(); | 882 | mutex_unlock(&twa_chrdev_mutex); |
| 883 | return retval; | 883 | return retval; |
| 884 | } /* End twa_chrdev_ioctl() */ | 884 | } /* End twa_chrdev_ioctl() */ |
| 885 | 885 | ||
| @@ -890,7 +890,6 @@ static int twa_chrdev_open(struct inode *inode, struct file *file) | |||
| 890 | unsigned int minor_number; | 890 | unsigned int minor_number; |
| 891 | int retval = TW_IOCTL_ERROR_OS_ENODEV; | 891 | int retval = TW_IOCTL_ERROR_OS_ENODEV; |
| 892 | 892 | ||
| 893 | cycle_kernel_lock(); | ||
| 894 | minor_number = iminor(inode); | 893 | minor_number = iminor(inode); |
| 895 | if (minor_number >= twa_device_extension_count) | 894 | if (minor_number >= twa_device_extension_count) |
| 896 | goto out; | 895 | goto out; |
diff --git a/drivers/scsi/3w-sas.c b/drivers/scsi/3w-sas.c index f481e734aad4..7e5f2385e3e6 100644 --- a/drivers/scsi/3w-sas.c +++ b/drivers/scsi/3w-sas.c | |||
| @@ -64,7 +64,6 @@ | |||
| 64 | #include <linux/pci.h> | 64 | #include <linux/pci.h> |
| 65 | #include <linux/time.h> | 65 | #include <linux/time.h> |
| 66 | #include <linux/mutex.h> | 66 | #include <linux/mutex.h> |
| 67 | #include <linux/smp_lock.h> | ||
| 68 | #include <linux/slab.h> | 67 | #include <linux/slab.h> |
| 69 | #include <asm/io.h> | 68 | #include <asm/io.h> |
| 70 | #include <asm/irq.h> | 69 | #include <asm/irq.h> |
| @@ -77,6 +76,7 @@ | |||
| 77 | 76 | ||
| 78 | /* Globals */ | 77 | /* Globals */ |
| 79 | #define TW_DRIVER_VERSION "3.26.02.000" | 78 | #define TW_DRIVER_VERSION "3.26.02.000" |
| 79 | static DEFINE_MUTEX(twl_chrdev_mutex); | ||
| 80 | static TW_Device_Extension *twl_device_extension_list[TW_MAX_SLOT]; | 80 | static TW_Device_Extension *twl_device_extension_list[TW_MAX_SLOT]; |
| 81 | static unsigned int twl_device_extension_count; | 81 | static unsigned int twl_device_extension_count; |
| 82 | static int twl_major = -1; | 82 | static int twl_major = -1; |
| @@ -764,7 +764,7 @@ static long twl_chrdev_ioctl(struct file *file, unsigned int cmd, unsigned long | |||
| 764 | int retval = -EFAULT; | 764 | int retval = -EFAULT; |
| 765 | void __user *argp = (void __user *)arg; | 765 | void __user *argp = (void __user *)arg; |
| 766 | 766 | ||
| 767 | lock_kernel(); | 767 | mutex_lock(&twl_chrdev_mutex); |
| 768 | 768 | ||
| 769 | /* Only let one of these through at a time */ | 769 | /* Only let one of these through at a time */ |
| 770 | if (mutex_lock_interruptible(&tw_dev->ioctl_lock)) { | 770 | if (mutex_lock_interruptible(&tw_dev->ioctl_lock)) { |
| @@ -861,7 +861,7 @@ out3: | |||
| 861 | out2: | 861 | out2: |
| 862 | mutex_unlock(&tw_dev->ioctl_lock); | 862 | mutex_unlock(&tw_dev->ioctl_lock); |
| 863 | out: | 863 | out: |
| 864 | unlock_kernel(); | 864 | mutex_unlock(&twl_chrdev_mutex); |
| 865 | return retval; | 865 | return retval; |
| 866 | } /* End twl_chrdev_ioctl() */ | 866 | } /* End twl_chrdev_ioctl() */ |
| 867 | 867 | ||
| @@ -876,7 +876,6 @@ static int twl_chrdev_open(struct inode *inode, struct file *file) | |||
| 876 | goto out; | 876 | goto out; |
| 877 | } | 877 | } |
| 878 | 878 | ||
| 879 | cycle_kernel_lock(); | ||
| 880 | minor_number = iminor(inode); | 879 | minor_number = iminor(inode); |
| 881 | if (minor_number >= twl_device_extension_count) | 880 | if (minor_number >= twl_device_extension_count) |
| 882 | goto out; | 881 | goto out; |
diff --git a/drivers/scsi/3w-xxxx.c b/drivers/scsi/3w-xxxx.c index 30d735ad35b5..081c864c11d2 100644 --- a/drivers/scsi/3w-xxxx.c +++ b/drivers/scsi/3w-xxxx.c | |||
| @@ -199,7 +199,6 @@ | |||
| 199 | 199 | ||
| 200 | #include <linux/module.h> | 200 | #include <linux/module.h> |
| 201 | #include <linux/reboot.h> | 201 | #include <linux/reboot.h> |
| 202 | #include <linux/smp_lock.h> | ||
| 203 | #include <linux/spinlock.h> | 202 | #include <linux/spinlock.h> |
| 204 | #include <linux/interrupt.h> | 203 | #include <linux/interrupt.h> |
| 205 | #include <linux/moduleparam.h> | 204 | #include <linux/moduleparam.h> |
| @@ -221,6 +220,7 @@ | |||
| 221 | 220 | ||
| 222 | /* Globals */ | 221 | /* Globals */ |
| 223 | #define TW_DRIVER_VERSION "1.26.02.003" | 222 | #define TW_DRIVER_VERSION "1.26.02.003" |
| 223 | static DEFINE_MUTEX(tw_mutex); | ||
| 224 | static TW_Device_Extension *tw_device_extension_list[TW_MAX_SLOT]; | 224 | static TW_Device_Extension *tw_device_extension_list[TW_MAX_SLOT]; |
| 225 | static int tw_device_extension_count = 0; | 225 | static int tw_device_extension_count = 0; |
| 226 | static int twe_major = -1; | 226 | static int twe_major = -1; |
| @@ -900,10 +900,10 @@ static long tw_chrdev_ioctl(struct file *file, unsigned int cmd, unsigned long a | |||
| 900 | 900 | ||
| 901 | dprintk(KERN_WARNING "3w-xxxx: tw_chrdev_ioctl()\n"); | 901 | dprintk(KERN_WARNING "3w-xxxx: tw_chrdev_ioctl()\n"); |
| 902 | 902 | ||
| 903 | lock_kernel(); | 903 | mutex_lock(&tw_mutex); |
| 904 | /* Only let one of these through at a time */ | 904 | /* Only let one of these through at a time */ |
| 905 | if (mutex_lock_interruptible(&tw_dev->ioctl_lock)) { | 905 | if (mutex_lock_interruptible(&tw_dev->ioctl_lock)) { |
| 906 | unlock_kernel(); | 906 | mutex_unlock(&tw_mutex); |
| 907 | return -EINTR; | 907 | return -EINTR; |
| 908 | } | 908 | } |
| 909 | 909 | ||
| @@ -1034,7 +1034,7 @@ out2: | |||
| 1034 | dma_free_coherent(&tw_dev->tw_pci_dev->dev, data_buffer_length_adjusted+sizeof(TW_New_Ioctl) - 1, cpu_addr, dma_handle); | 1034 | dma_free_coherent(&tw_dev->tw_pci_dev->dev, data_buffer_length_adjusted+sizeof(TW_New_Ioctl) - 1, cpu_addr, dma_handle); |
| 1035 | out: | 1035 | out: |
| 1036 | mutex_unlock(&tw_dev->ioctl_lock); | 1036 | mutex_unlock(&tw_dev->ioctl_lock); |
| 1037 | unlock_kernel(); | 1037 | mutex_unlock(&tw_mutex); |
| 1038 | return retval; | 1038 | return retval; |
| 1039 | } /* End tw_chrdev_ioctl() */ | 1039 | } /* End tw_chrdev_ioctl() */ |
| 1040 | 1040 | ||
| @@ -1044,7 +1044,6 @@ static int tw_chrdev_open(struct inode *inode, struct file *file) | |||
| 1044 | { | 1044 | { |
| 1045 | unsigned int minor_number; | 1045 | unsigned int minor_number; |
| 1046 | 1046 | ||
| 1047 | cycle_kernel_lock(); | ||
| 1048 | dprintk(KERN_WARNING "3w-xxxx: tw_ioctl_open()\n"); | 1047 | dprintk(KERN_WARNING "3w-xxxx: tw_ioctl_open()\n"); |
| 1049 | 1048 | ||
| 1050 | minor_number = iminor(inode); | 1049 | minor_number = iminor(inode); |
diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c index cad6f9abaeb9..6e233362dd7b 100644 --- a/drivers/scsi/aacraid/linit.c +++ b/drivers/scsi/aacraid/linit.c | |||
| @@ -38,7 +38,7 @@ | |||
| 38 | #include <linux/moduleparam.h> | 38 | #include <linux/moduleparam.h> |
| 39 | #include <linux/pci.h> | 39 | #include <linux/pci.h> |
| 40 | #include <linux/slab.h> | 40 | #include <linux/slab.h> |
| 41 | #include <linux/smp_lock.h> | 41 | #include <linux/mutex.h> |
| 42 | #include <linux/spinlock.h> | 42 | #include <linux/spinlock.h> |
| 43 | #include <linux/syscalls.h> | 43 | #include <linux/syscalls.h> |
| 44 | #include <linux/delay.h> | 44 | #include <linux/delay.h> |
| @@ -76,6 +76,7 @@ MODULE_DESCRIPTION("Dell PERC2, 2/Si, 3/Si, 3/Di, " | |||
| 76 | MODULE_LICENSE("GPL"); | 76 | MODULE_LICENSE("GPL"); |
| 77 | MODULE_VERSION(AAC_DRIVER_FULL_VERSION); | 77 | MODULE_VERSION(AAC_DRIVER_FULL_VERSION); |
| 78 | 78 | ||
| 79 | static DEFINE_MUTEX(aac_mutex); | ||
| 79 | static LIST_HEAD(aac_devices); | 80 | static LIST_HEAD(aac_devices); |
| 80 | static int aac_cfg_major = -1; | 81 | static int aac_cfg_major = -1; |
| 81 | char aac_driver_version[] = AAC_DRIVER_FULL_VERSION; | 82 | char aac_driver_version[] = AAC_DRIVER_FULL_VERSION; |
| @@ -678,7 +679,7 @@ static int aac_cfg_open(struct inode *inode, struct file *file) | |||
| 678 | unsigned minor_number = iminor(inode); | 679 | unsigned minor_number = iminor(inode); |
| 679 | int err = -ENODEV; | 680 | int err = -ENODEV; |
| 680 | 681 | ||
| 681 | lock_kernel(); /* BKL pushdown: nothing else protects this list */ | 682 | mutex_lock(&aac_mutex); /* BKL pushdown: nothing else protects this list */ |
| 682 | list_for_each_entry(aac, &aac_devices, entry) { | 683 | list_for_each_entry(aac, &aac_devices, entry) { |
| 683 | if (aac->id == minor_number) { | 684 | if (aac->id == minor_number) { |
| 684 | file->private_data = aac; | 685 | file->private_data = aac; |
| @@ -686,7 +687,7 @@ static int aac_cfg_open(struct inode *inode, struct file *file) | |||
| 686 | break; | 687 | break; |
| 687 | } | 688 | } |
| 688 | } | 689 | } |
| 689 | unlock_kernel(); | 690 | mutex_unlock(&aac_mutex); |
| 690 | 691 | ||
| 691 | return err; | 692 | return err; |
| 692 | } | 693 | } |
| @@ -711,9 +712,9 @@ static long aac_cfg_ioctl(struct file *file, | |||
| 711 | int ret; | 712 | int ret; |
| 712 | if (!capable(CAP_SYS_RAWIO)) | 713 | if (!capable(CAP_SYS_RAWIO)) |
| 713 | return -EPERM; | 714 | return -EPERM; |
| 714 | lock_kernel(); | 715 | mutex_lock(&aac_mutex); |
| 715 | ret = aac_do_ioctl(file->private_data, cmd, (void __user *)arg); | 716 | ret = aac_do_ioctl(file->private_data, cmd, (void __user *)arg); |
| 716 | unlock_kernel(); | 717 | mutex_unlock(&aac_mutex); |
| 717 | 718 | ||
| 718 | return ret; | 719 | return ret; |
| 719 | } | 720 | } |
| @@ -722,7 +723,7 @@ static long aac_cfg_ioctl(struct file *file, | |||
| 722 | static long aac_compat_do_ioctl(struct aac_dev *dev, unsigned cmd, unsigned long arg) | 723 | static long aac_compat_do_ioctl(struct aac_dev *dev, unsigned cmd, unsigned long arg) |
| 723 | { | 724 | { |
| 724 | long ret; | 725 | long ret; |
| 725 | lock_kernel(); | 726 | mutex_lock(&aac_mutex); |
| 726 | switch (cmd) { | 727 | switch (cmd) { |
| 727 | case FSACTL_MINIPORT_REV_CHECK: | 728 | case FSACTL_MINIPORT_REV_CHECK: |
| 728 | case FSACTL_SENDFIB: | 729 | case FSACTL_SENDFIB: |
| @@ -756,7 +757,7 @@ static long aac_compat_do_ioctl(struct aac_dev *dev, unsigned cmd, unsigned long | |||
| 756 | ret = -ENOIOCTLCMD; | 757 | ret = -ENOIOCTLCMD; |
| 757 | break; | 758 | break; |
| 758 | } | 759 | } |
| 759 | unlock_kernel(); | 760 | mutex_unlock(&aac_mutex); |
| 760 | return ret; | 761 | return ret; |
| 761 | } | 762 | } |
| 762 | 763 | ||
diff --git a/drivers/scsi/ch.c b/drivers/scsi/ch.c index d6532187f616..e805c8fda239 100644 --- a/drivers/scsi/ch.c +++ b/drivers/scsi/ch.c | |||
| @@ -22,7 +22,6 @@ | |||
| 22 | #include <linux/chio.h> /* here are all the ioctls */ | 22 | #include <linux/chio.h> /* here are all the ioctls */ |
| 23 | #include <linux/mutex.h> | 23 | #include <linux/mutex.h> |
| 24 | #include <linux/idr.h> | 24 | #include <linux/idr.h> |
| 25 | #include <linux/smp_lock.h> | ||
| 26 | #include <linux/slab.h> | 25 | #include <linux/slab.h> |
| 27 | 26 | ||
| 28 | #include <scsi/scsi.h> | 27 | #include <scsi/scsi.h> |
| @@ -44,6 +43,7 @@ MODULE_LICENSE("GPL"); | |||
| 44 | MODULE_ALIAS_CHARDEV_MAJOR(SCSI_CHANGER_MAJOR); | 43 | MODULE_ALIAS_CHARDEV_MAJOR(SCSI_CHANGER_MAJOR); |
| 45 | MODULE_ALIAS_SCSI_DEVICE(TYPE_MEDIUM_CHANGER); | 44 | MODULE_ALIAS_SCSI_DEVICE(TYPE_MEDIUM_CHANGER); |
| 46 | 45 | ||
| 46 | static DEFINE_MUTEX(ch_mutex); | ||
| 47 | static int init = 1; | 47 | static int init = 1; |
| 48 | module_param(init, int, 0444); | 48 | module_param(init, int, 0444); |
| 49 | MODULE_PARM_DESC(init, \ | 49 | MODULE_PARM_DESC(init, \ |
| @@ -581,19 +581,19 @@ ch_open(struct inode *inode, struct file *file) | |||
| 581 | scsi_changer *ch; | 581 | scsi_changer *ch; |
| 582 | int minor = iminor(inode); | 582 | int minor = iminor(inode); |
| 583 | 583 | ||
| 584 | lock_kernel(); | 584 | mutex_lock(&ch_mutex); |
| 585 | spin_lock(&ch_index_lock); | 585 | spin_lock(&ch_index_lock); |
| 586 | ch = idr_find(&ch_index_idr, minor); | 586 | ch = idr_find(&ch_index_idr, minor); |
| 587 | 587 | ||
| 588 | if (NULL == ch || scsi_device_get(ch->device)) { | 588 | if (NULL == ch || scsi_device_get(ch->device)) { |
| 589 | spin_unlock(&ch_index_lock); | 589 | spin_unlock(&ch_index_lock); |
| 590 | unlock_kernel(); | 590 | mutex_unlock(&ch_mutex); |
| 591 | return -ENXIO; | 591 | return -ENXIO; |
| 592 | } | 592 | } |
| 593 | spin_unlock(&ch_index_lock); | 593 | spin_unlock(&ch_index_lock); |
| 594 | 594 | ||
| 595 | file->private_data = ch; | 595 | file->private_data = ch; |
| 596 | unlock_kernel(); | 596 | mutex_unlock(&ch_mutex); |
| 597 | return 0; | 597 | return 0; |
| 598 | } | 598 | } |
| 599 | 599 | ||
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 | */ |
| 78 | static DEFINE_MUTEX(adpt_mutex); | ||
| 79 | static dpt_sig_S DPTI_sig = { | 79 | static 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 | } |
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 | ||
| 143 | static DEFINE_MUTEX(gdth_mutex); | ||
| 143 | static void gdth_delay(int milliseconds); | 144 | static void gdth_delay(int milliseconds); |
| 144 | static void gdth_eval_mapping(u32 size, u32 *cyls, int *heads, int *secs); | 145 | static void gdth_eval_mapping(u32 size, u32 *cyls, int *heads, int *secs); |
| 145 | static irqreturn_t gdth_interrupt(int irq, void *dev_id); | 146 | static 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 | } |
diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c index 0b6e3228610a..4d0cf5cd82cc 100644 --- a/drivers/scsi/megaraid.c +++ b/drivers/scsi/megaraid.c | |||
| @@ -46,7 +46,7 @@ | |||
| 46 | #include <linux/pci.h> | 46 | #include <linux/pci.h> |
| 47 | #include <linux/init.h> | 47 | #include <linux/init.h> |
| 48 | #include <linux/dma-mapping.h> | 48 | #include <linux/dma-mapping.h> |
| 49 | #include <linux/smp_lock.h> | 49 | #include <linux/mutex.h> |
| 50 | #include <linux/slab.h> | 50 | #include <linux/slab.h> |
| 51 | #include <scsi/scsicam.h> | 51 | #include <scsi/scsicam.h> |
| 52 | 52 | ||
| @@ -62,6 +62,7 @@ MODULE_DESCRIPTION ("LSI Logic MegaRAID legacy driver"); | |||
| 62 | MODULE_LICENSE ("GPL"); | 62 | MODULE_LICENSE ("GPL"); |
| 63 | MODULE_VERSION(MEGARAID_MODULE_VERSION); | 63 | MODULE_VERSION(MEGARAID_MODULE_VERSION); |
| 64 | 64 | ||
| 65 | static DEFINE_MUTEX(megadev_mutex); | ||
| 65 | static unsigned int max_cmd_per_lun = DEF_CMD_PER_LUN; | 66 | static unsigned int max_cmd_per_lun = DEF_CMD_PER_LUN; |
| 66 | module_param(max_cmd_per_lun, uint, 0); | 67 | module_param(max_cmd_per_lun, uint, 0); |
| 67 | MODULE_PARM_DESC(max_cmd_per_lun, "Maximum number of commands which can be issued to a single LUN (default=DEF_CMD_PER_LUN=63)"); | 68 | MODULE_PARM_DESC(max_cmd_per_lun, "Maximum number of commands which can be issued to a single LUN (default=DEF_CMD_PER_LUN=63)"); |
| @@ -3282,7 +3283,6 @@ mega_init_scb(adapter_t *adapter) | |||
| 3282 | static int | 3283 | static int |
| 3283 | megadev_open (struct inode *inode, struct file *filep) | 3284 | megadev_open (struct inode *inode, struct file *filep) |
| 3284 | { | 3285 | { |
| 3285 | cycle_kernel_lock(); | ||
| 3286 | /* | 3286 | /* |
| 3287 | * Only allow superuser to access private ioctl interface | 3287 | * Only allow superuser to access private ioctl interface |
| 3288 | */ | 3288 | */ |
| @@ -3701,9 +3701,9 @@ megadev_unlocked_ioctl(struct file *filep, unsigned int cmd, unsigned long arg) | |||
| 3701 | { | 3701 | { |
| 3702 | int ret; | 3702 | int ret; |
| 3703 | 3703 | ||
| 3704 | lock_kernel(); | 3704 | mutex_lock(&megadev_mutex); |
| 3705 | ret = megadev_ioctl(filep, cmd, arg); | 3705 | ret = megadev_ioctl(filep, cmd, arg); |
| 3706 | unlock_kernel(); | 3706 | mutex_unlock(&megadev_mutex); |
| 3707 | 3707 | ||
| 3708 | return ret; | 3708 | return ret; |
| 3709 | } | 3709 | } |
diff --git a/drivers/scsi/megaraid/megaraid_mm.c b/drivers/scsi/megaraid/megaraid_mm.c index 41f82f76d884..42770a1e7b8a 100644 --- a/drivers/scsi/megaraid/megaraid_mm.c +++ b/drivers/scsi/megaraid/megaraid_mm.c | |||
| @@ -16,11 +16,12 @@ | |||
| 16 | */ | 16 | */ |
| 17 | #include <linux/sched.h> | 17 | #include <linux/sched.h> |
| 18 | #include <linux/slab.h> | 18 | #include <linux/slab.h> |
| 19 | #include <linux/smp_lock.h> | 19 | #include <linux/mutex.h> |
| 20 | #include "megaraid_mm.h" | 20 | #include "megaraid_mm.h" |
| 21 | 21 | ||
| 22 | 22 | ||
| 23 | // Entry points for char node driver | 23 | // Entry points for char node driver |
| 24 | static DEFINE_MUTEX(mraid_mm_mutex); | ||
| 24 | static int mraid_mm_open(struct inode *, struct file *); | 25 | static int mraid_mm_open(struct inode *, struct file *); |
| 25 | static long mraid_mm_unlocked_ioctl(struct file *, uint, unsigned long); | 26 | static long mraid_mm_unlocked_ioctl(struct file *, uint, unsigned long); |
| 26 | 27 | ||
| @@ -98,7 +99,6 @@ mraid_mm_open(struct inode *inode, struct file *filep) | |||
| 98 | */ | 99 | */ |
| 99 | if (!capable(CAP_SYS_ADMIN)) return (-EACCES); | 100 | if (!capable(CAP_SYS_ADMIN)) return (-EACCES); |
| 100 | 101 | ||
| 101 | cycle_kernel_lock(); | ||
| 102 | return 0; | 102 | return 0; |
| 103 | } | 103 | } |
| 104 | 104 | ||
| @@ -224,9 +224,9 @@ mraid_mm_unlocked_ioctl(struct file *filep, unsigned int cmd, | |||
| 224 | int err; | 224 | int err; |
| 225 | 225 | ||
| 226 | /* inconsistant: mraid_mm_compat_ioctl doesn't take the BKL */ | 226 | /* inconsistant: mraid_mm_compat_ioctl doesn't take the BKL */ |
| 227 | lock_kernel(); | 227 | mutex_lock(&mraid_mm_mutex); |
| 228 | err = mraid_mm_ioctl(filep, cmd, arg); | 228 | err = mraid_mm_ioctl(filep, cmd, arg); |
| 229 | unlock_kernel(); | 229 | mutex_unlock(&mraid_mm_mutex); |
| 230 | 230 | ||
| 231 | return err; | 231 | return err; |
| 232 | } | 232 | } |
diff --git a/drivers/scsi/megaraid/megaraid_sas.c b/drivers/scsi/megaraid/megaraid_sas.c index 99e4478c3f3e..c4a595d8d23a 100644 --- a/drivers/scsi/megaraid/megaraid_sas.c +++ b/drivers/scsi/megaraid/megaraid_sas.c | |||
| @@ -33,7 +33,6 @@ | |||
| 33 | #include <linux/spinlock.h> | 33 | #include <linux/spinlock.h> |
| 34 | #include <linux/interrupt.h> | 34 | #include <linux/interrupt.h> |
| 35 | #include <linux/delay.h> | 35 | #include <linux/delay.h> |
| 36 | #include <linux/smp_lock.h> | ||
| 37 | #include <linux/uio.h> | 36 | #include <linux/uio.h> |
| 38 | #include <linux/slab.h> | 37 | #include <linux/slab.h> |
| 39 | #include <asm/uaccess.h> | 38 | #include <asm/uaccess.h> |
| @@ -3557,7 +3556,6 @@ static void megasas_shutdown(struct pci_dev *pdev) | |||
| 3557 | */ | 3556 | */ |
| 3558 | static int megasas_mgmt_open(struct inode *inode, struct file *filep) | 3557 | static int megasas_mgmt_open(struct inode *inode, struct file *filep) |
| 3559 | { | 3558 | { |
| 3560 | cycle_kernel_lock(); | ||
| 3561 | /* | 3559 | /* |
| 3562 | * Allow only those users with admin rights | 3560 | * Allow only those users with admin rights |
| 3563 | */ | 3561 | */ |
diff --git a/drivers/scsi/mpt2sas/mpt2sas_ctl.c b/drivers/scsi/mpt2sas/mpt2sas_ctl.c index b774973f0765..31cf126ed440 100644 --- a/drivers/scsi/mpt2sas/mpt2sas_ctl.c +++ b/drivers/scsi/mpt2sas/mpt2sas_ctl.c | |||
| @@ -51,7 +51,7 @@ | |||
| 51 | #include <linux/types.h> | 51 | #include <linux/types.h> |
| 52 | #include <linux/pci.h> | 52 | #include <linux/pci.h> |
| 53 | #include <linux/delay.h> | 53 | #include <linux/delay.h> |
| 54 | #include <linux/smp_lock.h> | 54 | #include <linux/mutex.h> |
| 55 | #include <linux/compat.h> | 55 | #include <linux/compat.h> |
| 56 | #include <linux/poll.h> | 56 | #include <linux/poll.h> |
| 57 | 57 | ||
| @@ -61,6 +61,7 @@ | |||
| 61 | #include "mpt2sas_base.h" | 61 | #include "mpt2sas_base.h" |
| 62 | #include "mpt2sas_ctl.h" | 62 | #include "mpt2sas_ctl.h" |
| 63 | 63 | ||
| 64 | static DEFINE_MUTEX(_ctl_mutex); | ||
| 64 | static struct fasync_struct *async_queue; | 65 | static struct fasync_struct *async_queue; |
| 65 | static DECLARE_WAIT_QUEUE_HEAD(ctl_poll_wait); | 66 | static DECLARE_WAIT_QUEUE_HEAD(ctl_poll_wait); |
| 66 | 67 | ||
| @@ -2238,9 +2239,9 @@ _ctl_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
| 2238 | { | 2239 | { |
| 2239 | long ret; | 2240 | long ret; |
| 2240 | 2241 | ||
| 2241 | lock_kernel(); | 2242 | mutex_lock(&_ctl_mutex); |
| 2242 | ret = _ctl_ioctl_main(file, cmd, (void __user *)arg); | 2243 | ret = _ctl_ioctl_main(file, cmd, (void __user *)arg); |
| 2243 | unlock_kernel(); | 2244 | mutex_unlock(&_ctl_mutex); |
| 2244 | return ret; | 2245 | return ret; |
| 2245 | } | 2246 | } |
| 2246 | 2247 | ||
| @@ -2309,12 +2310,12 @@ _ctl_ioctl_compat(struct file *file, unsigned cmd, unsigned long arg) | |||
| 2309 | { | 2310 | { |
| 2310 | long ret; | 2311 | long ret; |
| 2311 | 2312 | ||
| 2312 | lock_kernel(); | 2313 | mutex_lock(&_ctl_mutex); |
| 2313 | if (cmd == MPT2COMMAND32) | 2314 | if (cmd == MPT2COMMAND32) |
| 2314 | ret = _ctl_compat_mpt_command(file, cmd, arg); | 2315 | ret = _ctl_compat_mpt_command(file, cmd, arg); |
| 2315 | else | 2316 | else |
| 2316 | ret = _ctl_ioctl_main(file, cmd, (void __user *)arg); | 2317 | ret = _ctl_ioctl_main(file, cmd, (void __user *)arg); |
| 2317 | unlock_kernel(); | 2318 | mutex_unlock(&_ctl_mutex); |
| 2318 | return ret; | 2319 | return ret; |
| 2319 | } | 2320 | } |
| 2320 | #endif | 2321 | #endif |
diff --git a/drivers/scsi/osst.c b/drivers/scsi/osst.c index 278b352ae78d..54de1d1af1a7 100644 --- a/drivers/scsi/osst.c +++ b/drivers/scsi/osst.c | |||
| @@ -51,7 +51,7 @@ static const char * osst_version = "0.99.4"; | |||
| 51 | #include <linux/moduleparam.h> | 51 | #include <linux/moduleparam.h> |
| 52 | #include <linux/delay.h> | 52 | #include <linux/delay.h> |
| 53 | #include <linux/jiffies.h> | 53 | #include <linux/jiffies.h> |
| 54 | #include <linux/smp_lock.h> | 54 | #include <linux/mutex.h> |
| 55 | #include <asm/uaccess.h> | 55 | #include <asm/uaccess.h> |
| 56 | #include <asm/dma.h> | 56 | #include <asm/dma.h> |
| 57 | #include <asm/system.h> | 57 | #include <asm/system.h> |
| @@ -80,6 +80,7 @@ static const char * osst_version = "0.99.4"; | |||
| 80 | #include "osst_options.h" | 80 | #include "osst_options.h" |
| 81 | #include "osst_detect.h" | 81 | #include "osst_detect.h" |
| 82 | 82 | ||
| 83 | static DEFINE_MUTEX(osst_int_mutex); | ||
| 83 | static int max_dev = 0; | 84 | static int max_dev = 0; |
| 84 | static int write_threshold_kbs = 0; | 85 | static int write_threshold_kbs = 0; |
| 85 | static int max_sg_segs = 0; | 86 | static int max_sg_segs = 0; |
| @@ -4807,9 +4808,9 @@ static int os_scsi_tape_open(struct inode * inode, struct file * filp) | |||
| 4807 | { | 4808 | { |
| 4808 | int ret; | 4809 | int ret; |
| 4809 | 4810 | ||
| 4810 | lock_kernel(); | 4811 | mutex_lock(&osst_int_mutex); |
| 4811 | ret = __os_scsi_tape_open(inode, filp); | 4812 | ret = __os_scsi_tape_open(inode, filp); |
| 4812 | unlock_kernel(); | 4813 | mutex_unlock(&osst_int_mutex); |
| 4813 | return ret; | 4814 | return ret; |
| 4814 | } | 4815 | } |
| 4815 | 4816 | ||
| @@ -4943,9 +4944,9 @@ static long osst_ioctl(struct file * file, | |||
| 4943 | char * name = tape_name(STp); | 4944 | char * name = tape_name(STp); |
| 4944 | void __user * p = (void __user *)arg; | 4945 | void __user * p = (void __user *)arg; |
| 4945 | 4946 | ||
| 4946 | lock_kernel(); | 4947 | mutex_lock(&osst_int_mutex); |
| 4947 | if (mutex_lock_interruptible(&STp->lock)) { | 4948 | if (mutex_lock_interruptible(&STp->lock)) { |
| 4948 | unlock_kernel(); | 4949 | mutex_unlock(&osst_int_mutex); |
| 4949 | return -ERESTARTSYS; | 4950 | return -ERESTARTSYS; |
| 4950 | } | 4951 | } |
| 4951 | 4952 | ||
| @@ -5260,14 +5261,14 @@ static long osst_ioctl(struct file * file, | |||
| 5260 | mutex_unlock(&STp->lock); | 5261 | mutex_unlock(&STp->lock); |
| 5261 | 5262 | ||
| 5262 | retval = scsi_ioctl(STp->device, cmd_in, p); | 5263 | retval = scsi_ioctl(STp->device, cmd_in, p); |
| 5263 | unlock_kernel(); | 5264 | mutex_unlock(&osst_int_mutex); |
| 5264 | return retval; | 5265 | return retval; |
| 5265 | 5266 | ||
| 5266 | out: | 5267 | out: |
| 5267 | if (SRpnt) osst_release_request(SRpnt); | 5268 | if (SRpnt) osst_release_request(SRpnt); |
| 5268 | 5269 | ||
| 5269 | mutex_unlock(&STp->lock); | 5270 | mutex_unlock(&STp->lock); |
| 5270 | unlock_kernel(); | 5271 | mutex_unlock(&osst_int_mutex); |
| 5271 | 5272 | ||
| 5272 | return retval; | 5273 | return retval; |
| 5273 | } | 5274 | } |
diff --git a/drivers/scsi/scsi_tgt_if.c b/drivers/scsi/scsi_tgt_if.c index a87e21c35ef2..02034460babb 100644 --- a/drivers/scsi/scsi_tgt_if.c +++ b/drivers/scsi/scsi_tgt_if.c | |||
| @@ -22,7 +22,6 @@ | |||
| 22 | #include <linux/miscdevice.h> | 22 | #include <linux/miscdevice.h> |
| 23 | #include <linux/gfp.h> | 23 | #include <linux/gfp.h> |
| 24 | #include <linux/file.h> | 24 | #include <linux/file.h> |
| 25 | #include <linux/smp_lock.h> | ||
| 26 | #include <net/tcp.h> | 25 | #include <net/tcp.h> |
| 27 | #include <scsi/scsi.h> | 26 | #include <scsi/scsi.h> |
| 28 | #include <scsi/scsi_cmnd.h> | 27 | #include <scsi/scsi_cmnd.h> |
| @@ -323,7 +322,6 @@ static int tgt_open(struct inode *inode, struct file *file) | |||
| 323 | { | 322 | { |
| 324 | tx_ring.tr_idx = rx_ring.tr_idx = 0; | 323 | tx_ring.tr_idx = rx_ring.tr_idx = 0; |
| 325 | 324 | ||
| 326 | cycle_kernel_lock(); | ||
| 327 | return 0; | 325 | return 0; |
| 328 | } | 326 | } |
| 329 | 327 | ||
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index 78d616315d8e..b5507d59b5a6 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c | |||
| @@ -49,7 +49,7 @@ static int sg_version_num = 30534; /* 2 digits for each component */ | |||
| 49 | #include <linux/blkdev.h> | 49 | #include <linux/blkdev.h> |
| 50 | #include <linux/delay.h> | 50 | #include <linux/delay.h> |
| 51 | #include <linux/blktrace_api.h> | 51 | #include <linux/blktrace_api.h> |
| 52 | #include <linux/smp_lock.h> | 52 | #include <linux/mutex.h> |
| 53 | 53 | ||
| 54 | #include "scsi.h" | 54 | #include "scsi.h" |
| 55 | #include <scsi/scsi_dbg.h> | 55 | #include <scsi/scsi_dbg.h> |
| @@ -103,6 +103,8 @@ static int scatter_elem_sz_prev = SG_SCATTER_SZ; | |||
| 103 | static int sg_add(struct device *, struct class_interface *); | 103 | static int sg_add(struct device *, struct class_interface *); |
| 104 | static void sg_remove(struct device *, struct class_interface *); | 104 | static void sg_remove(struct device *, struct class_interface *); |
| 105 | 105 | ||
| 106 | static DEFINE_MUTEX(sg_mutex); | ||
| 107 | |||
| 106 | static DEFINE_IDR(sg_index_idr); | 108 | static DEFINE_IDR(sg_index_idr); |
| 107 | static DEFINE_RWLOCK(sg_index_lock); /* Also used to lock | 109 | static DEFINE_RWLOCK(sg_index_lock); /* Also used to lock |
| 108 | file descriptor list for device */ | 110 | file descriptor list for device */ |
| @@ -229,7 +231,7 @@ sg_open(struct inode *inode, struct file *filp) | |||
| 229 | int res; | 231 | int res; |
| 230 | int retval; | 232 | int retval; |
| 231 | 233 | ||
| 232 | lock_kernel(); | 234 | mutex_lock(&sg_mutex); |
| 233 | nonseekable_open(inode, filp); | 235 | nonseekable_open(inode, filp); |
| 234 | SCSI_LOG_TIMEOUT(3, printk("sg_open: dev=%d, flags=0x%x\n", dev, flags)); | 236 | SCSI_LOG_TIMEOUT(3, printk("sg_open: dev=%d, flags=0x%x\n", dev, flags)); |
| 235 | sdp = sg_get_dev(dev); | 237 | sdp = sg_get_dev(dev); |
| @@ -314,7 +316,7 @@ sdp_put: | |||
| 314 | sg_put: | 316 | sg_put: |
| 315 | if (sdp) | 317 | if (sdp) |
| 316 | sg_put_dev(sdp); | 318 | sg_put_dev(sdp); |
| 317 | unlock_kernel(); | 319 | mutex_unlock(&sg_mutex); |
| 318 | return retval; | 320 | return retval; |
| 319 | } | 321 | } |
| 320 | 322 | ||
| @@ -1092,9 +1094,9 @@ sg_unlocked_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg) | |||
| 1092 | { | 1094 | { |
| 1093 | int ret; | 1095 | int ret; |
| 1094 | 1096 | ||
| 1095 | lock_kernel(); | 1097 | mutex_lock(&sg_mutex); |
| 1096 | ret = sg_ioctl(filp, cmd_in, arg); | 1098 | ret = sg_ioctl(filp, cmd_in, arg); |
| 1097 | unlock_kernel(); | 1099 | mutex_unlock(&sg_mutex); |
| 1098 | 1100 | ||
| 1099 | return ret; | 1101 | return ret; |
| 1100 | } | 1102 | } |
