aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/mtd_blkdevs.c
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2010-06-02 08:28:52 -0400
committerArnd Bergmann <arnd@arndb.de>2010-10-05 09:01:10 -0400
commit2a48fc0ab24241755dc93bfd4f01d68efab47f5a (patch)
treefa9ae10ce89b26b7d8ae9ce24bdfda5e3007b763 /drivers/mtd/mtd_blkdevs.c
parent613655fa39ff6957754fa8ceb8559980920eb8ee (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/mtd/mtd_blkdevs.c')
-rw-r--r--drivers/mtd/mtd_blkdevs.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c
index 62e68707b07f..50ab431b24eb 100644
--- a/drivers/mtd/mtd_blkdevs.c
+++ b/drivers/mtd/mtd_blkdevs.c
@@ -29,7 +29,6 @@
29#include <linux/blkdev.h> 29#include <linux/blkdev.h>
30#include <linux/blkpg.h> 30#include <linux/blkpg.h>
31#include <linux/spinlock.h> 31#include <linux/spinlock.h>
32#include <linux/smp_lock.h>
33#include <linux/hdreg.h> 32#include <linux/hdreg.h>
34#include <linux/init.h> 33#include <linux/init.h>
35#include <linux/mutex.h> 34#include <linux/mutex.h>
@@ -38,6 +37,7 @@
38 37
39#include "mtdcore.h" 38#include "mtdcore.h"
40 39
40static DEFINE_MUTEX(mtd_blkdevs_mutex);
41static LIST_HEAD(blktrans_majors); 41static LIST_HEAD(blktrans_majors);
42static DEFINE_MUTEX(blktrans_ref_mutex); 42static DEFINE_MUTEX(blktrans_ref_mutex);
43 43
@@ -181,7 +181,7 @@ static int blktrans_open(struct block_device *bdev, fmode_t mode)
181 if (!dev) 181 if (!dev)
182 return -ERESTARTSYS; /* FIXME: busy loop! -arnd*/ 182 return -ERESTARTSYS; /* FIXME: busy loop! -arnd*/
183 183
184 lock_kernel(); 184 mutex_lock(&mtd_blkdevs_mutex);
185 mutex_lock(&dev->lock); 185 mutex_lock(&dev->lock);
186 186
187 if (!dev->mtd) { 187 if (!dev->mtd) {
@@ -198,7 +198,7 @@ static int blktrans_open(struct block_device *bdev, fmode_t mode)
198unlock: 198unlock:
199 mutex_unlock(&dev->lock); 199 mutex_unlock(&dev->lock);
200 blktrans_dev_put(dev); 200 blktrans_dev_put(dev);
201 unlock_kernel(); 201 mutex_unlock(&mtd_blkdevs_mutex);
202 return ret; 202 return ret;
203} 203}
204 204
@@ -210,7 +210,7 @@ static int blktrans_release(struct gendisk *disk, fmode_t mode)
210 if (!dev) 210 if (!dev)
211 return ret; 211 return ret;
212 212
213 lock_kernel(); 213 mutex_lock(&mtd_blkdevs_mutex);
214 mutex_lock(&dev->lock); 214 mutex_lock(&dev->lock);
215 215
216 /* Release one reference, we sure its not the last one here*/ 216 /* Release one reference, we sure its not the last one here*/
@@ -223,7 +223,7 @@ static int blktrans_release(struct gendisk *disk, fmode_t mode)
223unlock: 223unlock:
224 mutex_unlock(&dev->lock); 224 mutex_unlock(&dev->lock);
225 blktrans_dev_put(dev); 225 blktrans_dev_put(dev);
226 unlock_kernel(); 226 mutex_unlock(&mtd_blkdevs_mutex);
227 return ret; 227 return ret;
228} 228}
229 229
@@ -256,7 +256,7 @@ static int blktrans_ioctl(struct block_device *bdev, fmode_t mode,
256 if (!dev) 256 if (!dev)
257 return ret; 257 return ret;
258 258
259 lock_kernel(); 259 mutex_lock(&mtd_blkdevs_mutex);
260 mutex_lock(&dev->lock); 260 mutex_lock(&dev->lock);
261 261
262 if (!dev->mtd) 262 if (!dev->mtd)
@@ -271,7 +271,7 @@ static int blktrans_ioctl(struct block_device *bdev, fmode_t mode,
271 } 271 }
272unlock: 272unlock:
273 mutex_unlock(&dev->lock); 273 mutex_unlock(&dev->lock);
274 unlock_kernel(); 274 mutex_unlock(&mtd_blkdevs_mutex);
275 blktrans_dev_put(dev); 275 blktrans_dev_put(dev);
276 return ret; 276 return ret;
277} 277}