diff options
Diffstat (limited to 'drivers/mtd/mtd_blkdevs.c')
-rw-r--r-- | drivers/mtd/mtd_blkdevs.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c index 178b53b56be9..b5d62cb357da 100644 --- a/drivers/mtd/mtd_blkdevs.c +++ b/drivers/mtd/mtd_blkdevs.c | |||
@@ -42,19 +42,20 @@ static int do_blktrans_request(struct mtd_blktrans_ops *tr, | |||
42 | unsigned long block, nsect; | 42 | unsigned long block, nsect; |
43 | char *buf; | 43 | char *buf; |
44 | 44 | ||
45 | block = req->sector; | 45 | block = req->sector << 9 >> tr->blkshift; |
46 | nsect = req->current_nr_sectors; | 46 | nsect = req->current_nr_sectors << 9 >> tr->blkshift; |
47 | |||
47 | buf = req->buffer; | 48 | buf = req->buffer; |
48 | 49 | ||
49 | if (!blk_fs_request(req)) | 50 | if (!blk_fs_request(req)) |
50 | return 0; | 51 | return 0; |
51 | 52 | ||
52 | if (block + nsect > get_capacity(req->rq_disk)) | 53 | if (req->sector + req->current_nr_sectors > get_capacity(req->rq_disk)) |
53 | return 0; | 54 | return 0; |
54 | 55 | ||
55 | switch(rq_data_dir(req)) { | 56 | switch(rq_data_dir(req)) { |
56 | case READ: | 57 | case READ: |
57 | for (; nsect > 0; nsect--, block++, buf += 512) | 58 | for (; nsect > 0; nsect--, block++, buf += tr->blksize) |
58 | if (tr->readsect(dev, block, buf)) | 59 | if (tr->readsect(dev, block, buf)) |
59 | return 0; | 60 | return 0; |
60 | return 1; | 61 | return 1; |
@@ -63,7 +64,7 @@ static int do_blktrans_request(struct mtd_blktrans_ops *tr, | |||
63 | if (!tr->writesect) | 64 | if (!tr->writesect) |
64 | return 0; | 65 | return 0; |
65 | 66 | ||
66 | for (; nsect > 0; nsect--, block++, buf += 512) | 67 | for (; nsect > 0; nsect--, block++, buf += tr->blksize) |
67 | if (tr->writesect(dev, block, buf)) | 68 | if (tr->writesect(dev, block, buf)) |
68 | return 0; | 69 | return 0; |
69 | return 1; | 70 | return 1; |
@@ -297,7 +298,7 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new) | |||
297 | 298 | ||
298 | /* 2.5 has capacity in units of 512 bytes while still | 299 | /* 2.5 has capacity in units of 512 bytes while still |
299 | having BLOCK_SIZE_BITS set to 10. Just to keep us amused. */ | 300 | having BLOCK_SIZE_BITS set to 10. Just to keep us amused. */ |
300 | set_capacity(gd, (new->size * new->blksize) >> 9); | 301 | set_capacity(gd, (new->size * tr->blksize) >> 9); |
301 | 302 | ||
302 | gd->private_data = new; | 303 | gd->private_data = new; |
303 | new->blkcore_priv = gd; | 304 | new->blkcore_priv = gd; |
@@ -401,6 +402,8 @@ int register_mtd_blktrans(struct mtd_blktrans_ops *tr) | |||
401 | } | 402 | } |
402 | 403 | ||
403 | tr->blkcore_priv->rq->queuedata = tr; | 404 | tr->blkcore_priv->rq->queuedata = tr; |
405 | blk_queue_hardsect_size(tr->blkcore_priv->rq, tr->blksize); | ||
406 | tr->blkshift = ffs(tr->blksize) - 1; | ||
404 | 407 | ||
405 | ret = kernel_thread(mtd_blktrans_thread, tr, CLONE_KERNEL); | 408 | ret = kernel_thread(mtd_blktrans_thread, tr, CLONE_KERNEL); |
406 | if (ret < 0) { | 409 | if (ret < 0) { |