Skip to content

Commit

Permalink
mmc_block: hard code 512 byte block size
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Pierre Ossman committed Oct 12, 2008
1 parent a4b7619 commit 0884669
Showing 1 changed file with 5 additions and 18 deletions.
23 changes: 5 additions & 18 deletions drivers/mmc/card/block.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ struct mmc_blk_data {
struct mmc_queue queue;

unsigned int usage;
unsigned int block_bits;
unsigned int read_only;
};

Expand Down Expand Up @@ -231,11 +230,11 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
if (!mmc_card_blockaddr(card))
brq.cmd.arg <<= 9;
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.arg = 0;
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) {
/* SPI multiblock writes terminate using a special
Expand Down Expand Up @@ -351,16 +350,11 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
if (rq_data_dir(req) != READ) {
if (mmc_card_sd(card)) {
u32 blocks;
unsigned int bytes;

blocks = mmc_sd_num_wr_blocks(card);
if (blocks != (u32)-1) {
if (card->csd.write_partial)
bytes = blocks << md->block_bits;
else
bytes = blocks << 9;
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);
}
} else {
Expand Down Expand Up @@ -410,13 +404,6 @@ static struct mmc_blk_data *mmc_blk_alloc(struct mmc_card *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);
if (md->disk == NULL) {
ret = -ENOMEM;
Expand Down Expand Up @@ -454,7 +441,7 @@ static struct mmc_blk_data *mmc_blk_alloc(struct mmc_card *card)

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)) {
/*
Expand Down Expand Up @@ -492,7 +479,7 @@ mmc_blk_set_blksize(struct mmc_blk_data *md, struct mmc_card *card)

mmc_claim_host(card->host);
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;
err = mmc_wait_for_cmd(card->host, &cmd, 5);
mmc_release_host(card->host);
Expand Down

0 comments on commit 0884669

Please sign in to comment.