aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/mtd_blkdevs.c
diff options
context:
space:
mode:
authorRichard Purdie <rpurdie@openedhand.com>2006-10-27 04:09:33 -0400
committerDavid Woodhouse <dwmw2@infradead.org>2006-11-28 17:27:47 -0500
commit191876729901d0c8dab8a331f9a1e4b73a56457b (patch)
tree1e25eb24ac84c09b0300e32eea55b33adc567015 /drivers/mtd/mtd_blkdevs.c
parent90afffc8bd79d130b58acd18f972ce4e00b8e20f (diff)
[MTD] Allow variable block sizes in mtd_blkdevs
Currently, mtd_blkdevs enforces a block size of 512, even if the drivers can seemingly request a different size. This patch fixes mtd_blkdevs so block sizes other than 512 work correctly. Signed-off-by: Richard Purdie <rpurdie@openedhand.com> Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Diffstat (limited to 'drivers/mtd/mtd_blkdevs.c')
-rw-r--r--drivers/mtd/mtd_blkdevs.c15
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) {