aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRussell King <rmk@dyn-67.arm.linux.org.uk>2005-12-22 18:21:38 -0500
committerRussell King <rmk+kernel@arm.linux.org.uk>2005-12-22 18:21:38 -0500
commitd2b18394259ef621fd2a6322aa9934198fd87a6a (patch)
treecedd99314fd5408559d410c5fc51c1af2a62f6ed
parentd5ea4e26602fa7f5141872f2c17a862f1974a73f (diff)
[MMC] Set correct capacity for 1024-byte block cards
We were passing set_capacity() the capacity we calculated in terms of the number of blocks on the card, which happened to be the right units for 512-byte block cards. However, with 1024-byte block cards, we end up setting the capacity to half the number of blocks. Fix this by shifting by the appropriate amount. Thanks to Todd Blumer for pointing this out. Use get_capacity() to report the card capacity, rather than recalculating it from the CSD information. Finally, use our chosen IO block size for the SET_BLOCKLEN command rather than the CSD read block size. Currently these are equivalent, but will not be in the future. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
-rw-r--r--drivers/mmc/mmc_block.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/drivers/mmc/mmc_block.c b/drivers/mmc/mmc_block.c
index d91fcf7c3178..abcf19116d70 100644
--- a/drivers/mmc/mmc_block.c
+++ b/drivers/mmc/mmc_block.c
@@ -359,7 +359,12 @@ static struct mmc_blk_data *mmc_blk_alloc(struct mmc_card *card)
359 md->block_bits = card->csd.read_blkbits; 359 md->block_bits = card->csd.read_blkbits;
360 360
361 blk_queue_hardsect_size(md->queue.queue, 1 << md->block_bits); 361 blk_queue_hardsect_size(md->queue.queue, 1 << md->block_bits);
362 set_capacity(md->disk, card->csd.capacity); 362
363 /*
364 * The CSD capacity field is in units of read_blkbits.
365 * set_capacity takes units of 512 bytes.
366 */
367 set_capacity(md->disk, card->csd.capacity << (card->csd.read_blkbits - 9));
363 } 368 }
364 out: 369 out:
365 return md; 370 return md;
@@ -373,7 +378,7 @@ mmc_blk_set_blksize(struct mmc_blk_data *md, struct mmc_card *card)
373 378
374 mmc_card_claim_host(card); 379 mmc_card_claim_host(card);
375 cmd.opcode = MMC_SET_BLOCKLEN; 380 cmd.opcode = MMC_SET_BLOCKLEN;
376 cmd.arg = 1 << card->csd.read_blkbits; 381 cmd.arg = 1 << md->block_bits;
377 cmd.flags = MMC_RSP_R1; 382 cmd.flags = MMC_RSP_R1;
378 err = mmc_wait_for_cmd(card->host, &cmd, 5); 383 err = mmc_wait_for_cmd(card->host, &cmd, 5);
379 mmc_card_release_host(card); 384 mmc_card_release_host(card);
@@ -412,10 +417,9 @@ static int mmc_blk_probe(struct mmc_card *card)
412 if (err) 417 if (err)
413 goto out; 418 goto out;
414 419
415 printk(KERN_INFO "%s: %s %s %dKiB %s\n", 420 printk(KERN_INFO "%s: %s %s %luKiB %s\n",
416 md->disk->disk_name, mmc_card_id(card), mmc_card_name(card), 421 md->disk->disk_name, mmc_card_id(card), mmc_card_name(card),
417 (card->csd.capacity << card->csd.read_blkbits) / 1024, 422 get_capacity(md->disk) >> 1, mmc_blk_readonly(card)?"(ro)":"");
418 mmc_blk_readonly(card)?"(ro)":"");
419 423
420 mmc_set_drvdata(card, md); 424 mmc_set_drvdata(card, md);
421 add_disk(md->disk); 425 add_disk(md->disk);