aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/pktcdvd.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/pktcdvd.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/pktcdvd.c')
-rw-r--r--drivers/block/pktcdvd.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
index b1cbeb59bb76..1e85678dd4f6 100644
--- a/drivers/block/pktcdvd.c
+++ b/drivers/block/pktcdvd.c
@@ -57,7 +57,6 @@
57#include <linux/seq_file.h> 57#include <linux/seq_file.h>
58#include <linux/miscdevice.h> 58#include <linux/miscdevice.h>
59#include <linux/freezer.h> 59#include <linux/freezer.h>
60#include <linux/smp_lock.h>
61#include <linux/mutex.h> 60#include <linux/mutex.h>
62#include <linux/slab.h> 61#include <linux/slab.h>
63#include <scsi/scsi_cmnd.h> 62#include <scsi/scsi_cmnd.h>
@@ -86,6 +85,7 @@
86 85
87#define ZONE(sector, pd) (((sector) + (pd)->offset) & ~((pd)->settings.size - 1)) 86#define ZONE(sector, pd) (((sector) + (pd)->offset) & ~((pd)->settings.size - 1))
88 87
88static DEFINE_MUTEX(pktcdvd_mutex);
89static struct pktcdvd_device *pkt_devs[MAX_WRITERS]; 89static struct pktcdvd_device *pkt_devs[MAX_WRITERS];
90static struct proc_dir_entry *pkt_proc; 90static struct proc_dir_entry *pkt_proc;
91static int pktdev_major; 91static int pktdev_major;
@@ -2383,7 +2383,7 @@ static int pkt_open(struct block_device *bdev, fmode_t mode)
2383 2383
2384 VPRINTK(DRIVER_NAME": entering open\n"); 2384 VPRINTK(DRIVER_NAME": entering open\n");
2385 2385
2386 lock_kernel(); 2386 mutex_lock(&pktcdvd_mutex);
2387 mutex_lock(&ctl_mutex); 2387 mutex_lock(&ctl_mutex);
2388 pd = pkt_find_dev_from_minor(MINOR(bdev->bd_dev)); 2388 pd = pkt_find_dev_from_minor(MINOR(bdev->bd_dev));
2389 if (!pd) { 2389 if (!pd) {
@@ -2411,7 +2411,7 @@ static int pkt_open(struct block_device *bdev, fmode_t mode)
2411 } 2411 }
2412 2412
2413 mutex_unlock(&ctl_mutex); 2413 mutex_unlock(&ctl_mutex);
2414 unlock_kernel(); 2414 mutex_unlock(&pktcdvd_mutex);
2415 return 0; 2415 return 0;
2416 2416
2417out_dec: 2417out_dec:
@@ -2419,7 +2419,7 @@ out_dec:
2419out: 2419out:
2420 VPRINTK(DRIVER_NAME": failed open (%d)\n", ret); 2420 VPRINTK(DRIVER_NAME": failed open (%d)\n", ret);
2421 mutex_unlock(&ctl_mutex); 2421 mutex_unlock(&ctl_mutex);
2422 unlock_kernel(); 2422 mutex_unlock(&pktcdvd_mutex);
2423 return ret; 2423 return ret;
2424} 2424}
2425 2425
@@ -2428,7 +2428,7 @@ static int pkt_close(struct gendisk *disk, fmode_t mode)
2428 struct pktcdvd_device *pd = disk->private_data; 2428 struct pktcdvd_device *pd = disk->private_data;
2429 int ret = 0; 2429 int ret = 0;
2430 2430
2431 lock_kernel(); 2431 mutex_lock(&pktcdvd_mutex);
2432 mutex_lock(&ctl_mutex); 2432 mutex_lock(&ctl_mutex);
2433 pd->refcnt--; 2433 pd->refcnt--;
2434 BUG_ON(pd->refcnt < 0); 2434 BUG_ON(pd->refcnt < 0);
@@ -2437,7 +2437,7 @@ static int pkt_close(struct gendisk *disk, fmode_t mode)
2437 pkt_release_dev(pd, flush); 2437 pkt_release_dev(pd, flush);
2438 } 2438 }
2439 mutex_unlock(&ctl_mutex); 2439 mutex_unlock(&ctl_mutex);
2440 unlock_kernel(); 2440 mutex_unlock(&pktcdvd_mutex);
2441 return ret; 2441 return ret;
2442} 2442}
2443 2443
@@ -2773,7 +2773,7 @@ static int pkt_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd,
2773 VPRINTK("pkt_ioctl: cmd %x, dev %d:%d\n", cmd, 2773 VPRINTK("pkt_ioctl: cmd %x, dev %d:%d\n", cmd,
2774 MAJOR(bdev->bd_dev), MINOR(bdev->bd_dev)); 2774 MAJOR(bdev->bd_dev), MINOR(bdev->bd_dev));
2775 2775
2776 lock_kernel(); 2776 mutex_lock(&pktcdvd_mutex);
2777 switch (cmd) { 2777 switch (cmd) {
2778 case CDROMEJECT: 2778 case CDROMEJECT:
2779 /* 2779 /*
@@ -2798,7 +2798,7 @@ static int pkt_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd,
2798 VPRINTK(DRIVER_NAME": Unknown ioctl for %s (%x)\n", pd->name, cmd); 2798 VPRINTK(DRIVER_NAME": Unknown ioctl for %s (%x)\n", pd->name, cmd);
2799 ret = -ENOTTY; 2799 ret = -ENOTTY;
2800 } 2800 }
2801 unlock_kernel(); 2801 mutex_unlock(&pktcdvd_mutex);
2802 2802
2803 return ret; 2803 return ret;
2804} 2804}