diff options
Diffstat (limited to 'drivers/mtd/mtd_blkdevs.c')
-rw-r--r-- | drivers/mtd/mtd_blkdevs.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c index 1d2144d77470..62e68707b07f 100644 --- a/drivers/mtd/mtd_blkdevs.c +++ b/drivers/mtd/mtd_blkdevs.c | |||
@@ -29,6 +29,7 @@ | |||
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> | ||
32 | #include <linux/hdreg.h> | 33 | #include <linux/hdreg.h> |
33 | #include <linux/init.h> | 34 | #include <linux/init.h> |
34 | #include <linux/mutex.h> | 35 | #include <linux/mutex.h> |
@@ -87,14 +88,14 @@ static int do_blktrans_request(struct mtd_blktrans_ops *tr, | |||
87 | 88 | ||
88 | buf = req->buffer; | 89 | buf = req->buffer; |
89 | 90 | ||
90 | if (!blk_fs_request(req)) | 91 | if (req->cmd_type != REQ_TYPE_FS) |
91 | return -EIO; | 92 | return -EIO; |
92 | 93 | ||
93 | if (blk_rq_pos(req) + blk_rq_cur_sectors(req) > | 94 | if (blk_rq_pos(req) + blk_rq_cur_sectors(req) > |
94 | get_capacity(req->rq_disk)) | 95 | get_capacity(req->rq_disk)) |
95 | return -EIO; | 96 | return -EIO; |
96 | 97 | ||
97 | if (blk_discard_rq(req)) | 98 | if (req->cmd_flags & REQ_DISCARD) |
98 | return tr->discard(dev, block, nsect); | 99 | return tr->discard(dev, block, nsect); |
99 | 100 | ||
100 | switch(rq_data_dir(req)) { | 101 | switch(rq_data_dir(req)) { |
@@ -178,8 +179,9 @@ static int blktrans_open(struct block_device *bdev, fmode_t mode) | |||
178 | int ret; | 179 | int ret; |
179 | 180 | ||
180 | if (!dev) | 181 | if (!dev) |
181 | return -ERESTARTSYS; | 182 | return -ERESTARTSYS; /* FIXME: busy loop! -arnd*/ |
182 | 183 | ||
184 | lock_kernel(); | ||
183 | mutex_lock(&dev->lock); | 185 | mutex_lock(&dev->lock); |
184 | 186 | ||
185 | if (!dev->mtd) { | 187 | if (!dev->mtd) { |
@@ -196,6 +198,7 @@ static int blktrans_open(struct block_device *bdev, fmode_t mode) | |||
196 | unlock: | 198 | unlock: |
197 | mutex_unlock(&dev->lock); | 199 | mutex_unlock(&dev->lock); |
198 | blktrans_dev_put(dev); | 200 | blktrans_dev_put(dev); |
201 | unlock_kernel(); | ||
199 | return ret; | 202 | return ret; |
200 | } | 203 | } |
201 | 204 | ||
@@ -207,6 +210,7 @@ static int blktrans_release(struct gendisk *disk, fmode_t mode) | |||
207 | if (!dev) | 210 | if (!dev) |
208 | return ret; | 211 | return ret; |
209 | 212 | ||
213 | lock_kernel(); | ||
210 | mutex_lock(&dev->lock); | 214 | mutex_lock(&dev->lock); |
211 | 215 | ||
212 | /* Release one reference, we sure its not the last one here*/ | 216 | /* Release one reference, we sure its not the last one here*/ |
@@ -219,6 +223,7 @@ static int blktrans_release(struct gendisk *disk, fmode_t mode) | |||
219 | unlock: | 223 | unlock: |
220 | mutex_unlock(&dev->lock); | 224 | mutex_unlock(&dev->lock); |
221 | blktrans_dev_put(dev); | 225 | blktrans_dev_put(dev); |
226 | unlock_kernel(); | ||
222 | return ret; | 227 | return ret; |
223 | } | 228 | } |
224 | 229 | ||
@@ -251,6 +256,7 @@ static int blktrans_ioctl(struct block_device *bdev, fmode_t mode, | |||
251 | if (!dev) | 256 | if (!dev) |
252 | return ret; | 257 | return ret; |
253 | 258 | ||
259 | lock_kernel(); | ||
254 | mutex_lock(&dev->lock); | 260 | mutex_lock(&dev->lock); |
255 | 261 | ||
256 | if (!dev->mtd) | 262 | if (!dev->mtd) |
@@ -265,6 +271,7 @@ static int blktrans_ioctl(struct block_device *bdev, fmode_t mode, | |||
265 | } | 271 | } |
266 | unlock: | 272 | unlock: |
267 | mutex_unlock(&dev->lock); | 273 | mutex_unlock(&dev->lock); |
274 | unlock_kernel(); | ||
268 | blktrans_dev_put(dev); | 275 | blktrans_dev_put(dev); |
269 | return ret; | 276 | return ret; |
270 | } | 277 | } |
@@ -273,7 +280,7 @@ static const struct block_device_operations mtd_blktrans_ops = { | |||
273 | .owner = THIS_MODULE, | 280 | .owner = THIS_MODULE, |
274 | .open = blktrans_open, | 281 | .open = blktrans_open, |
275 | .release = blktrans_release, | 282 | .release = blktrans_release, |
276 | .locked_ioctl = blktrans_ioctl, | 283 | .ioctl = blktrans_ioctl, |
277 | .getgeo = blktrans_getgeo, | 284 | .getgeo = blktrans_getgeo, |
278 | }; | 285 | }; |
279 | 286 | ||