diff options
| author | Arnd Bergmann <arnd@arndb.de> | 2010-06-02 08:28:52 -0400 |
|---|---|---|
| committer | Arnd Bergmann <arnd@arndb.de> | 2010-10-05 09:01:10 -0400 |
| commit | 2a48fc0ab24241755dc93bfd4f01d68efab47f5a (patch) | |
| tree | fa9ae10ce89b26b7d8ae9ce24bdfda5e3007b763 | |
| parent | 613655fa39ff6957754fa8ceb8559980920eb8ee (diff) | |
block: autoconvert trivial BKL users to private mutex
The block device drivers have all gained new lock_kernel
calls from a recent pushdown, and some of the drivers
were already using the BKL before.
This turns the BKL into a set of per-driver mutexes.
Still need to check whether this is safe to do.
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>
43 files changed, 277 insertions, 250 deletions
diff --git a/block/bsg.c b/block/bsg.c index 82d58829ba5..ffd79ca25c0 100644 --- a/block/bsg.c +++ b/block/bsg.c | |||
| @@ -20,7 +20,6 @@ | |||
| 20 | #include <linux/uio.h> | 20 | #include <linux/uio.h> |
| 21 | #include <linux/idr.h> | 21 | #include <linux/idr.h> |
| 22 | #include <linux/bsg.h> | 22 | #include <linux/bsg.h> |
| 23 | #include <linux/smp_lock.h> | ||
| 24 | #include <linux/slab.h> | 23 | #include <linux/slab.h> |
| 25 | 24 | ||
| 26 | #include <scsi/scsi.h> | 25 | #include <scsi/scsi.h> |
| @@ -843,9 +842,7 @@ static int bsg_open(struct inode *inode, struct file *file) | |||
| 843 | { | 842 | { |
| 844 | struct bsg_device *bd; | 843 | struct bsg_device *bd; |
| 845 | 844 | ||
| 846 | lock_kernel(); | ||
| 847 | bd = bsg_get_device(inode, file); | 845 | bd = bsg_get_device(inode, file); |
| 848 | unlock_kernel(); | ||
| 849 | 846 | ||
| 850 | if (IS_ERR(bd)) | 847 | if (IS_ERR(bd)) |
| 851 | return PTR_ERR(bd); | 848 | return PTR_ERR(bd); |
diff --git a/drivers/block/DAC960.c b/drivers/block/DAC960.c index 4e2c367fec1..da0f6ddd762 100644 --- a/drivers/block/DAC960.c +++ b/drivers/block/DAC960.c | |||
| @@ -36,7 +36,7 @@ | |||
| 36 | #include <linux/ioport.h> | 36 | #include <linux/ioport.h> |
| 37 | #include <linux/mm.h> | 37 | #include <linux/mm.h> |
| 38 | #include <linux/slab.h> | 38 | #include <linux/slab.h> |
| 39 | #include <linux/smp_lock.h> | 39 | #include <linux/mutex.h> |
| 40 | #include <linux/proc_fs.h> | 40 | #include <linux/proc_fs.h> |
| 41 | #include <linux/seq_file.h> | 41 | #include <linux/seq_file.h> |
| 42 | #include <linux/reboot.h> | 42 | #include <linux/reboot.h> |
| @@ -54,6 +54,7 @@ | |||
| 54 | #define DAC960_GAM_MINOR 252 | 54 | #define DAC960_GAM_MINOR 252 |
| 55 | 55 | ||
| 56 | 56 | ||
| 57 | static DEFINE_MUTEX(DAC960_mutex); | ||
| 57 | static DAC960_Controller_T *DAC960_Controllers[DAC960_MaxControllers]; | 58 | static DAC960_Controller_T *DAC960_Controllers[DAC960_MaxControllers]; |
| 58 | static int DAC960_ControllerCount; | 59 | static int DAC960_ControllerCount; |
| 59 | static struct proc_dir_entry *DAC960_ProcDirectoryEntry; | 60 | static struct proc_dir_entry *DAC960_ProcDirectoryEntry; |
| @@ -81,7 +82,7 @@ static int DAC960_open(struct block_device *bdev, fmode_t mode) | |||
| 81 | int drive_nr = (long)disk->private_data; | 82 | int drive_nr = (long)disk->private_data; |
| 82 | int ret = -ENXIO; | 83 | int ret = -ENXIO; |
| 83 | 84 | ||
| 84 | lock_kernel(); | 85 | mutex_lock(&DAC960_mutex); |
| 85 | if (p->FirmwareType == DAC960_V1_Controller) { | 86 | if (p->FirmwareType == DAC960_V1_Controller) { |
| 86 | if (p->V1.LogicalDriveInformation[drive_nr]. | 87 | if (p->V1.LogicalDriveInformation[drive_nr]. |
| 87 | LogicalDriveState == DAC960_V1_LogicalDrive_Offline) | 88 | LogicalDriveState == DAC960_V1_LogicalDrive_Offline) |
| @@ -99,7 +100,7 @@ static int DAC960_open(struct block_device *bdev, fmode_t mode) | |||
| 99 | goto out; | 100 | goto out; |
| 100 | ret = 0; | 101 | ret = 0; |
| 101 | out: | 102 | out: |
| 102 | unlock_kernel(); | 103 | mutex_unlock(&DAC960_mutex); |
| 103 | return ret; | 104 | return ret; |
| 104 | } | 105 | } |
| 105 | 106 | ||
| @@ -6625,7 +6626,7 @@ static long DAC960_gam_ioctl(struct file *file, unsigned int Request, | |||
| 6625 | long ErrorCode = 0; | 6626 | long ErrorCode = 0; |
| 6626 | if (!capable(CAP_SYS_ADMIN)) return -EACCES; | 6627 | if (!capable(CAP_SYS_ADMIN)) return -EACCES; |
| 6627 | 6628 | ||
| 6628 | lock_kernel(); | 6629 | mutex_lock(&DAC960_mutex); |
| 6629 | switch (Request) | 6630 | switch (Request) |
| 6630 | { | 6631 | { |
| 6631 | case DAC960_IOCTL_GET_CONTROLLER_COUNT: | 6632 | case DAC960_IOCTL_GET_CONTROLLER_COUNT: |
| @@ -7056,7 +7057,7 @@ static long DAC960_gam_ioctl(struct file *file, unsigned int Request, | |||
| 7056 | default: | 7057 | default: |
| 7057 | ErrorCode = -ENOTTY; | 7058 | ErrorCode = -ENOTTY; |
| 7058 | } | 7059 | } |
| 7059 | unlock_kernel(); | 7060 | mutex_unlock(&DAC960_mutex); |
| 7060 | return ErrorCode; | 7061 | return ErrorCode; |
| 7061 | } | 7062 | } |
| 7062 | 7063 | ||
diff --git a/drivers/block/amiflop.c b/drivers/block/amiflop.c index 76f114f0bba..4b852c96226 100644 --- a/drivers/block/amiflop.c +++ b/drivers/block/amiflop.c | |||
| @@ -60,7 +60,7 @@ | |||
| 60 | #include <linux/hdreg.h> | 60 | #include <linux/hdreg.h> |
| 61 | #include <linux/delay.h> | 61 | #include <linux/delay.h> |
| 62 | #include <linux/init.h> | 62 | #include <linux/init.h> |
| 63 | #include <linux/smp_lock.h> | 63 | #include <linux/mutex.h> |
| 64 | #include <linux/amifdreg.h> | 64 | #include <linux/amifdreg.h> |
| 65 | #include <linux/amifd.h> | 65 | #include <linux/amifd.h> |
| 66 | #include <linux/buffer_head.h> | 66 | #include <linux/buffer_head.h> |
| @@ -109,6 +109,7 @@ | |||
| 109 | #define FD_HD_3 0x55555555 /* high-density 3.5" (1760K) drive */ | 109 | #define FD_HD_3 0x55555555 /* high-density 3.5" (1760K) drive */ |
| 110 | #define FD_DD_5 0xaaaaaaaa /* double-density 5.25" (440K) drive */ | 110 | #define FD_DD_5 0xaaaaaaaa /* double-density 5.25" (440K) drive */ |
| 111 | 111 | ||
| 112 | static DEFINE_MUTEX(amiflop_mutex); | ||
| 112 | static unsigned long int fd_def_df0 = FD_DD_3; /* default for df0 if it doesn't identify */ | 113 | static unsigned long int fd_def_df0 = FD_DD_3; /* default for df0 if it doesn't identify */ |
| 113 | 114 | ||
| 114 | module_param(fd_def_df0, ulong, 0); | 115 | module_param(fd_def_df0, ulong, 0); |
| @@ -1506,9 +1507,9 @@ static int fd_ioctl(struct block_device *bdev, fmode_t mode, | |||
| 1506 | { | 1507 | { |
| 1507 | int ret; | 1508 | int ret; |
| 1508 | 1509 | ||
| 1509 | lock_kernel(); | 1510 | mutex_lock(&amiflop_mutex); |
| 1510 | ret = fd_locked_ioctl(bdev, mode, cmd, param); | 1511 | ret = fd_locked_ioctl(bdev, mode, cmd, param); |
| 1511 | unlock_kernel(); | 1512 | mutex_unlock(&amiflop_mutex); |
| 1512 | 1513 | ||
| 1513 | return ret; | 1514 | return ret; |
| 1514 | } | 1515 | } |
| @@ -1555,11 +1556,11 @@ static int floppy_open(struct block_device *bdev, fmode_t mode) | |||
| 1555 | int old_dev; | 1556 | int old_dev; |
| 1556 | unsigned long flags; | 1557 | unsigned long flags; |
| 1557 | 1558 | ||
| 1558 | lock_kernel(); | 1559 | mutex_lock(&amiflop_mutex); |
| 1559 | old_dev = fd_device[drive]; | 1560 | old_dev = fd_device[drive]; |
| 1560 | |||
