diff options
Diffstat (limited to 'drivers/mtd/mtd_blkdevs.c')
-rw-r--r-- | drivers/mtd/mtd_blkdevs.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c index 178b53b56be9..b879a66daa9e 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; |
@@ -372,12 +373,10 @@ int register_mtd_blktrans(struct mtd_blktrans_ops *tr) | |||
372 | if (!blktrans_notifier.list.next) | 373 | if (!blktrans_notifier.list.next) |
373 | register_mtd_user(&blktrans_notifier); | 374 | register_mtd_user(&blktrans_notifier); |
374 | 375 | ||
375 | tr->blkcore_priv = kmalloc(sizeof(*tr->blkcore_priv), GFP_KERNEL); | 376 | tr->blkcore_priv = kzalloc(sizeof(*tr->blkcore_priv), GFP_KERNEL); |
376 | if (!tr->blkcore_priv) | 377 | if (!tr->blkcore_priv) |
377 | return -ENOMEM; | 378 | return -ENOMEM; |
378 | 379 | ||
379 | memset(tr->blkcore_priv, 0, sizeof(*tr->blkcore_priv)); | ||
380 | |||
381 | mutex_lock(&mtd_table_mutex); | 380 | mutex_lock(&mtd_table_mutex); |
382 | 381 | ||
383 | ret = register_blkdev(tr->major, tr->name); | 382 | ret = register_blkdev(tr->major, tr->name); |
@@ -401,6 +400,8 @@ int register_mtd_blktrans(struct mtd_blktrans_ops *tr) | |||
401 | } | 400 | } |
402 | 401 | ||
403 | tr->blkcore_priv->rq->queuedata = tr; | 402 | tr->blkcore_priv->rq->queuedata = tr; |
403 | blk_queue_hardsect_size(tr->blkcore_priv->rq, tr->blksize); | ||
404 | tr->blkshift = ffs(tr->blksize) - 1; | ||
404 | 405 | ||
405 | ret = kernel_thread(mtd_blktrans_thread, tr, CLONE_KERNEL); | 406 | ret = kernel_thread(mtd_blktrans_thread, tr, CLONE_KERNEL); |
406 | if (ret < 0) { | 407 | if (ret < 0) { |