aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/z2ram.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/block/z2ram.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/block/z2ram.c')
-rw-r--r--drivers/block/z2ram.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/drivers/block/z2ram.c b/drivers/block/z2ram.c
index d75b2bb601ad..dcd4cfcf4126 100644
--- a/drivers/block/z2ram.c
+++ b/drivers/block/z2ram.c
@@ -33,7 +33,7 @@
33#include <linux/module.h> 33#include <linux/module.h>
34#include <linux/blkdev.h> 34#include <linux/blkdev.h>
35#include <linux/bitops.h> 35#include <linux/bitops.h>
36#include <linux/smp_lock.h> 36#include <linux/mutex.h>
37#include <linux/slab.h> 37#include <linux/slab.h>
38 38
39#include <asm/setup.h> 39#include <asm/setup.h>
@@ -57,6 +57,7 @@ extern struct mem_info m68k_memory[NUM_MEMINFO];
57 57
58#define Z2RAM_CHUNK1024 ( Z2RAM_CHUNKSIZE >> 10 ) 58#define Z2RAM_CHUNK1024 ( Z2RAM_CHUNKSIZE >> 10 )
59 59
60static DEFINE_MUTEX(z2ram_mutex);
60static u_long *z2ram_map = NULL; 61static u_long *z2ram_map = NULL;
61static u_long z2ram_size = 0; 62static u_long z2ram_size = 0;
62static int z2_count = 0; 63static int z2_count = 0;
@@ -154,7 +155,7 @@ static int z2_open(struct block_device *bdev, fmode_t mode)
154 155
155 device = MINOR(bdev->bd_dev); 156 device = MINOR(bdev->bd_dev);
156 157
157 lock_kernel(); 158 mutex_lock(&z2ram_mutex);
158 if ( current_device != -1 && current_device != device ) 159 if ( current_device != -1 && current_device != device )
159 { 160 {
160 rc = -EBUSY; 161 rc = -EBUSY;
@@ -296,25 +297,25 @@ static int z2_open(struct block_device *bdev, fmode_t mode)
296 set_capacity(z2ram_gendisk, z2ram_size >> 9); 297 set_capacity(z2ram_gendisk, z2ram_size >> 9);
297 } 298 }
298 299
299 unlock_kernel(); 300 mutex_unlock(&z2ram_mutex);
300 return 0; 301 return 0;
301 302
302err_out_kfree: 303err_out_kfree:
303 kfree(z2ram_map); 304 kfree(z2ram_map);
304err_out: 305err_out:
305 unlock_kernel(); 306 mutex_unlock(&z2ram_mutex);
306 return rc; 307 return rc;
307} 308}
308 309
309static int 310static int
310z2_release(struct gendisk *disk, fmode_t mode) 311z2_release(struct gendisk *disk, fmode_t mode)
311{ 312{
312 lock_kernel(); 313 mutex_lock(&z2ram_mutex);
313 if ( current_device == -1 ) { 314 if ( current_device == -1 ) {
314 unlock_kernel(); 315 mutex_unlock(&z2ram_mutex);
315 return 0; 316 return 0;
316 } 317 }
317 unlock_kernel(); 318 mutex_unlock(&z2ram_mutex);
318 /* 319 /*
319 * FIXME: unmap memory 320 * FIXME: unmap memory
320 */ 321 */