diff options
author | Pierre Ossman <drzeus@drzeus.cx> | 2008-08-31 08:10:08 -0400 |
---|---|---|
committer | Pierre Ossman <drzeus@drzeus.cx> | 2008-10-12 05:04:33 -0400 |
commit | 08846698703dedae6c6915eb4b4d0a36188c5635 (patch) | |
tree | a5a12b778636738701e15671375c73eb1579583d /drivers/mmc/card/block.c | |
parent | a4b76193774b463b922cab2f92450efb20d29ef0 (diff) |
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: Pierre Ossman <drzeus@drzeus.cx>
Diffstat (limited to 'drivers/mmc/card/block.c')
-rw-r--r-- | drivers/mmc/card/block.c | 23 |
1 files changed, 5 insertions, 18 deletions
diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c index d73cac84d9f2..1d1e469e08ea 100644 --- a/drivers/mmc/card/block.c +++ b/drivers/mmc/card/block.c | |||
@@ -57,7 +57,6 @@ struct mmc_blk_data { | |||
57 | struct mmc_queue queue; | 57 | struct mmc_queue queue; |
58 | 58 | ||
59 | unsigned int usage; | 59 | unsigned int usage; |
60 | unsigned int block_bits; | ||
61 | unsigned int read_only; | 60 | unsigned int read_only; |
62 | }; | 61 | }; |
63 | 62 | ||
@@ -231,11 +230,11 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) | |||
231 | if (!mmc_card_blockaddr(card)) | 230 | if (!mmc_card_blockaddr(card)) |
232 | brq.cmd.arg <<= 9; | 231 | brq.cmd.arg <<= 9; |
233 | brq.cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_ADTC; | 232 | brq.cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_ADTC; |
234 | brq.data.blksz = 1 << md->block_bits; | 233 | brq.data.blksz = 512; |
235 | brq.stop.opcode = MMC_STOP_TRANSMISSION; | 234 | brq.stop.opcode = MMC_STOP_TRANSMISSION; |
236 | brq.stop.arg = 0; | 235 | brq.stop.arg = 0; |
237 | brq.stop.flags = MMC_RSP_SPI_R1B | MMC_RSP_R1B | MMC_CMD_AC; | 236 | brq.stop.flags = MMC_RSP_SPI_R1B | MMC_RSP_R1B | MMC_CMD_AC; |
238 | brq.data.blocks = req->nr_sectors >> (md->block_bits - 9); | 237 | brq.data.blocks = req->nr_sectors; |
239 | 238 | ||
240 | if (brq.data.blocks > 1) { | 239 | if (brq.data.blocks > 1) { |
241 | /* SPI multiblock writes terminate using a special | 240 | /* 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 | if (rq_data_dir(req) != READ) { | 350 | if (rq_data_dir(req) != READ) { |
352 | if (mmc_card_sd(card)) { | 351 | if (mmc_card_sd(card)) { |
353 | u32 blocks; | 352 | u32 blocks; |
354 | unsigned int bytes; | ||
355 | 353 | ||
356 | blocks = mmc_sd_num_wr_blocks(card); | 354 | blocks = mmc_sd_num_wr_blocks(card); |
357 | if (blocks != (u32)-1) { | 355 | if (blocks != (u32)-1) { |
358 | if (card->csd.write_partial) | ||
359 | bytes = blocks << md->block_bits; | ||
360 | else | ||
361 | bytes = blocks << 9; | ||
362 | spin_lock_irq(&md->lock); | 356 | spin_lock_irq(&md->lock); |
363 | ret = __blk_end_request(req, 0, bytes); | 357 | ret = __blk_end_request(req, 0, blocks << 9); |
364 | spin_unlock_irq(&md->lock); | 358 | spin_unlock_irq(&md->lock); |
365 | } | 359 | } |
366 | } else { | 360 | } else { |
@@ -410,13 +404,6 @@ static struct mmc_blk_data *mmc_blk_alloc(struct mmc_card *card) | |||
410 | */ | 404 | */ |
411 | md->read_only = mmc_blk_readonly(card); | 405 | md->read_only = mmc_blk_readonly(card); |
412 | 406 | ||
413 | /* | ||
414 | * Both SD and MMC specifications state (although a bit | ||
415 | * unclearly in the MMC case) that a block size of 512 | ||
416 | * bytes must always be supported by the card. | ||
417 | */ | ||
418 | md->block_bits = 9; | ||
419 | |||
420 | md->disk = alloc_disk(1 << MMC_SHIFT); | 407 | md->disk = alloc_disk(1 << MMC_SHIFT); |
421 | if (md->disk == NULL) { | 408 | if (md->disk == NULL) { |
422 | ret = -ENOMEM; | 409 | ret = -ENOMEM; |
@@ -454,7 +441,7 @@ static struct mmc_blk_data *mmc_blk_alloc(struct mmc_card *card) | |||
454 | 441 | ||
455 | sprintf(md->disk->disk_name, "mmcblk%d", devidx); | 442 | sprintf(md->disk->disk_name, "mmcblk%d", devidx); |
456 | 443 | ||
457 | blk_queue_hardsect_size(md->queue.queue, 1 << md->block_bits); | 444 | blk_queue_hardsect_size(md->queue.queue, 512); |
458 | 445 | ||
459 | if (!mmc_card_sd(card) && mmc_card_blockaddr(card)) { | 446 | if (!mmc_card_sd(card) && mmc_card_blockaddr(card)) { |
460 | /* | 447 | /* |
@@ -492,7 +479,7 @@ mmc_blk_set_blksize(struct mmc_blk_data *md, struct mmc_card *card) | |||
492 | 479 | ||
493 | mmc_claim_host(card->host); | 480 | mmc_claim_host(card->host); |
494 | cmd.opcode = MMC_SET_BLOCKLEN; | 481 | cmd.opcode = MMC_SET_BLOCKLEN; |
495 | cmd.arg = 1 << md->block_bits; | 482 | cmd.arg = 512; |
496 | cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_AC; | 483 | cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_AC; |
497 | err = mmc_wait_for_cmd(card->host, &cmd, 5); | 484 | err = mmc_wait_for_cmd(card->host, &cmd, 5); |
498 | mmc_release_host(card->host); | 485 | mmc_release_host(card->host); |