提交 08846698 编写于 作者: P Pierre Ossman

mmc_block: hard code 512 byte block size

We use 512 byte blocks on all cards, and newer cards support nothing
else, so hard code it and make the code less complex.
Signed-off-by: NPierre Ossman <drzeus@drzeus.cx>
上级 a4b76193
...@@ -57,7 +57,6 @@ struct mmc_blk_data { ...@@ -57,7 +57,6 @@ struct mmc_blk_data {
struct mmc_queue queue; struct mmc_queue queue;
unsigned int usage; unsigned int usage;
unsigned int block_bits;
unsigned int read_only; unsigned int read_only;
}; };
...@@ -231,11 +230,11 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) ...@@ -231,11 +230,11 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
if (!mmc_card_blockaddr(card)) if (!mmc_card_blockaddr(card))
brq.cmd.arg <<= 9; brq.cmd.arg <<= 9;
brq.cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_ADTC; brq.cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_ADTC;
brq.data.blksz = 1 << md->block_bits; brq.data.blksz = 512;
brq.stop.opcode = MMC_STOP_TRANSMISSION; brq.stop.opcode = MMC_STOP_TRANSMISSION;
brq.stop.arg = 0; brq.stop.arg = 0;
brq.stop.flags = MMC_RSP_SPI_R1B | MMC_RSP_R1B | MMC_CMD_AC; brq.stop.flags = MMC_RSP_SPI_R1B | MMC_RSP_R1B | MMC_CMD_AC;
brq.data.blocks = req->nr_sectors >> (md->block_bits - 9); brq.data.blocks = req->nr_sectors;
if (brq.data.blocks > 1) { if (brq.data.blocks > 1) {
/* SPI multiblock writes terminate using a special /* SPI multiblock writes terminate using a special
...@@ -351,16 +350,11 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) ...@@ -351,16 +350,11 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
if (rq_data_dir(req) != READ) { if (rq_data_dir(req) != READ) {
if (mmc_card_sd(card)) { if (mmc_card_sd(card)) {
u32 blocks; u32 blocks;
unsigned int bytes;
blocks = mmc_sd_num_wr_blocks(card); blocks = mmc_sd_num_wr_blocks(card);
if (blocks != (u32)-1) { if (blocks != (u32)-1) {
if (card->csd.write_partial)
bytes = blocks << md->block_bits;
else
bytes = blocks << 9;
spin_lock_irq(&md->lock); spin_lock_irq(&md->lock);
ret = __blk_end_request(req, 0, bytes); ret = __blk_end_request(req, 0, blocks << 9);
spin_unlock_irq(&md->lock); spin_unlock_irq(&md->lock);
} }
} else { } else {
...@@ -410,13 +404,6 @@ static struct mmc_blk_data *mmc_blk_alloc(struct mmc_card *card) ...@@ -410,13 +404,6 @@ static struct mmc_blk_data *mmc_blk_alloc(struct mmc_card *card)
*/ */
md->read_only = mmc_blk_readonly(card); md->read_only = mmc_blk_readonly(card);
/*
* Both SD and MMC specifications state (although a bit
* unclearly in the MMC case) that a block size of 512
* bytes must always be supported by the card.
*/
md->block_bits = 9;
md->disk = alloc_disk(1 << MMC_SHIFT); md->disk = alloc_disk(1 << MMC_SHIFT);
if (md->disk == NULL) { if (md->disk == NULL) {
ret = -ENOMEM; ret = -ENOMEM;
...@@ -454,7 +441,7 @@ static struct mmc_blk_data *mmc_blk_alloc(struct mmc_card *card) ...@@ -454,7 +441,7 @@ static struct mmc_blk_data *mmc_blk_alloc(struct mmc_card *card)
sprintf(md->disk->disk_name, "mmcblk%d", devidx); sprintf(md->disk->disk_name, "mmcblk%d", devidx);
blk_queue_hardsect_size(md->queue.queue, 1 << md->block_bits); blk_queue_hardsect_size(md->queue.queue, 512);
if (!mmc_card_sd(card) && mmc_card_blockaddr(card)) { if (!mmc_card_sd(card) && mmc_card_blockaddr(card)) {
/* /*
...@@ -492,7 +479,7 @@ mmc_blk_set_blksize(struct mmc_blk_data *md, struct mmc_card *card) ...@@ -492,7 +479,7 @@ mmc_blk_set_blksize(struct mmc_blk_data *md, struct mmc_card *card)
mmc_claim_host(card->host); mmc_claim_host(card->host);
cmd.opcode = MMC_SET_BLOCKLEN; cmd.opcode = MMC_SET_BLOCKLEN;
cmd.arg = 1 << md->block_bits; cmd.arg = 512;
cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_AC; cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_AC;
err = mmc_wait_for_cmd(card->host, &cmd, 5); err = mmc_wait_for_cmd(card->host, &cmd, 5);
mmc_release_host(card->host); mmc_release_host(card->host);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册