mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 02:32:09 -04:00
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 <[email protected]>
This commit is contained in:
parent
613655fa39
commit
2a48fc0ab2
43 changed files with 277 additions and 250 deletions
|
|
@ -18,11 +18,12 @@
|
|||
#include <linux/kthread.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/smp_lock.h>
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/memstick.h>
|
||||
|
||||
#define DRIVER_NAME "mspro_block"
|
||||
|
||||
static DEFINE_MUTEX(mspro_block_mutex);
|
||||
static int major;
|
||||
module_param(major, int, 0644);
|
||||
|
||||
|
|
@ -180,7 +181,7 @@ static int mspro_block_bd_open(struct block_device *bdev, fmode_t mode)
|
|||
struct mspro_block_data *msb = disk->private_data;
|
||||
int rc = -ENXIO;
|
||||
|
||||
lock_kernel();
|
||||
mutex_lock(&mspro_block_mutex);
|
||||
mutex_lock(&mspro_block_disk_lock);
|
||||
|
||||
if (msb && msb->card) {
|
||||
|
|
@ -192,7 +193,7 @@ static int mspro_block_bd_open(struct block_device *bdev, fmode_t mode)
|
|||
}
|
||||
|
||||
mutex_unlock(&mspro_block_disk_lock);
|
||||
unlock_kernel();
|
||||
mutex_unlock(&mspro_block_mutex);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
|
@ -225,9 +226,9 @@ static int mspro_block_disk_release(struct gendisk *disk)
|
|||
static int mspro_block_bd_release(struct gendisk *disk, fmode_t mode)
|
||||
{
|
||||
int ret;
|
||||
lock_kernel();
|
||||
mutex_lock(&mspro_block_mutex);
|
||||
ret = mspro_block_disk_release(disk);
|
||||
unlock_kernel();
|
||||
mutex_unlock(&mspro_block_mutex);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue