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/ataflop.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/ataflop.c')
-rw-r--r-- | drivers/block/ataflop.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/drivers/block/ataflop.c b/drivers/block/ataflop.c index aceb96476524..8c021bb7a991 100644 --- a/drivers/block/ataflop.c +++ b/drivers/block/ataflop.c | |||
@@ -67,7 +67,7 @@ | |||
67 | #include <linux/delay.h> | 67 | #include <linux/delay.h> |
68 | #include <linux/init.h> | 68 | #include <linux/init.h> |
69 | #include <linux/blkdev.h> | 69 | #include <linux/blkdev.h> |
70 | #include <linux/smp_lock.h> | 70 | #include <linux/mutex.h> |
71 | 71 | ||
72 | #include <asm/atafd.h> | 72 | #include <asm/atafd.h> |
73 | #include <asm/atafdreg.h> | 73 | #include <asm/atafdreg.h> |
@@ -79,6 +79,7 @@ | |||
79 | 79 | ||
80 | #undef DEBUG | 80 | #undef DEBUG |
81 | 81 | ||
82 | static DEFINE_MUTEX(ataflop_mutex); | ||
82 | static struct request_queue *floppy_queue; | 83 | static struct request_queue *floppy_queue; |
83 | static struct request *fd_request; | 84 | static struct request *fd_request; |
84 | 85 | ||
@@ -1671,9 +1672,9 @@ static int fd_ioctl(struct block_device *bdev, fmode_t mode, | |||
1671 | { | 1672 | { |
1672 | int ret; | 1673 | int ret; |
1673 | 1674 | ||
1674 | lock_kernel(); | 1675 | mutex_lock(&ataflop_mutex); |
1675 | ret = fd_locked_ioctl(bdev, mode, cmd, arg); | 1676 | ret = fd_locked_ioctl(bdev, mode, cmd, arg); |
1676 | unlock_kernel(); | 1677 | mutex_unlock(&ataflop_mutex); |
1677 | 1678 | ||
1678 | return ret; | 1679 | return ret; |
1679 | } | 1680 | } |
@@ -1854,9 +1855,9 @@ static int floppy_unlocked_open(struct block_device *bdev, fmode_t mode) | |||
1854 | { | 1855 | { |
1855 | int ret; | 1856 | int ret; |
1856 | 1857 | ||
1857 | lock_kernel(); | 1858 | mutex_lock(&ataflop_mutex); |
1858 | ret = floppy_open(bdev, mode); | 1859 | ret = floppy_open(bdev, mode); |
1859 | unlock_kernel(); | 1860 | mutex_unlock(&ataflop_mutex); |
1860 | 1861 | ||
1861 | return ret; | 1862 | return ret; |
1862 | } | 1863 | } |
@@ -1864,14 +1865,14 @@ static int floppy_unlocked_open(struct block_device *bdev, fmode_t mode) | |||
1864 | static int floppy_release(struct gendisk *disk, fmode_t mode) | 1865 | static int floppy_release(struct gendisk *disk, fmode_t mode) |
1865 | { | 1866 | { |
1866 | struct atari_floppy_struct *p = disk->private_data; | 1867 | struct atari_floppy_struct *p = disk->private_data; |
1867 | lock_kernel(); | 1868 | mutex_lock(&ataflop_mutex); |
1868 | if (p->ref < 0) | 1869 | if (p->ref < 0) |
1869 | p->ref = 0; | 1870 | p->ref = 0; |
1870 | else if (!p->ref--) { | 1871 | else if (!p->ref--) { |
1871 | printk(KERN_ERR "floppy_release with fd_ref == 0"); | 1872 | printk(KERN_ERR "floppy_release with fd_ref == 0"); |
1872 | p->ref = 0; | 1873 | p->ref = 0; |
1873 | } | 1874 | } |
1874 | unlock_kernel(); | 1875 | mutex_unlock(&ataflop_mutex); |
1875 | return 0; | 1876 | return 0; |
1876 | } | 1877 | } |
1877 | 1878 | ||