[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>
This commit is contained in:
parent
d5ea4e2660
commit
d2b1839425
|
@ -359,7 +359,12 @@ static struct mmc_blk_data *mmc_blk_alloc(struct mmc_card *card)
|
||||||
md->block_bits = card->csd.read_blkbits;
|
md->block_bits = card->csd.read_blkbits;
|
||||||
|
|
||||||
blk_queue_hardsect_size(md->queue.queue, 1 << md->block_bits);
|
blk_queue_hardsect_size(md->queue.queue, 1 << md->block_bits);
|
||||||
set_capacity(md->disk, card->csd.capacity);
|
|
||||||
|
/*
|
||||||
|
* The CSD capacity field is in units of read_blkbits.
|
||||||
|
* set_capacity takes units of 512 bytes.
|
||||||
|
*/
|
||||||
|
set_capacity(md->disk, card->csd.capacity << (card->csd.read_blkbits - 9));
|
||||||
}
|
}
|
||||||
out:
|
out:
|
||||||
return md;
|
return md;
|
||||||
|
@ -373,7 +378,7 @@ mmc_blk_set_blksize(struct mmc_blk_data *md, struct mmc_card *card)
|
||||||
|
|
||||||
mmc_card_claim_host(card);
|
mmc_card_claim_host(card);
|
||||||
cmd.opcode = MMC_SET_BLOCKLEN;
|
cmd.opcode = MMC_SET_BLOCKLEN;
|
||||||
cmd.arg = 1 << card->csd.read_blkbits;
|
cmd.arg = 1 << md->block_bits;
|
||||||
cmd.flags = MMC_RSP_R1;
|
cmd.flags = MMC_RSP_R1;
|
||||||
err = mmc_wait_for_cmd(card->host, &cmd, 5);
|
err = mmc_wait_for_cmd(card->host, &cmd, 5);
|
||||||
mmc_card_release_host(card);
|
mmc_card_release_host(card);
|
||||||
|
@ -412,10 +417,9 @@ static int mmc_blk_probe(struct mmc_card *card)
|
||||||
if (err)
|
if (err)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
printk(KERN_INFO "%s: %s %s %dKiB %s\n",
|
printk(KERN_INFO "%s: %s %s %luKiB %s\n",
|
||||||
md->disk->disk_name, mmc_card_id(card), mmc_card_name(card),
|
md->disk->disk_name, mmc_card_id(card), mmc_card_name(card),
|
||||||
(card->csd.capacity << card->csd.read_blkbits) / 1024,
|
get_capacity(md->disk) >> 1, mmc_blk_readonly(card)?"(ro)":"");
|
||||||
mmc_blk_readonly(card)?"(ro)":"");
|
|
||||||
|
|
||||||
mmc_set_drvdata(card, md);
|
mmc_set_drvdata(card, md);
|
||||||
add_disk(md->disk);
|
add_disk(md->disk);
|
||||||
|
|
Loading…
Reference in New Issue