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 | |
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')
-rw-r--r-- | drivers/block/DAC960.c | 11 | ||||
-rw-r--r-- | drivers/block/amiflop.c | 19 | ||||
-rw-r--r-- | drivers/block/aoe/aoeblk.c | 9 | ||||
-rw-r--r-- | drivers/block/aoe/aoechr.c | 9 | ||||
-rw-r--r-- | drivers/block/ataflop.c | 15 | ||||
-rw-r--r-- | drivers/block/brd.c | 7 | ||||
-rw-r--r-- | drivers/block/cciss.c | 14 | ||||
-rw-r--r-- | drivers/block/cpqarray.c | 15 | ||||
-rw-r--r-- | drivers/block/drbd/drbd_main.c | 11 | ||||
-rw-r--r-- | drivers/block/floppy.c | 16 | ||||
-rw-r--r-- | drivers/block/loop.c | 11 | ||||
-rw-r--r-- | drivers/block/nbd.c | 7 | ||||
-rw-r--r-- | drivers/block/paride/pcd.c | 15 | ||||
-rw-r--r-- | drivers/block/paride/pd.c | 15 | ||||
-rw-r--r-- | drivers/block/paride/pf.c | 17 | ||||
-rw-r--r-- | drivers/block/pktcdvd.c | 16 | ||||
-rw-r--r-- | drivers/block/swim.c | 15 | ||||
-rw-r--r-- | drivers/block/swim3.c | 15 | ||||
-rw-r--r-- | drivers/block/ub.c | 15 | ||||
-rw-r--r-- | drivers/block/viodasd.c | 11 | ||||
-rw-r--r-- | drivers/block/xd.c | 7 | ||||
-rw-r--r-- | drivers/block/xen-blkfront.c | 11 | ||||
-rw-r--r-- | drivers/block/xsysace.c | 11 | ||||
-rw-r--r-- | drivers/block/z2ram.c | 15 |
24 files changed, 164 insertions, 143 deletions
diff --git a/drivers/block/DAC960.c b/drivers/block/DAC960.c index 4e2c367fec11..da0f6ddd7621 100644 --- a/drivers/block/DAC960.c +++ b/drivers/block/DAC960.c | |||
@@ -36,7 +36,7 @@ | |||
36 | #include <linux/ioport.h> | 36 | #include <linux/ioport.h> |
37 | #include <linux/mm.h> | 37 | #include <linux/mm.h> |
38 | #include <linux/slab.h> | 38 | #include <linux/slab.h> |
39 | #include <linux/smp_lock.h> | 39 | #include <linux/mutex.h> |
40 | #include <linux/proc_fs.h> | 40 | #include <linux/proc_fs.h> |
41 | #include <linux/seq_file.h> | 41 | #include <linux/seq_file.h> |
42 | #include <linux/reboot.h> | 42 | #include <linux/reboot.h> |
@@ -54,6 +54,7 @@ | |||
54 | #define DAC960_GAM_MINOR 252 | 54 | #define DAC960_GAM_MINOR 252 |
55 | 55 | ||
56 | 56 | ||
57 | static DEFINE_MUTEX(DAC960_mutex); | ||
57 | static DAC960_Controller_T *DAC960_Controllers[DAC960_MaxControllers]; | 58 | static DAC960_Controller_T *DAC960_Controllers[DAC960_MaxControllers]; |
58 | static int DAC960_ControllerCount; | 59 | static int DAC960_ControllerCount; |
59 | static struct proc_dir_entry *DAC960_ProcDirectoryEntry; | 60 | static struct proc_dir_entry *DAC960_ProcDirectoryEntry; |
@@ -81,7 +82,7 @@ static int DAC960_open(struct block_device *bdev, fmode_t mode) | |||
81 | int drive_nr = (long)disk->private_data; | 82 | int drive_nr = (long)disk->private_data; |
82 | int ret = -ENXIO; | 83 | int ret = -ENXIO; |
83 | 84 | ||
84 | lock_kernel(); | 85 | mutex_lock(&DAC960_mutex); |
85 | if (p->FirmwareType == DAC960_V1_Controller) { | 86 | if (p->FirmwareType == DAC960_V1_Controller) { |
86 | if (p->V1.LogicalDriveInformation[drive_nr]. | 87 | if (p->V1.LogicalDriveInformation[drive_nr]. |
87 | LogicalDriveState == DAC960_V1_LogicalDrive_Offline) | 88 | LogicalDriveState == DAC960_V1_LogicalDrive_Offline) |
@@ -99,7 +100,7 @@ static int DAC960_open(struct block_device *bdev, fmode_t mode) | |||
99 | goto out; | 100 | goto out; |
100 | ret = 0; | 101 | ret = 0; |
101 | out: | 102 | out: |
102 | unlock_kernel(); | 103 | mutex_unlock(&DAC960_mutex); |
103 | return ret; | 104 | return ret; |
104 | } | 105 | } |
105 | 106 | ||
@@ -6625,7 +6626,7 @@ static long DAC960_gam_ioctl(struct file *file, unsigned int Request, | |||
6625 | long ErrorCode = 0; | 6626 | long ErrorCode = 0; |
6626 | if (!capable(CAP_SYS_ADMIN)) return -EACCES; | 6627 | if (!capable(CAP_SYS_ADMIN)) return -EACCES; |
6627 | 6628 | ||
6628 | lock_kernel(); | 6629 | mutex_lock(&DAC960_mutex); |
6629 | switch (Request) | 6630 | switch (Request) |
6630 | { | 6631 | { |
6631 | case DAC960_IOCTL_GET_CONTROLLER_COUNT: | 6632 | case DAC960_IOCTL_GET_CONTROLLER_COUNT: |
@@ -7056,7 +7057,7 @@ static long DAC960_gam_ioctl(struct file *file, unsigned int Request, | |||
7056 | default: | 7057 | default: |
7057 | ErrorCode = -ENOTTY; | 7058 | ErrorCode = -ENOTTY; |
7058 | } | 7059 | } |
7059 | unlock_kernel(); | 7060 | mutex_unlock(&DAC960_mutex); |
7060 | return ErrorCode; | 7061 | return ErrorCode; |
7061 | } | 7062 | } |
7062 | 7063 | ||
diff --git a/drivers/block/amiflop.c b/drivers/block/amiflop.c index 76f114f0bba3..4b852c962266 100644 --- a/drivers/block/amiflop.c +++ b/drivers/block/amiflop.c | |||
@@ -60,7 +60,7 @@ | |||
60 | #include <linux/hdreg.h> | 60 | #include <linux/hdreg.h> |
61 | #include <linux/delay.h> | 61 | #include <linux/delay.h> |
62 | #include <linux/init.h> | 62 | #include <linux/init.h> |
63 | #include <linux/smp_lock.h> | 63 | #include <linux/mutex.h> |
64 | #include <linux/amifdreg.h> | 64 | #include <linux/amifdreg.h> |
65 | #include <linux/amifd.h> | 65 | #include <linux/amifd.h> |
66 | #include <linux/buffer_head.h> | 66 | #include <linux/buffer_head.h> |
@@ -109,6 +109,7 @@ | |||
109 | #define FD_HD_3 0x55555555 /* high-density 3.5" (1760K) drive */ | 109 | #define FD_HD_3 0x55555555 /* high-density 3.5" (1760K) drive */ |
110 | #define FD_DD_5 0xaaaaaaaa /* double-density 5.25" (440K) drive */ | 110 | #define FD_DD_5 0xaaaaaaaa /* double-density 5.25" (440K) drive */ |
111 | 111 | ||
112 | static DEFINE_MUTEX(amiflop_mutex); | ||
112 | static unsigned long int fd_def_df0 = FD_DD_3; /* default for df0 if it doesn't identify */ | 113 | static unsigned long int fd_def_df0 = FD_DD_3; /* default for df0 if it doesn't identify */ |
113 | 114 | ||
114 | module_param(fd_def_df0, ulong, 0); | 115 | module_param(fd_def_df0, ulong, 0); |
@@ -1506,9 +1507,9 @@ static int fd_ioctl(struct block_device *bdev, fmode_t mode, | |||
1506 | { | 1507 | { |
1507 | int ret; | 1508 | int ret; |
1508 | 1509 | ||
1509 | lock_kernel(); | 1510 | mutex_lock(&amiflop_mutex); |
1510 | ret = fd_locked_ioctl(bdev, mode, cmd, param); | 1511 | ret = fd_locked_ioctl(bdev, mode, cmd, param); |
1511 | unlock_kernel(); | 1512 | mutex_unlock(&amiflop_mutex); |
1512 | 1513 | ||
1513 | return ret; | 1514 | return ret; |
1514 | } | 1515 | } |
@@ -1555,11 +1556,11 @@ static int floppy_open(struct block_device *bdev, fmode_t mode) | |||
1555 | int old_dev; | 1556 | int old_dev; |
1556 | unsigned long flags; | 1557 | unsigned long flags; |
1557 | 1558 | ||
1558 | lock_kernel(); | 1559 | mutex_lock(&amiflop_mutex); |
1559 | old_dev = fd_device[drive]; | 1560 | old_dev = fd_device[drive]; |
1560 | 1561 | ||
1561 | if (fd_ref[drive] && old_dev != system) { | 1562 | if (fd_ref[drive] && old_dev != system) { |
1562 | unlock_kernel(); | 1563 | mutex_unlock(&amiflop_mutex); |
1563 | return -EBUSY; | 1564 | return -EBUSY; |
1564 | } | 1565 | } |
1565 | 1566 | ||
@@ -1575,7 +1576,7 @@ static int floppy_open(struct block_device *bdev, fmode_t mode) | |||
1575 | rel_fdc(); | 1576 | rel_fdc(); |
1576 | 1577 | ||
1577 | if (wrprot) { | 1578 | if (wrprot) { |
1578 | unlock_kernel(); | 1579 | mutex_unlock(&amiflop_mutex); |
1579 | return -EROFS; | 1580 | return -EROFS; |
1580 | } | 1581 | } |
1581 | } | 1582 | } |
@@ -1594,7 +1595,7 @@ static int floppy_open(struct block_device *bdev, fmode_t mode) | |||
1594 | printk(KERN_INFO "fd%d: accessing %s-disk with %s-layout\n",drive, | 1595 | printk(KERN_INFO "fd%d: accessing %s-disk with %s-layout\n",drive, |
1595 | unit[drive].type->name, data_types[system].name); | 1596 | unit[drive].type->name, data_types[system].name); |
1596 | 1597 | ||
1597 | unlock_kernel(); | 1598 | mutex_unlock(&amiflop_mutex); |
1598 | return 0; | 1599 | return 0; |
1599 | } | 1600 | } |
1600 | 1601 | ||
@@ -1603,7 +1604,7 @@ static int floppy_release(struct gendisk *disk, fmode_t mode) | |||
1603 | struct amiga_floppy_struct *p = disk->private_data; | 1604 | struct amiga_floppy_struct *p = disk->private_data; |
1604 | int drive = p - unit; | 1605 | int drive = p - unit; |
1605 | 1606 | ||
1606 | lock_kernel(); | 1607 | mutex_lock(&amiflop_mutex); |
1607 | if (unit[drive].dirty == 1) { | 1608 | if (unit[drive].dirty == 1) { |
1608 | del_timer (flush_track_timer + drive); | 1609 | del_timer (flush_track_timer + drive); |
1609 | non_int_flush_track (drive); | 1610 | non_int_flush_track (drive); |
@@ -1617,7 +1618,7 @@ static int floppy_release(struct gendisk *disk, fmode_t mode) | |||
1617 | /* the mod_use counter is handled this way */ | 1618 | /* the mod_use counter is handled this way */ |
1618 | floppy_off (drive | 0x40000000); | 1619 | floppy_off (drive | 0x40000000); |
1619 | #endif | 1620 | #endif |
1620 | unlock_kernel(); | 1621 | mutex_unlock(&amiflop_mutex); |
1621 | return 0; | 1622 | return 0; |
1622 | } | 1623 | } |
1623 | 1624 | ||
diff --git a/drivers/block/aoe/aoeblk.c b/drivers/block/aoe/aoeblk.c index a946929735a5..f21c237a9e5e 100644 --- a/drivers/block/aoe/aoeblk.c +++ b/drivers/block/aoe/aoeblk.c | |||
@@ -12,9 +12,10 @@ | |||
12 | #include <linux/slab.h> | 12 | #include <linux/slab.h> |
13 | #include <linux/genhd.h> | 13 | #include <linux/genhd.h> |
14 | #include <linux/netdevice.h> | 14 | #include <linux/netdevice.h> |
15 | #include <linux/smp_lock.h> | 15 | #include <linux/mutex.h> |
16 | #include "aoe.h" | 16 | #include "aoe.h" |
17 | 17 | ||
18 | static DEFINE_MUTEX(aoeblk_mutex); | ||
18 | static struct kmem_cache *buf_pool_cache; | 19 | static struct kmem_cache *buf_pool_cache; |
19 | 20 | ||
20 | static ssize_t aoedisk_show_state(struct device *dev, | 21 | static ssize_t aoedisk_show_state(struct device *dev, |
@@ -125,16 +126,16 @@ aoeblk_open(struct block_device *bdev, fmode_t mode) | |||
125 | struct aoedev *d = bdev->bd_disk->private_data; | 126 | struct aoedev *d = bdev->bd_disk->private_data; |
126 | ulong flags; | 127 | ulong flags; |
127 | 128 | ||
128 | lock_kernel(); | 129 | mutex_lock(&aoeblk_mutex); |
129 | spin_lock_irqsave(&d->lock, flags); | 130 | spin_lock_irqsave(&d->lock, flags); |
130 | if (d->flags & DEVFL_UP) { | 131 | if (d->flags & DEVFL_UP) { |
131 | d->nopen++; | 132 | d->nopen++; |
132 | spin_unlock_irqrestore(&d->lock, flags); | 133 | spin_unlock_irqrestore(&d->lock, flags); |
133 | unlock_kernel(); | 134 | mutex_unlock(&aoeblk_mutex); |
134 | return 0; | 135 | return 0; |
135 | } | 136 | } |
136 | spin_unlock_irqrestore(&d->lock, flags); | 137 | spin_unlock_irqrestore(&d->lock, flags); |
137 | unlock_kernel(); | 138 | mutex_unlock(&aoeblk_mutex); |
138 | return -ENODEV; | 139 | return -ENODEV; |
139 | } | 140 | } |
140 | 141 | ||
diff --git a/drivers/block/aoe/aoechr.c b/drivers/block/aoe/aoechr.c index 4a1b9e7464aa..05d5ef172ca5 100644 --- a/drivers/block/aoe/aoechr.c +++ b/drivers/block/aoe/aoechr.c | |||
@@ -9,7 +9,7 @@ | |||
9 | #include <linux/completion.h> | 9 | #include <linux/completion.h> |
10 | #include <linux/delay.h> | 10 | #include <linux/delay.h> |
11 | #include <linux/slab.h> | 11 | #include <linux/slab.h> |
12 | #include <linux/smp_lock.h> | 12 | #include <linux/mutex.h> |
13 | #include <linux/skbuff.h> | 13 | #include <linux/skbuff.h> |
14 | #include "aoe.h" | 14 | #include "aoe.h" |
15 | 15 | ||
@@ -37,6 +37,7 @@ struct ErrMsg { | |||
37 | char *msg; | 37 | char *msg; |
38 | }; | 38 | }; |
39 | 39 | ||
40 | static DEFINE_MUTEX(aoechr_mutex); | ||
40 | static struct ErrMsg emsgs[NMSG]; | 41 | static struct ErrMsg emsgs[NMSG]; |
41 | static int emsgs_head_idx, emsgs_tail_idx; | 42 | static int emsgs_head_idx, emsgs_tail_idx; |
42 | static struct completion emsgs_comp; | 43 | static struct completion emsgs_comp; |
@@ -183,16 +184,16 @@ aoechr_open(struct inode *inode, struct file *filp) | |||
183 | { | 184 | { |
184 | int n, i; | 185 | int n, i; |
185 | 186 | ||
186 | lock_kernel(); | 187 | mutex_lock(&aoechr_mutex); |
187 | n = iminor(inode); | 188 | n = iminor(inode); |
188 | filp->private_data = (void *) (unsigned long) n; | 189 | filp->private_data = (void *) (unsigned long) n; |
189 | 190 | ||
190 | for (i = 0; i < ARRAY_SIZE(chardevs); ++i) | 191 | for (i = 0; i < ARRAY_SIZE(chardevs); ++i) |
191 | if (chardevs[i].minor == n) { | 192 | if (chardevs[i].minor == n) { |
192 | unlock_kernel(); | 193 | mutex_unlock(&aoechr_mutex); |
193 | return 0; | 194 | return 0; |
194 | } | 195 | } |
195 | unlock_kernel(); | 196 | mutex_unlock(&aoechr_mutex); |
196 | return -EINVAL; | 197 | return -EINVAL; |
197 | } | 198 | } |
198 | 199 | ||
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 | ||
diff --git a/drivers/block/brd.c b/drivers/block/brd.c index 1c7f63792ff8..82bfd5bb4a97 100644 --- a/drivers/block/brd.c +++ b/drivers/block/brd.c | |||
@@ -15,7 +15,7 @@ | |||
15 | #include <linux/blkdev.h> | 15 | #include <linux/blkdev.h> |
16 | #include <linux/bio.h> | 16 | #include <linux/bio.h> |
17 | #include <linux/highmem.h> | 17 | #include <linux/highmem.h> |
18 | #include <linux/smp_lock.h> | 18 | #include <linux/mutex.h> |
19 | #include <linux/radix-tree.h> | 19 | #include <linux/radix-tree.h> |
20 | #include <linux/buffer_head.h> /* invalidate_bh_lrus() */ | 20 | #include <linux/buffer_head.h> /* invalidate_bh_lrus() */ |
21 | #include <linux/slab.h> | 21 | #include <linux/slab.h> |
@@ -55,6 +55,7 @@ struct brd_device { | |||
55 | /* | 55 | /* |
56 | * Look up and return a brd's page for a given sector. | 56 | * Look up and return a brd's page for a given sector. |
57 | */ | 57 | */ |
58 | static DEFINE_MUTEX(brd_mutex); | ||
58 | static struct page *brd_lookup_page(struct brd_device *brd, sector_t sector) | 59 | static struct page *brd_lookup_page(struct brd_device *brd, sector_t sector) |
59 | { | 60 | { |
60 | pgoff_t idx; | 61 | pgoff_t idx; |
@@ -402,7 +403,7 @@ static int brd_ioctl(struct block_device *bdev, fmode_t mode, | |||
402 | * ram device BLKFLSBUF has special semantics, we want to actually | 403 | * ram device BLKFLSBUF has special semantics, we want to actually |
403 | * release and destroy the ramdisk data. | 404 | * release and destroy the ramdisk data. |
404 | */ | 405 | */ |
405 | lock_kernel(); | 406 | mutex_lock(&brd_mutex); |
406 | mutex_lock(&bdev->bd_mutex); | 407 | mutex_lock(&bdev->bd_mutex); |
407 | error = -EBUSY; | 408 | error = -EBUSY; |
408 | if (bdev->bd_openers <= 1) { | 409 | if (bdev->bd_openers <= 1) { |
@@ -419,7 +420,7 @@ static int brd_ioctl(struct block_device *bdev, fmode_t mode, | |||
419 | error = 0; | 420 | error = 0; |
420 | } | 421 | } |
421 | mutex_unlock(&bdev->bd_mutex); | 422 | mutex_unlock(&bdev->bd_mutex); |
422 | unlock_kernel(); | 423 | mutex_unlock(&brd_mutex); |
423 | 424 | ||
424 | return error; | 425 | return error; |
425 | } | 426 | } |
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c index 6124c2fd2d33..ba9c3a4947c7 100644 --- a/drivers/block/cciss.c +++ b/drivers/block/cciss.c | |||
@@ -26,7 +26,6 @@ | |||
26 | #include <linux/pci.h> | 26 | #include <linux/pci.h> |
27 | #include <linux/kernel.h> | 27 | #include <linux/kernel.h> |
28 | #include <linux/slab.h> | 28 | #include <linux/slab.h> |
29 | #include <linux/smp_lock.h> | ||
30 | #include <linux/delay.h> | 29 | #include <linux/delay.h> |
31 | #include <linux/major.h> | 30 | #include <linux/major.h> |
32 | #include <linux/fs.h> | 31 | #include <linux/fs.h> |
@@ -66,6 +65,7 @@ MODULE_SUPPORTED_DEVICE("HP Smart Array Controllers"); | |||
66 | MODULE_VERSION("3.6.26"); | 65 | MODULE_VERSION("3.6.26"); |
67 | MODULE_LICENSE("GPL"); | 66 | MODULE_LICENSE("GPL"); |
68 | 67 | ||
68 | static DEFINE_MUTEX(cciss_mutex); | ||
69 | static int cciss_allow_hpsa; | 69 | static int cciss_allow_hpsa; |
70 | module_param(cciss_allow_hpsa, int, S_IRUGO|S_IWUSR); | 70 | module_param(cciss_allow_hpsa, int, S_IRUGO|S_IWUSR); |
71 | MODULE_PARM_DESC(cciss_allow_hpsa, | 71 | MODULE_PARM_DESC(cciss_allow_hpsa, |
@@ -1059,9 +1059,9 @@ static int cciss_unlocked_open(struct block_device *bdev, fmode_t mode) | |||
1059 | { | 1059 | { |
1060 | int ret; | 1060 | int ret; |
1061 | 1061 | ||
1062 | lock_kernel(); | 1062 | mutex_lock(&cciss_mutex); |
1063 | ret = cciss_open(bdev, mode); | 1063 | ret = cciss_open(bdev, mode); |
1064 | unlock_kernel(); | 1064 | mutex_unlock(&cciss_mutex); |
1065 | 1065 | ||
1066 | return ret; | 1066 | return ret; |
1067 | } | 1067 | } |
@@ -1074,13 +1074,13 @@ static int cciss_release(struct gendisk *disk, fmode_t mode) | |||
1074 | ctlr_info_t *h; | 1074 | ctlr_info_t *h; |
1075 | drive_info_struct *drv; | 1075 | drive_info_struct *drv; |
1076 | 1076 | ||
1077 | lock_kernel(); | 1077 | mutex_lock(&cciss_mutex); |
1078 | h = get_host(disk); | 1078 | h = get_host(disk); |
1079 | drv = get_drv(disk); | 1079 | drv = get_drv(disk); |
1080 | dev_dbg(&h->pdev->dev, "cciss_release %s\n", disk->disk_name); | 1080 | dev_dbg(&h->pdev->dev, "cciss_release %s\n", disk->disk_name); |
1081 | drv->usage_count--; | 1081 | drv->usage_count--; |
1082 | h->usage_count--; | 1082 | h->usage_count--; |
1083 | unlock_kernel(); | 1083 | mutex_unlock(&cciss_mutex); |
1084 | return 0; | 1084 | return 0; |
1085 | } | 1085 | } |
1086 | 1086 | ||
@@ -1088,9 +1088,9 @@ static int do_ioctl(struct block_device *bdev, fmode_t mode, | |||
1088 | unsigned cmd, unsigned long arg) | 1088 | unsigned cmd, unsigned long arg) |
1089 | { | 1089 | { |
1090 | int ret; | 1090 | int ret; |
1091 | lock_kernel(); | 1091 | mutex_lock(&cciss_mutex); |
1092 | ret = cciss_ioctl(bdev, mode, cmd, arg); | 1092 | ret = cciss_ioctl(bdev, mode, cmd, arg); |
1093 | unlock_kernel(); | 1093 | mutex_unlock(&cciss_mutex); |
1094 | return ret; | 1094 | return ret; |
1095 | } | 1095 | } |
1096 | 1096 | ||
diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c index d53b0291c44b..946dad4caef3 100644 --- a/drivers/block/cpqarray.c +++ b/drivers/block/cpqarray.c | |||
@@ -35,7 +35,7 @@ | |||
35 | #include <linux/seq_file.h> | 35 | #include <linux/seq_file.h> |
36 | #include <linux/init.h> | 36 | #include <linux/init.h> |
37 | #include <linux/hdreg.h> | 37 | #include <linux/hdreg.h> |
38 | #include <linux/smp_lock.h> | 38 | #include <linux/mutex.h> |
39 | #include <linux/spinlock.h> | 39 | #include <linux/spinlock.h> |
40 | #include <linux/blkdev.h> | 40 | #include <linux/blkdev.h> |
41 | #include <linux/genhd.h> | 41 | #include <linux/genhd.h> |
@@ -68,6 +68,7 @@ MODULE_LICENSE("GPL"); | |||
68 | 68 | ||
69 | #define CPQARRAY_DMA_MASK 0xFFFFFFFF /* 32 bit DMA */ | 69 | #define CPQARRAY_DMA_MASK 0xFFFFFFFF /* 32 bit DMA */ |
70 | 70 | ||
71 | static DEFINE_MUTEX(cpqarray_mutex); | ||
71 | static int nr_ctlr; | 72 | static int nr_ctlr; |
72 | static ctlr_info_t *hba[MAX_CTLR]; | 73 | static ctlr_info_t *hba[MAX_CTLR]; |
73 | 74 | ||
@@ -845,9 +846,9 @@ static int ida_unlocked_open(struct block_device *bdev, fmode_t mode) | |||
845 | { | 846 | { |
846 | int ret; | 847 | int ret; |
847 | 848 | ||
848 | lock_kernel(); | 849 | mutex_lock(&cpqarray_mutex); |
849 | ret = ida_open(bdev, mode); | 850 | ret = ida_open(bdev, mode); |
850 | unlock_kernel(); | 851 | mutex_unlock(&cpqarray_mutex); |
851 | 852 | ||
852 | return ret; | 853 | return ret; |
853 | } | 854 | } |
@@ -859,10 +860,10 @@ static int ida_release(struct gendisk *disk, fmode_t mode) | |||
859 | { | 860 | { |
860 | ctlr_info_t *host; | 861 | ctlr_info_t *host; |
861 | 862 | ||
862 | lock_kernel(); | 863 | mutex_lock(&cpqarray_mutex); |
863 | host = get_host(disk); | 864 | host = get_host(disk); |
864 | host->usage_count--; | 865 | host->usage_count--; |
865 | unlock_kernel(); | 866 | mutex_unlock(&cpqarray_mutex); |
866 | 867 | ||
867 | return 0; | 868 | return 0; |
868 | } | 869 | } |
@@ -1217,9 +1218,9 @@ static int ida_ioctl(struct block_device *bdev, fmode_t mode, | |||
1217 | { | 1218 | { |
1218 | int ret; | 1219 | int ret; |
1219 | 1220 | ||
1220 | lock_kernel(); | 1221 | mutex_lock(&cpqarray_mutex); |
1221 | ret = ida_locked_ioctl(bdev, mode, cmd, param); | 1222 | ret = ida_locked_ioctl(bdev, mode, cmd, param); |
1222 | unlock_kernel(); | 1223 | mutex_unlock(&cpqarray_mutex); |
1223 | 1224 | ||
1224 | return ret; | 1225 | return ret; |
1225 | } | 1226 | } |
diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c index fa650dd85b90..e4b56119866e 100644 --- a/drivers/block/drbd/drbd_main.c +++ b/drivers/block/drbd/drbd_main.c | |||
@@ -32,7 +32,7 @@ | |||
32 | #include <asm/types.h> | 32 | #include <asm/types.h> |
33 | #include <net/sock.h> | 33 | #include <net/sock.h> |
34 | #include <linux/ctype.h> | 34 | #include <linux/ctype.h> |
35 | #include <linux/smp_lock.h> | 35 | #include <linux/mutex.h> |
36 | #include <linux/fs.h> | 36 | #include <linux/fs.h> |
37 | #include <linux/file.h> | 37 | #include <linux/file.h> |
38 | #include <linux/proc_fs.h> | 38 | #include <linux/proc_fs.h> |
@@ -64,6 +64,7 @@ struct after_state_chg_work { | |||
64 | struct completion *done; | 64 | struct completion *done; |
65 | }; | 65 | }; |
66 | 66 | ||
67 | static DEFINE_MUTEX(drbd_main_mutex); | ||
67 | int drbdd_init(struct drbd_thread *); | 68 | int drbdd_init(struct drbd_thread *); |
68 | int drbd_worker(struct drbd_thread *); | 69 | int drbd_worker(struct drbd_thread *); |
69 | int drbd_asender(struct drbd_thread *); | 70 | int drbd_asender(struct drbd_thread *); |
@@ -2536,7 +2537,7 @@ static int drbd_open(struct block_device *bdev, fmode_t mode) | |||
2536 | unsigned long flags; | 2537 | unsigned long flags; |
2537 | int rv = 0; | 2538 | int rv = 0; |
2538 | 2539 | ||
2539 | lock_kernel(); | 2540 | mutex_lock(&drbd_main_mutex); |
2540 | spin_lock_irqsave(&mdev->req_lock, flags); | 2541 | spin_lock_irqsave(&mdev->req_lock, flags); |
2541 | /* to have a stable mdev->state.role | 2542 | /* to have a stable mdev->state.role |
2542 | * and no race with updating open_cnt */ | 2543 | * and no race with updating open_cnt */ |
@@ -2551,7 +2552,7 @@ static int drbd_open(struct block_device *bdev, fmode_t mode) | |||
2551 | if (!rv) | 2552 | if (!rv) |
2552 | mdev->open_cnt++; | 2553 | mdev->open_cnt++; |
2553 | spin_unlock_irqrestore(&mdev->req_lock, flags); | 2554 | spin_unlock_irqrestore(&mdev->req_lock, flags); |
2554 | unlock_kernel(); | 2555 | mutex_unlock(&drbd_main_mutex); |
2555 | 2556 | ||
2556 | return rv; | 2557 | return rv; |
2557 | } | 2558 | } |
@@ -2559,9 +2560,9 @@ static int drbd_open(struct block_device *bdev, fmode_t mode) | |||
2559 | static int drbd_release(struct gendisk *gd, fmode_t mode) | 2560 | static int drbd_release(struct gendisk *gd, fmode_t mode) |
2560 | { | 2561 | { |
2561 | struct drbd_conf *mdev = gd->private_data; | 2562 | struct drbd_conf *mdev = gd->private_data; |
2562 | lock_kernel(); | 2563 | mutex_lock(&drbd_main_mutex); |
2563 | mdev->open_cnt--; | 2564 | mdev->open_cnt--; |
2564 | unlock_kernel(); | 2565 | mutex_unlock(&drbd_main_mutex); |
2565 | return 0; | 2566 | return 0; |
2566 | } | 2567 | } |
2567 | 2568 | ||
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c index cf04c1b234ed..3b57459bb745 100644 --- a/drivers/block/floppy.c +++ b/drivers/block/floppy.c | |||
@@ -178,7 +178,6 @@ static int print_unex = 1; | |||
178 | #include <linux/slab.h> | 178 | #include <linux/slab.h> |
179 | #include <linux/mm.h> | 179 | #include <linux/mm.h> |
180 | #include <linux/bio.h> | 180 | #include <linux/bio.h> |
181 | #include <linux/smp_lock.h> | ||
182 | #include <linux/string.h> | 181 | #include <linux/string.h> |
183 | #include <linux/jiffies.h> | 182 | #include <linux/jiffies.h> |
184 | #include <linux/fcntl.h> | 183 | #include <linux/fcntl.h> |
@@ -199,6 +198,7 @@ static int print_unex = 1; | |||
199 | * It's been recommended that take about 1/4 of the default speed | 198 | * It's been recommended that take about 1/4 of the default speed |
200 | * in some more extreme cases. | 199 | * in some more extreme cases. |
201 | */ | 200 | */ |
201 | static DEFINE_MUTEX(floppy_mutex); | ||
202 | static int slow_floppy; | 202 | static int slow_floppy; |
203 | 203 | ||
204 | #include <asm/dma.h> | 204 | #include <asm/dma.h> |
@@ -3553,9 +3553,9 @@ static int fd_ioctl(struct block_device *bdev, fmode_t mode, | |||
3553 | { | 3553 | { |
3554 | int ret; | 3554 | int ret; |
3555 | 3555 | ||
3556 | lock_kernel(); | 3556 | mutex_lock(&floppy_mutex); |
3557 | ret = fd_locked_ioctl(bdev, mode, cmd, param); | 3557 | ret = fd_locked_ioctl(bdev, mode, cmd, param); |
3558 | unlock_kernel(); | 3558 | mutex_unlock(&floppy_mutex); |
3559 | 3559 | ||
3560 | return ret; | 3560 | return ret; |
3561 | } | 3561 | } |
@@ -3616,7 +3616,7 @@ static int floppy_release(struct gendisk *disk, fmode_t mode) | |||
3616 | { | 3616 | { |
3617 | int drive = (long)disk->private_data; | 3617 | int drive = (long)disk->private_data; |
3618 | 3618 | ||
3619 | lock_kernel(); | 3619 | mutex_lock(&floppy_mutex); |
3620 | mutex_lock(&open_lock); | 3620 | mutex_lock(&open_lock); |
3621 | if (UDRS->fd_ref < 0) | 3621 | if (UDRS->fd_ref < 0) |
3622 | UDRS->fd_ref = 0; | 3622 | UDRS->fd_ref = 0; |
@@ -3627,7 +3627,7 @@ static int floppy_release(struct gendisk *disk, fmode_t mode) | |||
3627 | if (!UDRS->fd_ref) | 3627 | if (!UDRS->fd_ref) |
3628 | opened_bdev[drive] = NULL; | 3628 | opened_bdev[drive] = NULL; |
3629 | mutex_unlock(&open_lock); | 3629 | mutex_unlock(&open_lock); |
3630 | unlock_kernel(); | 3630 | mutex_unlock(&floppy_mutex); |
3631 | 3631 | ||
3632 | return 0; | 3632 | return 0; |
3633 | } | 3633 | } |
@@ -3645,7 +3645,7 @@ static int floppy_open(struct block_device *bdev, fmode_t mode) | |||
3645 | int res = -EBUSY; | 3645 | int res = -EBUSY; |
3646 | char *tmp; | 3646 | char *tmp; |
3647 | 3647 | ||
3648 | lock_kernel(); | 3648 | mutex_lock(&floppy_mutex); |
3649 | mutex_lock(&open_lock); | 3649 | mutex_lock(&open_lock); |
3650 | old_dev = UDRS->fd_device; | 3650 | old_dev = UDRS->fd_device; |
3651 | if (opened_bdev[drive] && opened_bdev[drive] != bdev) | 3651 | if (opened_bdev[drive] && opened_bdev[drive] != bdev) |
@@ -3722,7 +3722,7 @@ static int floppy_open(struct block_device *bdev, fmode_t mode) | |||
3722 | goto out; | 3722 | goto out; |
3723 | } | 3723 | } |
3724 | mutex_unlock(&open_lock); | 3724 | mutex_unlock(&open_lock); |
3725 | unlock_kernel(); | 3725 | mutex_unlock(&floppy_mutex); |
3726 | return 0; | 3726 | return 0; |
3727 | out: | 3727 | out: |
3728 | if (UDRS->fd_ref < 0) | 3728 | if (UDRS->fd_ref < 0) |
@@ -3733,7 +3733,7 @@ out: | |||
3733 | opened_bdev[drive] = NULL; | 3733 | opened_bdev[drive] = NULL; |
3734 | out2: | 3734 | out2: |
3735 | mutex_unlock(&open_lock); | 3735 | mutex_unlock(&open_lock); |
3736 | unlock_kernel(); | 3736 | mutex_unlock(&floppy_mutex); |
3737 | return res; | 3737 | return res; |
3738 | } | 3738 | } |
3739 | 3739 | ||
diff --git a/drivers/block/loop.c b/drivers/block/loop.c index 91797bbbe702..a10c8c9b6b78 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c | |||
@@ -67,7 +67,7 @@ | |||
67 | #include <linux/compat.h> | 67 | #include <linux/compat.h> |
68 | #include <linux/suspend.h> | 68 | #include <linux/suspend.h> |
69 | #include <linux/freezer.h> | 69 | #include <linux/freezer.h> |
70 | #include <linux/smp_lock.h> | 70 | #include <linux/mutex.h> |
71 | #include <linux/writeback.h> | 71 | #include <linux/writeback.h> |
72 | #include <linux/buffer_head.h> /* for invalidate_bdev() */ | 72 | #include <linux/buffer_head.h> /* for invalidate_bdev() */ |
73 | #include <linux/completion.h> | 73 | #include <linux/completion.h> |
@@ -77,6 +77,7 @@ | |||
77 | 77 | ||
78 | #include <asm/uaccess.h> | 78 | #include <asm/uaccess.h> |
79 | 79 | ||
80 | static DEFINE_MUTEX(loop_mutex); | ||
80 | static LIST_HEAD(loop_devices); | 81 | static LIST_HEAD(loop_devices); |
81 | static DEFINE_MUTEX(loop_devices_mutex); | 82 | static DEFINE_MUTEX(loop_devices_mutex); |
82 | 83 | ||
@@ -1409,11 +1410,11 @@ static int lo_open(struct block_device *bdev, fmode_t mode) | |||
1409 | { | 1410 | { |
1410 | struct loop_device *lo = bdev->bd_disk->private_data; | 1411 | struct loop_device *lo = bdev->bd_disk->private_data; |
1411 | 1412 | ||
1412 | lock_kernel(); | 1413 | mutex_lock(&loop_mutex); |
1413 | mutex_lock(&lo->lo_ctl_mutex); | 1414 | mutex_lock(&lo->lo_ctl_mutex); |
1414 | lo->lo_refcnt++; | 1415 | lo->lo_refcnt++; |
1415 | mutex_unlock(&lo->lo_ctl_mutex); | 1416 | mutex_unlock(&lo->lo_ctl_mutex); |
1416 | unlock_kernel(); | 1417 | mutex_unlock(&loop_mutex); |
1417 | 1418 | ||
1418 | return 0; | 1419 | return 0; |
1419 | } | 1420 | } |
@@ -1423,7 +1424,7 @@ static int lo_release(struct gendisk *disk, fmode_t mode) | |||
1423 | struct loop_device *lo = disk->private_data; | 1424 | struct loop_device *lo = disk->private_data; |
1424 | int err; | 1425 | int err; |
1425 | 1426 | ||
1426 | lock_kernel(); | 1427 | mutex_lock(&loop_mutex); |
1427 | mutex_lock(&lo->lo_ctl_mutex); | 1428 | mutex_lock(&lo->lo_ctl_mutex); |
1428 | 1429 | ||
1429 | if (--lo->lo_refcnt) | 1430 | if (--lo->lo_refcnt) |
@@ -1448,7 +1449,7 @@ static int lo_release(struct gendisk *disk, fmode_t mode) | |||
1448 | out: | 1449 | out: |
1449 | mutex_unlock(&lo->lo_ctl_mutex); | 1450 | mutex_unlock(&lo->lo_ctl_mutex); |
1450 | out_unlocked: | 1451 | out_unlocked: |
1451 | lock_kernel(); | 1452 | mutex_unlock(&loop_mutex); |
1452 | return 0; | 1453 | return 0; |
1453 | } | 1454 | } |
1454 | 1455 | ||
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index 0daa422aa281..a32fb41246f8 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c | |||
@@ -24,7 +24,7 @@ | |||
24 | #include <linux/errno.h> | 24 | #include <linux/errno.h> |
25 | #include <linux/file.h> | 25 | #include <linux/file.h> |
26 | #include <linux/ioctl.h> | 26 | #include <linux/ioctl.h> |
27 | #include <linux/smp_lock.h> | 27 | #include <linux/mutex.h> |
28 | #include <linux/compiler.h> | 28 | #include <linux/compiler.h> |
29 | #include <linux/err.h> | 29 | #include <linux/err.h> |
30 | #include <linux/kernel.h> | 30 | #include <linux/kernel.h> |
@@ -53,6 +53,7 @@ | |||
53 | #define DBG_BLKDEV 0x0100 | 53 | #define DBG_BLKDEV 0x0100 |
54 | #define DBG_RX 0x0200 | 54 | #define DBG_RX 0x0200 |
55 | #define DBG_TX 0x0400 | 55 | #define DBG_TX 0x0400 |
56 | static DEFINE_MUTEX(nbd_mutex); | ||
56 | static unsigned int debugflags; | 57 | static unsigned int debugflags; |
57 | #endif /* NDEBUG */ | 58 | #endif /* NDEBUG */ |
58 | 59 | ||
@@ -717,11 +718,11 @@ static int nbd_ioctl(struct block_device *bdev, fmode_t mode, | |||
717 | dprintk(DBG_IOCTL, "%s: nbd_ioctl cmd=%s(0x%x) arg=%lu\n", | 718 | dprintk(DBG_IOCTL, "%s: nbd_ioctl cmd=%s(0x%x) arg=%lu\n", |
718 | lo->disk->disk_name, ioctl_cmd_to_ascii(cmd), cmd, arg); | 719 | lo->disk->disk_name, ioctl_cmd_to_ascii(cmd), cmd, arg); |
719 | 720 | ||
720 | lock_kernel(); | 721 | mutex_lock(&nbd_mutex); |
721 | mutex_lock(&lo->tx_lock); | 722 | mutex_lock(&lo->tx_lock); |
722 | error = __nbd_ioctl(bdev, lo, cmd, arg); | 723 | error = __nbd_ioctl(bdev, lo, cmd, arg); |
723 | mutex_unlock(&lo->tx_lock); | 724 | mutex_unlock(&lo->tx_lock); |
724 | unlock_kernel(); | 725 | mutex_unlock(&nbd_mutex); |
725 | 726 | ||
726 | return error; | 727 | return error; |
727 | } | 728 | } |
diff --git a/drivers/block/paride/pcd.c b/drivers/block/paride/pcd.c index 76f8565e1e8d..62cec6afd7ad 100644 --- a/drivers/block/paride/pcd.c +++ b/drivers/block/paride/pcd.c | |||
@@ -138,9 +138,10 @@ enum {D_PRT, D_PRO, D_UNI, D_MOD, D_SLV, D_DLY}; | |||
138 | #include <linux/cdrom.h> | 138 | #include <linux/cdrom.h> |
139 | #include <linux/spinlock.h> | 139 | #include <linux/spinlock.h> |
140 | #include <linux/blkdev.h> | 140 | #include <linux/blkdev.h> |
141 | #include <linux/smp_lock.h> | 141 | #include <linux/mutex.h> |
142 | #include <asm/uaccess.h> | 142 | #include <asm/uaccess.h> |
143 | 143 | ||
144 | static DEFINE_MUTEX(pcd_mutex); | ||
144 | static DEFINE_SPINLOCK(pcd_lock); | 145 | static DEFINE_SPINLOCK(pcd_lock); |
145 | 146 | ||
146 | module_param(verbose, bool, 0644); | 147 | module_param(verbose, bool, 0644); |
@@ -227,9 +228,9 @@ static int pcd_block_open(struct block_device *bdev, fmode_t mode) | |||
227 | struct pcd_unit *cd = bdev->bd_disk->private_data; | 228 | struct pcd_unit *cd = bdev->bd_disk->private_data; |
228 | int ret; | 229 | int ret; |
229 | 230 | ||
230 | lock_kernel(); | 231 | mutex_lock(&pcd_mutex); |
231 | ret = cdrom_open(&cd->info, bdev, mode); | 232 | ret = cdrom_open(&cd->info, bdev, mode); |
232 | unlock_kernel(); | 233 | mutex_unlock(&pcd_mutex); |
233 | 234 | ||
234 | return ret; | 235 | return ret; |
235 | } | 236 | } |
@@ -237,9 +238,9 @@ static int pcd_block_open(struct block_device *bdev, fmode_t mode) | |||
237 | static int pcd_block_release(struct gendisk *disk, fmode_t mode) | 238 | static int pcd_block_release(struct gendisk *disk, fmode_t mode) |
238 | { | 239 | { |
239 | struct pcd_unit *cd = disk->private_data; | 240 | struct pcd_unit *cd = disk->private_data; |
240 | lock_kernel(); | 241 | mutex_lock(&pcd_mutex); |
241 | cdrom_release(&cd->info, mode); | 242 | cdrom_release(&cd->info, mode); |
242 | unlock_kernel(); | 243 | mutex_unlock(&pcd_mutex); |
243 | return 0; | 244 | return 0; |
244 | } | 245 | } |
245 | 246 | ||
@@ -249,9 +250,9 @@ static int pcd_block_ioctl(struct block_device *bdev, fmode_t mode, | |||
249 | struct pcd_unit *cd = bdev->bd_disk->private_data; | 250 | struct pcd_unit *cd = bdev->bd_disk->private_data; |
250 | int ret; | 251 | int ret; |
251 | 252 | ||
252 | lock_kernel(); | 253 | mutex_lock(&pcd_mutex); |
253 | ret = cdrom_ioctl(&cd->info, bdev, mode, cmd, arg); | 254 | ret = cdrom_ioctl(&cd->info, bdev, mode, cmd, arg); |
254 | unlock_kernel(); | 255 | mutex_unlock(&pcd_mutex); |
255 | 256 | ||
256 | return ret; | 257 | return ret; |
257 | } | 258 | } |
diff --git a/drivers/block/paride/pd.c b/drivers/block/paride/pd.c index 985f0d4f1d1e..c0ee1558b9bb 100644 --- a/drivers/block/paride/pd.c +++ b/drivers/block/paride/pd.c | |||
@@ -153,10 +153,11 @@ enum {D_PRT, D_PRO, D_UNI, D_MOD, D_GEO, D_SBY, D_DLY, D_SLV}; | |||
153 | #include <linux/blkdev.h> | 153 | #include <linux/blkdev.h> |
154 | #include <linux/blkpg.h> | 154 | #include <linux/blkpg.h> |
155 | #include <linux/kernel.h> | 155 | #include <linux/kernel.h> |
156 | #include <linux/smp_lock.h> | 156 | #include <linux/mutex.h> |
157 | #include <asm/uaccess.h> | 157 | #include <asm/uaccess.h> |
158 | #include <linux/workqueue.h> | 158 | #include <linux/workqueue.h> |
159 | 159 | ||
160 | static DEFINE_MUTEX(pd_mutex); | ||
160 | static DEFINE_SPINLOCK(pd_lock); | 161 | static DEFINE_SPINLOCK(pd_lock); |
161 | 162 | ||
162 | module_param(verbose, bool, 0); | 163 | module_param(verbose, bool, 0); |
@@ -736,14 +737,14 @@ static int pd_open(struct block_device *bdev, fmode_t mode) | |||
736 | { | 737 | { |
737 | struct pd_unit *disk = bdev->bd_disk->private_data; | 738 | struct pd_unit *disk = bdev->bd_disk->private_data; |
738 | 739 | ||
739 | lock_kernel(); | 740 | mutex_lock(&pd_mutex); |
740 | disk->access++; | 741 | disk->access++; |
741 | 742 | ||
742 | if (disk->removable) { | 743 | if (disk->removable) { |
743 | pd_special_command(disk, pd_media_check); | 744 | pd_special_command(disk, pd_media_check); |
744 | pd_special_command(disk, pd_door_lock); | 745 | pd_special_command(disk, pd_door_lock); |
745 | } | 746 | } |
746 | unlock_kernel(); | 747 | mutex_unlock(&pd_mutex); |
747 | return 0; | 748 | return 0; |
748 | } | 749 | } |
749 | 750 | ||
@@ -771,10 +772,10 @@ static int pd_ioctl(struct block_device *bdev, fmode_t mode, | |||
771 | 772 | ||
772 | switch (cmd) { | 773 | switch (cmd) { |
773 | case CDROMEJECT: | 774 | case CDROMEJECT: |
774 | lock_kernel(); | 775 | mutex_lock(&pd_mutex); |
775 | if (disk->access == 1) | 776 | if (disk->access == 1) |
776 | pd_special_command(disk, pd_eject); | 777 | pd_special_command(disk, pd_eject); |
777 | unlock_kernel(); | 778 | mutex_unlock(&pd_mutex); |
778 | return 0; | 779 | return 0; |
779 | default: | 780 | default: |
780 | return -EINVAL; | 781 | return -EINVAL; |
@@ -785,10 +786,10 @@ static int pd_release(struct gendisk *p, fmode_t mode) | |||
785 | { | 786 | { |
786 | struct pd_unit *disk = p->private_data; | 787 | struct pd_unit *disk = p->private_data; |
787 | 788 | ||
788 | lock_kernel(); | 789 | mutex_lock(&pd_mutex); |
789 | if (!--disk->access && disk->removable) | 790 | if (!--disk->access && disk->removable) |
790 | pd_special_command(disk, pd_door_unlock); | 791 | pd_special_command(disk, pd_door_unlock); |
791 | unlock_kernel(); | 792 | mutex_unlock(&pd_mutex); |
792 | 793 | ||
793 | return 0; | 794 | return 0; |
794 | } | 795 | } |
diff --git a/drivers/block/paride/pf.c b/drivers/block/paride/pf.c index 4457b494882a..635f25dd9e10 100644 --- a/drivers/block/paride/pf.c +++ b/drivers/block/paride/pf.c | |||
@@ -152,9 +152,10 @@ enum {D_PRT, D_PRO, D_UNI, D_MOD, D_SLV, D_LUN, D_DLY}; | |||
152 | #include <linux/spinlock.h> | 152 | #include <linux/spinlock.h> |
153 | #include <linux/blkdev.h> | 153 | #include <linux/blkdev.h> |
154 | #include <linux/blkpg.h> | 154 | #include <linux/blkpg.h> |
155 | #include <linux/smp_lock.h> | 155 | #include <linux/mutex.h> |
156 | #include <asm/uaccess.h> | 156 | #include <asm/uaccess.h> |
157 | 157 | ||
158 | static DEFINE_MUTEX(pf_mutex); | ||
158 | static DEFINE_SPINLOCK(pf_spin_lock); | 159 | static DEFINE_SPINLOCK(pf_spin_lock); |
159 | 160 | ||
160 | module_param(verbose, bool, 0644); | 161 | module_param(verbose, bool, 0644); |
@@ -302,7 +303,7 @@ static int pf_open(struct block_device *bdev, fmode_t mode) | |||
302 | struct pf_unit *pf = bdev->bd_disk->private_data; | 303 | struct pf_unit *pf = bdev->bd_disk->private_data; |
303 | int ret; | 304 | int ret; |
304 | 305 | ||
305 | lock_kernel(); | 306 | mutex_lock(&pf_mutex); |
306 | pf_identify(pf); | 307 | pf_identify(pf); |
307 | 308 | ||
308 | ret = -ENODEV; | 309 | ret = -ENODEV; |
@@ -318,7 +319,7 @@ static int pf_open(struct block_device *bdev, fmode_t mode) | |||
318 | if (pf->removable) | 319 | if (pf->removable) |
319 | pf_lock(pf, 1); | 320 | pf_lock(pf, 1); |
320 | out: | 321 | out: |
321 | unlock_kernel(); | 322 | mutex_unlock(&pf_mutex); |
322 | return ret; | 323 | return ret; |
323 | } | 324 | } |
324 | 325 | ||
@@ -349,9 +350,9 @@ static int pf_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, u | |||
349 | 350 | ||
350 | if (pf->access != 1) | 351 | if (pf->access != 1) |
351 | return -EBUSY; | 352 | return -EBUSY; |
352 | lock_kernel(); | 353 | mutex_lock(&pf_mutex); |
353 | pf_eject(pf); | 354 | pf_eject(pf); |
354 | unlock_kernel(); | 355 | mutex_unlock(&pf_mutex); |
355 | 356 | ||
356 | return 0; | 357 | return 0; |
357 | } | 358 | } |
@@ -360,9 +361,9 @@ static int pf_release(struct gendisk *disk, fmode_t mode) | |||
360 | { | 361 | { |
361 | struct pf_unit *pf = disk->private_data; | 362 | struct pf_unit *pf = disk->private_data; |
362 | 363 | ||
363 | lock_kernel(); | 364 | mutex_lock(&pf_mutex); |
364 | if (pf->access <= 0) { | 365 | if (pf->access <= 0) { |
365 | unlock_kernel(); | 366 | mutex_unlock(&pf_mutex); |
366 | return -EINVAL; | 367 | return -EINVAL; |
367 | } | 368 | } |
368 | 369 | ||
@@ -371,7 +372,7 @@ static int pf_release(struct gendisk *disk, fmode_t mode) | |||
371 | if (!pf->access && pf->removable) | 372 | if (!pf->access && pf->removable) |
372 | pf_lock(pf, 0); | 373 | pf_lock(pf, 0); |
373 | 374 | ||
374 | unlock_kernel(); | 375 | mutex_unlock(&pf_mutex); |
375 | return 0; | 376 | return 0; |
376 | 377 | ||
377 | } | 378 | } |
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 | ||
88 | static DEFINE_MUTEX(pktcdvd_mutex); | ||
89 | static struct pktcdvd_device *pkt_devs[MAX_WRITERS]; | 89 | static struct pktcdvd_device *pkt_devs[MAX_WRITERS]; |
90 | static struct proc_dir_entry *pkt_proc; | 90 | static struct proc_dir_entry *pkt_proc; |
91 | static int pktdev_major; | 91 | static 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 | ||
2417 | out_dec: | 2417 | out_dec: |
@@ -2419,7 +2419,7 @@ out_dec: | |||
2419 | out: | 2419 | out: |
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 | } |
diff --git a/drivers/block/swim.c b/drivers/block/swim.c index 2e46815876df..75333d0a3327 100644 --- a/drivers/block/swim.c +++ b/drivers/block/swim.c | |||
@@ -20,7 +20,7 @@ | |||
20 | #include <linux/fd.h> | 20 | #include <linux/fd.h> |
21 | #include <linux/slab.h> | 21 | #include <linux/slab.h> |
22 | #include <linux/blkdev.h> | 22 | #include <linux/blkdev.h> |
23 | #include <linux/smp_lock.h> | 23 | #include <linux/mutex.h> |
24 | #include <linux/hdreg.h> | 24 | #include <linux/hdreg.h> |
25 | #include <linux/kernel.h> | 25 | #include <linux/kernel.h> |
26 | #include <linux/delay.h> | 26 | #include <linux/delay.h> |
@@ -222,6 +222,7 @@ extern int swim_read_sector_header(struct swim __iomem *base, | |||
222 | extern int swim_read_sector_data(struct swim __iomem *base, | 222 | extern int swim_read_sector_data(struct swim __iomem *base, |
223 | unsigned char *data); | 223 | unsigned char *data); |
224 | 224 | ||
225 | static DEFINE_MUTEX(swim_mutex); | ||
225 | static inline void set_swim_mode(struct swim __iomem *base, int enable) | 226 | static inline void set_swim_mode(struct swim __iomem *base, int enable) |
226 | { | 227 | { |
227 | struct iwm __iomem *iwm_base; | 228 | struct iwm __iomem *iwm_base; |
@@ -666,9 +667,9 @@ static int floppy_unlocked_open(struct block_device *bdev, fmode_t mode) | |||
666 | { | 667 | { |
667 | int ret; | 668 | int ret; |
668 | 669 | ||
669 | lock_kernel(); | 670 | mutex_lock(&swim_mutex); |
670 | ret = floppy_open(bdev, mode); | 671 | ret = floppy_open(bdev, mode); |
671 | unlock_kernel(); | 672 | mutex_unlock(&swim_mutex); |
672 | 673 | ||
673 | return ret; | 674 | return ret; |
674 | } | 675 | } |
@@ -678,7 +679,7 @@ static int floppy_release(struct gendisk *disk, fmode_t mode) | |||
678 | struct floppy_state *fs = disk->private_data; | 679 | struct floppy_state *fs = disk->private_data; |
679 | struct swim __iomem *base = fs->swd->base; | 680 | struct swim __iomem *base = fs->swd->base; |
680 | 681 | ||
681 | lock_kernel(); | 682 | mutex_lock(&swim_mutex); |
682 | if (fs->ref_count < 0) | 683 | if (fs->ref_count < 0) |
683 | fs->ref_count = 0; | 684 | fs->ref_count = 0; |
684 | else if (fs->ref_count > 0) | 685 | else if (fs->ref_count > 0) |
@@ -686,7 +687,7 @@ static int floppy_release(struct gendisk *disk, fmode_t mode) | |||
686 | 687 | ||
687 | if (fs->ref_count == 0) | 688 | if (fs->ref_count == 0) |
688 | swim_motor(base, OFF); | 689 | swim_motor(base, OFF); |
689 | unlock_kernel(); | 690 | mutex_unlock(&swim_mutex); |
690 | 691 | ||
691 | return 0; | 692 | return 0; |
692 | } | 693 | } |
@@ -704,9 +705,9 @@ static int floppy_ioctl(struct block_device *bdev, fmode_t mode, | |||
704 | case FDEJECT: | 705 | case FDEJECT: |
705 | if (fs->ref_count != 1) | 706 | if (fs->ref_count != 1) |
706 | return -EBUSY; | 707 | return -EBUSY; |
707 | lock_kernel(); | 708 | mutex_lock(&swim_mutex); |
708 | err = floppy_eject(fs); | 709 | err = floppy_eject(fs); |
709 | unlock_kernel(); | 710 | mutex_unlock(&swim_mutex); |
710 | return err; | 711 | return err; |
711 | 712 | ||
712 | case FDGETPRM: | 713 | case FDGETPRM: |
diff --git a/drivers/block/swim3.c b/drivers/block/swim3.c index cc6a3864822c..bf3a5b859299 100644 --- a/drivers/block/swim3.c +++ b/drivers/block/swim3.c | |||
@@ -25,7 +25,7 @@ | |||
25 | #include <linux/ioctl.h> | 25 | #include <linux/ioctl.h> |
26 | #include <linux/blkdev.h> | 26 | #include <linux/blkdev.h> |
27 | #include <linux/interrupt.h> | 27 | #include <linux/interrupt.h> |
28 | #include <linux/smp_lock.h> | 28 | #include <linux/mutex.h> |
29 | #include <linux/module.h> | 29 | #include <linux/module.h> |
30 | #include <linux/spinlock.h> | 30 | #include <linux/spinlock.h> |
31 | #include <asm/io.h> | 31 | #include <asm/io.h> |
@@ -36,6 +36,7 @@ | |||
36 | #include <asm/machdep.h> | 36 | #include <asm/machdep.h> |
37 | #include <asm/pmac_feature.h> | 37 | #include <asm/pmac_feature.h> |
38 | 38 | ||
39 | static DEFINE_MUTEX(swim3_mutex); | ||
39 | static struct request_queue *swim3_queue; | 40 | static struct request_queue *swim3_queue; |
40 | static struct gendisk *disks[2]; | 41 | static struct gendisk *disks[2]; |
41 | static struct request *fd_req; | 42 | static struct request *fd_req; |
@@ -873,9 +874,9 @@ static int floppy_ioctl(struct block_device *bdev, fmode_t mode, | |||
873 | { | 874 | { |
874 | int ret; | 875 | int ret; |
875 | 876 | ||
876 | lock_kernel(); | 877 | mutex_lock(&swim3_mutex); |
877 | ret = floppy_locked_ioctl(bdev, mode, cmd, param); | 878 | ret = floppy_locked_ioctl(bdev, mode, cmd, param); |
878 | unlock_kernel(); | 879 | mutex_unlock(&swim3_mutex); |
879 | 880 | ||
880 | return ret; | 881 | return ret; |
881 | } | 882 | } |
@@ -953,9 +954,9 @@ static int floppy_unlocked_open(struct block_device *bdev, fmode_t mode) | |||
953 | { | 954 | { |
954 | int ret; | 955 | int ret; |
955 | 956 | ||
956 | lock_kernel(); | 957 | mutex_lock(&swim3_mutex); |
957 | ret = floppy_open(bdev, mode); | 958 | ret = floppy_open(bdev, mode); |
958 | unlock_kernel(); | 959 | mutex_unlock(&swim3_mutex); |
959 | 960 | ||
960 | return ret; | 961 | return ret; |
961 | } | 962 | } |
@@ -964,13 +965,13 @@ static int floppy_release(struct gendisk *disk, fmode_t mode) | |||
964 | { | 965 | { |
965 | struct floppy_state *fs = disk->private_data; | 966 | struct floppy_state *fs = disk->private_data; |
966 | struct swim3 __iomem *sw = fs->swim3; | 967 | struct swim3 __iomem *sw = fs->swim3; |
967 | lock_kernel(); | 968 | mutex_lock(&swim3_mutex); |
968 | if (fs->ref_count > 0 && --fs->ref_count == 0) { | 969 | if (fs->ref_count > 0 && --fs->ref_count == 0) { |
969 | swim3_action(fs, MOTOR_OFF); | 970 | swim3_action(fs, MOTOR_OFF); |
970 | out_8(&sw->control_bic, 0xff); | 971 | out_8(&sw->control_bic, 0xff); |
971 | swim3_select(fs, RELAX); | 972 | swim3_select(fs, RELAX); |
972 | } | 973 | } |
973 | unlock_kernel(); | 974 | mutex_unlock(&swim3_mutex); |
974 | return 0; | 975 | return 0; |
975 | } | 976 | } |
976 | 977 | ||
diff --git a/drivers/block/ub.c b/drivers/block/ub.c index c48e14878582..b5690a045a01 100644 --- a/drivers/block/ub.c +++ b/drivers/block/ub.c | |||
@@ -28,7 +28,7 @@ | |||
28 | #include <linux/timer.h> | 28 | #include <linux/timer.h> |
29 | #include <linux/scatterlist.h> | 29 | #include <linux/scatterlist.h> |
30 | #include <linux/slab.h> | 30 | #include <linux/slab.h> |
31 | #include <linux/smp_lock.h> | 31 | #include <linux/mutex.h> |
32 | #include <scsi/scsi.h> | 32 | #include <scsi/scsi.h> |
33 | 33 | ||
34 | #define DRV_NAME "ub" | 34 | #define DRV_NAME "ub" |
@@ -248,6 +248,7 @@ struct ub_completion { | |||
248 | spinlock_t lock; | 248 | spinlock_t lock; |
249 | }; | 249 | }; |
250 | 250 | ||
251 | static DEFINE_MUTEX(ub_mutex); | ||
251 | static inline void ub_init_completion(struct ub_completion *x) | 252 | static inline void ub_init_completion(struct ub_completion *x) |
252 | { | 253 | { |
253 | x->done = 0; | 254 | x->done = 0; |
@@ -1715,9 +1716,9 @@ static int ub_bd_unlocked_open(struct block_device *bdev, fmode_t mode) | |||
1715 | { | 1716 | { |
1716 | int ret; | 1717 | int ret; |
1717 | 1718 | ||
1718 | lock_kernel(); | 1719 | mutex_lock(&ub_mutex); |
1719 | ret = ub_bd_open(bdev, mode); | 1720 | ret = ub_bd_open(bdev, mode); |
1720 | unlock_kernel(); | 1721 | mutex_unlock(&ub_mutex); |
1721 | 1722 | ||
1722 | return ret; | 1723 | return ret; |
1723 | } | 1724 | } |
@@ -1730,9 +1731,9 @@ static int ub_bd_release(struct gendisk *disk, fmode_t mode) | |||
1730 | struct ub_lun *lun = disk->private_data; | 1731 | struct ub_lun *lun = disk->private_data; |
1731 | struct ub_dev *sc = lun->udev; | 1732 | struct ub_dev *sc = lun->udev; |
1732 | 1733 | ||
1733 | lock_kernel(); | 1734 | mutex_lock(&ub_mutex); |
1734 | ub_put(sc); | 1735 | ub_put(sc); |
1735 | unlock_kernel(); | 1736 | mutex_unlock(&ub_mutex); |
1736 | 1737 | ||
1737 | return 0; | 1738 | return 0; |
1738 | } | 1739 | } |
@@ -1747,9 +1748,9 @@ static int ub_bd_ioctl(struct block_device *bdev, fmode_t mode, | |||
1747 | void __user *usermem = (void __user *) arg; | 1748 | void __user *usermem = (void __user *) arg; |
1748 | int ret; | 1749 | int ret; |
1749 | 1750 | ||
1750 | lock_kernel(); | 1751 | mutex_lock(&ub_mutex); |
1751 | ret = scsi_cmd_ioctl(disk->queue, disk, mode, cmd, usermem); | 1752 | ret = scsi_cmd_ioctl(disk->queue, disk, mode, cmd, usermem); |
1752 | unlock_kernel(); | 1753 | mutex_unlock(&ub_mutex); |
1753 | 1754 | ||
1754 | return ret; | 1755 | return ret; |
1755 | } | 1756 | } |
diff --git a/drivers/block/viodasd.c b/drivers/block/viodasd.c index f651e51a3319..e2ff697697c2 100644 --- a/drivers/block/viodasd.c +++ b/drivers/block/viodasd.c | |||
@@ -41,7 +41,7 @@ | |||
41 | #include <linux/errno.h> | 41 | #include <linux/errno.h> |
42 | #include <linux/init.h> | 42 | #include <linux/init.h> |
43 | #include <linux/string.h> | 43 | #include <linux/string.h> |
44 | #include <linux/smp_lock.h> | 44 | #include <linux/mutex.h> |
45 | #include <linux/dma-mapping.h> | 45 | #include <linux/dma-mapping.h> |
46 | #include <linux/completion.h> | 46 | #include <linux/completion.h> |
47 | #include <linux/device.h> | 47 | #include <linux/device.h> |
@@ -73,6 +73,7 @@ enum { | |||
73 | MAX_DISK_NAME = FIELD_SIZEOF(struct gendisk, disk_name) | 73 | MAX_DISK_NAME = FIELD_SIZEOF(struct gendisk, disk_name) |
74 | }; | 74 | }; |
75 | 75 | ||
76 | static DEFINE_MUTEX(viodasd_mutex); | ||
76 | static DEFINE_SPINLOCK(viodasd_spinlock); | 77 | static DEFINE_SPINLOCK(viodasd_spinlock); |
77 | 78 | ||
78 | #define VIOMAXREQ 16 | 79 | #define VIOMAXREQ 16 |
@@ -180,9 +181,9 @@ static int viodasd_unlocked_open(struct block_device *bdev, fmode_t mode) | |||
180 | { | 181 | { |
181 | int ret; | 182 | int ret; |
182 | 183 | ||
183 | lock_kernel(); | 184 | mutex_lock(&viodasd_mutex); |
184 | ret = viodasd_open(bdev, mode); | 185 | ret = viodasd_open(bdev, mode); |
185 | unlock_kernel(); | 186 | mutex_unlock(&viodasd_mutex); |
186 | 187 | ||
187 | return ret; | 188 | return ret; |
188 | } | 189 | } |
@@ -196,7 +197,7 @@ static int viodasd_release(struct gendisk *disk, fmode_t mode) | |||
196 | struct viodasd_device *d = disk->private_data; | 197 | struct viodasd_device *d = disk->private_data; |
197 | HvLpEvent_Rc hvrc; | 198 | HvLpEvent_Rc hvrc; |
198 | 199 | ||
199 | lock_kernel(); | 200 | mutex_lock(&viodasd_mutex); |
200 | /* Send the event to OS/400. We DON'T expect a response */ | 201 | /* Send the event to OS/400. We DON'T expect a response */ |
201 | hvrc = HvCallEvent_signalLpEventFast(viopath_hostLp, | 202 | hvrc = HvCallEvent_signalLpEventFast(viopath_hostLp, |
202 | HvLpEvent_Type_VirtualIo, | 203 | HvLpEvent_Type_VirtualIo, |
@@ -210,7 +211,7 @@ static int viodasd_release(struct gendisk *disk, fmode_t mode) | |||
210 | if (hvrc != 0) | 211 | if (hvrc != 0) |
211 | pr_warning("HV close call failed %d\n", (int)hvrc); | 212 | pr_warning("HV close call failed %d\n", (int)hvrc); |
212 | 213 | ||
213 | unlock_kernel(); | 214 | mutex_unlock(&viodasd_mutex); |
214 | 215 | ||
215 | return 0; | 216 | return 0; |
216 | } | 217 | } |
diff --git a/drivers/block/xd.c b/drivers/block/xd.c index d5a3cd750561..4abd2bcd20fb 100644 --- a/drivers/block/xd.c +++ b/drivers/block/xd.c | |||
@@ -46,7 +46,7 @@ | |||
46 | #include <linux/init.h> | 46 | #include <linux/init.h> |
47 | #include <linux/wait.h> | 47 | #include <linux/wait.h> |
48 | #include <linux/blkdev.h> | 48 | #include <linux/blkdev.h> |
49 | #include <linux/smp_lock.h> | 49 | #include <linux/mutex.h> |
50 | #include <linux/blkpg.h> | 50 | #include <linux/blkpg.h> |
51 | #include <linux/delay.h> | 51 | #include <linux/delay.h> |
52 | #include <linux/io.h> | 52 | #include <linux/io.h> |
@@ -58,6 +58,7 @@ | |||
58 | 58 | ||
59 | #include "xd.h" | 59 | #include "xd.h" |
60 | 60 | ||
61 | static DEFINE_MUTEX(xd_mutex); | ||
61 | static void __init do_xd_setup (int *integers); | 62 | static void __init do_xd_setup (int *integers); |
62 | #ifdef MODULE | 63 | #ifdef MODULE |
63 | static int xd[5] = { -1,-1,-1,-1, }; | 64 | static int xd[5] = { -1,-1,-1,-1, }; |
@@ -381,9 +382,9 @@ static int xd_ioctl(struct block_device *bdev, fmode_t mode, | |||
381 | { | 382 | { |
382 | int ret; | 383 | int ret; |
383 | 384 | ||
384 | lock_kernel(); | 385 | mutex_lock(&xd_mutex); |
385 | ret = xd_locked_ioctl(bdev, mode, cmd, param); | 386 | ret = xd_locked_ioctl(bdev, mode, cmd, param); |
386 | unlock_kernel(); | 387 | mutex_unlock(&xd_mutex); |
387 | 388 | ||
388 | return ret; | 389 | return ret; |
389 | } | 390 | } |
diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c index ab735a605cf3..3ff06f475eef 100644 --- a/drivers/block/xen-blkfront.c +++ b/drivers/block/xen-blkfront.c | |||
@@ -41,7 +41,7 @@ | |||
41 | #include <linux/cdrom.h> | 41 | #include <linux/cdrom.h> |
42 | #include <linux/module.h> | 42 | #include <linux/module.h> |
43 | #include <linux/slab.h> | 43 | #include <linux/slab.h> |
44 | #include <linux/smp_lock.h> | 44 | #include <linux/mutex.h> |
45 | #include <linux/scatterlist.h> | 45 | #include <linux/scatterlist.h> |
46 | 46 | ||
47 | #include <xen/xen.h> | 47 | #include <xen/xen.h> |
@@ -69,6 +69,7 @@ struct blk_shadow { | |||
69 | unsigned long frame[BLKIF_MAX_SEGMENTS_PER_REQUEST]; | 69 | unsigned long frame[BLKIF_MAX_SEGMENTS_PER_REQUEST]; |
70 | }; | 70 | }; |
71 | 71 | ||
72 | static DEFINE_MUTEX(blkfront_mutex); | ||
72 | static const struct block_device_operations xlvbd_block_fops; | 73 | static const struct block_device_operations xlvbd_block_fops; |
73 | 74 | ||
74 | #define BLK_RING_SIZE __RING_SIZE((struct blkif_sring *)0, PAGE_SIZE) | 75 | #define BLK_RING_SIZE __RING_SIZE((struct blkif_sring *)0, PAGE_SIZE) |
@@ -1201,7 +1202,7 @@ static int blkif_open(struct block_device *bdev, fmode_t mode) | |||
1201 | struct blkfront_info *info; | 1202 | struct blkfront_info *info; |
1202 | int err = 0; | 1203 | int err = 0; |
1203 | 1204 | ||
1204 | lock_kernel(); | 1205 | mutex_lock(&blkfront_mutex); |
1205 | 1206 | ||
1206 | info = disk->private_data; | 1207 | info = disk->private_data; |
1207 | if (!info) { | 1208 | if (!info) { |
@@ -1219,7 +1220,7 @@ static int blkif_open(struct block_device *bdev, fmode_t mode) | |||
1219 | mutex_unlock(&info->mutex); | 1220 | mutex_unlock(&info->mutex); |
1220 | 1221 | ||
1221 | out: | 1222 | out: |
1222 | unlock_kernel(); | 1223 | mutex_unlock(&blkfront_mutex); |
1223 | return err; | 1224 | return err; |
1224 | } | 1225 | } |
1225 | 1226 | ||
@@ -1229,7 +1230,7 @@ static int blkif_release(struct gendisk *disk, fmode_t mode) | |||
1229 | struct block_device *bdev; | 1230 | struct block_device *bdev; |
1230 | struct xenbus_device *xbdev; | 1231 | struct xenbus_device *xbdev; |
1231 | 1232 | ||
1232 | lock_kernel(); | 1233 | mutex_lock(&blkfront_mutex); |
1233 | 1234 | ||
1234 | bdev = bdget_disk(disk, 0); | 1235 | bdev = bdget_disk(disk, 0); |
1235 | bdput(bdev); | 1236 | bdput(bdev); |
@@ -1263,7 +1264,7 @@ static int blkif_release(struct gendisk *disk, fmode_t mode) | |||
1263 | } | 1264 | } |
1264 | 1265 | ||
1265 | out: | 1266 | out: |
1266 | unlock_kernel(); | 1267 | mutex_unlock(&blkfront_mutex); |
1267 | return 0; | 1268 | return 0; |
1268 | } | 1269 | } |
1269 | 1270 | ||
diff --git a/drivers/block/xsysace.c b/drivers/block/xsysace.c index 057413bb16e2..6e968cd4893c 100644 --- a/drivers/block/xsysace.c +++ b/drivers/block/xsysace.c | |||
@@ -89,7 +89,7 @@ | |||
89 | #include <linux/delay.h> | 89 | #include <linux/delay.h> |
90 | #include <linux/slab.h> | 90 | #include <linux/slab.h> |
91 | #include <linux/blkdev.h> | 91 | #include <linux/blkdev.h> |
92 | #include <linux/smp_lock.h> | 92 | #include <linux/mutex.h> |
93 | #include <linux/ata.h> | 93 | #include <linux/ata.h> |
94 | #include <linux/hdreg.h> | 94 | #include <linux/hdreg.h> |
95 | #include <linux/platform_device.h> | 95 | #include <linux/platform_device.h> |
@@ -214,6 +214,7 @@ struct ace_device { | |||
214 | u16 cf_id[ATA_ID_WORDS]; | 214 | u16 cf_id[ATA_ID_WORDS]; |
215 | }; | 215 | }; |
216 | 216 | ||
217 | static DEFINE_MUTEX(xsysace_mutex); | ||
217 | static int ace_major; | 218 | static int ace_major; |
218 | 219 | ||
219 | /* --------------------------------------------------------------------- | 220 | /* --------------------------------------------------------------------- |
@@ -903,13 +904,13 @@ static int ace_open(struct block_device *bdev, fmode_t mode) | |||
903 | 904 | ||
904 | dev_dbg(ace->dev, "ace_open() users=%i\n", ace->users + 1); | 905 | dev_dbg(ace->dev, "ace_open() users=%i\n", ace->users + 1); |
905 | 906 | ||
906 | lock_kernel(); | 907 | mutex_lock(&xsysace_mutex); |
907 | spin_lock_irqsave(&ace->lock, flags); | 908 | spin_lock_irqsave(&ace->lock, flags); |
908 | ace->users++; | 909 | ace->users++; |
909 | spin_unlock_irqrestore(&ace->lock, flags); | 910 | spin_unlock_irqrestore(&ace->lock, flags); |
910 | 911 | ||
911 | check_disk_change(bdev); | 912 | check_disk_change(bdev); |
912 | unlock_kernel(); | 913 | mutex_unlock(&xsysace_mutex); |
913 | 914 | ||
914 | return 0; | 915 | return 0; |
915 | } | 916 | } |
@@ -922,7 +923,7 @@ static int ace_release(struct gendisk *disk, fmode_t mode) | |||
922 | 923 | ||
923 | dev_dbg(ace->dev, "ace_release() users=%i\n", ace->users - 1); | 924 | dev_dbg(ace->dev, "ace_release() users=%i\n", ace->users - 1); |
924 | 925 | ||
925 | lock_kernel(); | 926 | mutex_lock(&xsysace_mutex); |
926 | spin_lock_irqsave(&ace->lock, flags); | 927 | spin_lock_irqsave(&ace->lock, flags); |
927 | ace->users--; | 928 | ace->users--; |
928 | if (ace->users == 0) { | 929 | if (ace->users == 0) { |
@@ -930,7 +931,7 @@ static int ace_release(struct gendisk *disk, fmode_t mode) | |||
930 | ace_out(ace, ACE_CTRL, val & ~ACE_CTRL_LOCKREQ); | 931 | ace_out(ace, ACE_CTRL, val & ~ACE_CTRL_LOCKREQ); |
931 | } | 932 | } |
932 | spin_unlock_irqrestore(&ace->lock, flags); | 933 | spin_unlock_irqrestore(&ace->lock, flags); |
933 | unlock_kernel(); | 934 | mutex_unlock(&xsysace_mutex); |
934 | return 0; | 935 | return 0; |
935 | } | 936 | } |
936 | 937 | ||
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 | ||
60 | static DEFINE_MUTEX(z2ram_mutex); | ||
60 | static u_long *z2ram_map = NULL; | 61 | static u_long *z2ram_map = NULL; |
61 | static u_long z2ram_size = 0; | 62 | static u_long z2ram_size = 0; |
62 | static int z2_count = 0; | 63 | static 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 | ||
302 | err_out_kfree: | 303 | err_out_kfree: |
303 | kfree(z2ram_map); | 304 | kfree(z2ram_map); |
304 | err_out: | 305 | err_out: |
305 | unlock_kernel(); | 306 | mutex_unlock(&z2ram_mutex); |
306 | return rc; | 307 | return rc; |
307 | } | 308 | } |
308 | 309 | ||
309 | static int | 310 | static int |
310 | z2_release(struct gendisk *disk, fmode_t mode) | 311 | z2_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 | */ |