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 /drivers/block/swim.c | |
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>
Diffstat (limited to 'drivers/block/swim.c')
-rw-r--r-- | drivers/block/swim.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/drivers/block/swim.c b/drivers/block/swim.c index 2e46815876df..75333d0a3327 100644 --- a/drivers/block/swim.c +++ b/drivers/block/swim.c | |||
@@ -20,7 +20,7 @@ | |||
20 | #include <linux/fd.h> | 20 | #include <linux/fd.h> |
21 | #include <linux/slab.h> | 21 | #include <linux/slab.h> |
22 | #include <linux/blkdev.h> | 22 | #include <linux/blkdev.h> |
23 | #include <linux/smp_lock.h> | 23 | #include <linux/mutex.h> |
24 | #include <linux/hdreg.h> | 24 | #include <linux/hdreg.h> |
25 | #include <linux/kernel.h> | 25 | #include <linux/kernel.h> |
26 | #include <linux/delay.h> | 26 | #include <linux/delay.h> |
@@ -222,6 +222,7 @@ extern int swim_read_sector_header(struct swim __iomem *base, | |||
222 | extern int swim_read_sector_data(struct swim __iomem *base, | 222 | extern int swim_read_sector_data(struct swim __iomem *base, |
223 | unsigned char *data); | 223 | unsigned char *data); |
224 | 224 | ||
225 | static DEFINE_MUTEX(swim_mutex); | ||
225 | static inline void set_swim_mode(struct swim __iomem *base, int enable) | 226 | static inline void set_swim_mode(struct swim __iomem *base, int enable) |
226 | { | 227 | { |
227 | struct iwm __iomem *iwm_base; | 228 | struct iwm __iomem *iwm_base; |
@@ -666,9 +667,9 @@ static int floppy_unlocked_open(struct block_device *bdev, fmode_t mode) | |||
666 | { | 667 | { |
667 | int ret; | 668 | int ret; |
668 | 669 | ||
669 | lock_kernel(); | 670 | mutex_lock(&swim_mutex); |
670 | ret = floppy_open(bdev, mode); | 671 | ret = floppy_open(bdev, mode); |
671 | unlock_kernel(); | 672 | mutex_unlock(&swim_mutex); |
672 | 673 | ||
673 | return ret; | 674 | return ret; |
674 | } | 675 | } |
@@ -678,7 +679,7 @@ static int floppy_release(struct gendisk *disk, fmode_t mode) | |||
678 | struct floppy_state *fs = disk->private_data; | 679 | struct floppy_state *fs = disk->private_data; |
679 | struct swim __iomem *base = fs->swd->base; | 680 | struct swim __iomem *base = fs->swd->base; |
680 | 681 | ||
681 | lock_kernel(); | 682 | mutex_lock(&swim_mutex); |
682 | if (fs->ref_count < 0) | 683 | if (fs->ref_count < 0) |
683 | fs->ref_count = 0; | 684 | fs->ref_count = 0; |
684 | else if (fs->ref_count > 0) | 685 | else if (fs->ref_count > 0) |
@@ -686,7 +687,7 @@ static int floppy_release(struct gendisk *disk, fmode_t mode) | |||
686 | 687 | ||
687 | if (fs->ref_count == 0) | 688 | if (fs->ref_count == 0) |
688 | swim_motor(base, OFF); | 689 | swim_motor(base, OFF); |
689 | unlock_kernel(); | 690 | mutex_unlock(&swim_mutex); |
690 | 691 | ||
691 | return 0; | 692 | return 0; |
692 | } | 693 | } |
@@ -704,9 +705,9 @@ static int floppy_ioctl(struct block_device *bdev, fmode_t mode, | |||
704 | case FDEJECT: | 705 | case FDEJECT: |
705 | if (fs->ref_count != 1) | 706 | if (fs->ref_count != 1) |
706 | return -EBUSY; | 707 | return -EBUSY; |
707 | lock_kernel(); | 708 | mutex_lock(&swim_mutex); |
708 | err = floppy_eject(fs); | 709 | err = floppy_eject(fs); |
709 | unlock_kernel(); | 710 | mutex_unlock(&swim_mutex); |
710 | return err; | 711 | return err; |
711 | 712 | ||
712 | case FDGETPRM: | 713 | case FDGETPRM: |