aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mmc/card/block.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mmc/card/block.c')
-rw-r--r--drivers/mmc/card/block.c46
1 files changed, 6 insertions, 40 deletions
diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index efacee0404a0..24c97d3d16bb 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -58,7 +58,6 @@ struct mmc_blk_data {
58 struct mmc_queue queue; 58 struct mmc_queue queue;
59 59
60 unsigned int usage; 60 unsigned int usage;
61 unsigned int block_bits;
62 unsigned int read_only; 61 unsigned int read_only;
63}; 62};
64 63
@@ -216,8 +215,7 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
216 struct mmc_blk_data *md = mq->data; 215 struct mmc_blk_data *md = mq->data;
217 struct mmc_card *card = md->queue.card; 216 struct mmc_card *card = md->queue.card;
218 struct mmc_blk_request brq; 217 struct mmc_blk_request brq;
219 int ret = 1, data_size, i; 218 int ret = 1;
220 struct scatterlist *sg;
221 219
222 mmc_claim_host(card->host); 220 mmc_claim_host(card->host);
223 221
@@ -233,13 +231,11 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
233 if (!mmc_card_blockaddr(card)) 231 if (!mmc_card_blockaddr(card))
234 brq.cmd.arg <<= 9; 232 brq.cmd.arg <<= 9;
235 brq.cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_ADTC; 233 brq.cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_ADTC;
236 brq.data.blksz = 1 << md->block_bits; 234 brq.data.blksz = 512;
237 brq.stop.opcode = MMC_STOP_TRANSMISSION; 235 brq.stop.opcode = MMC_STOP_TRANSMISSION;
238 brq.stop.arg = 0; 236 brq.stop.arg = 0;
239 brq.stop.flags = MMC_RSP_SPI_R1B | MMC_RSP_R1B | MMC_CMD_AC; 237 brq.stop.flags = MMC_RSP_SPI_R1B | MMC_RSP_R1B | MMC_CMD_AC;
240 brq.data.blocks = req->nr_sectors >> (md->block_bits - 9); 238 brq.data.blocks = req->nr_sectors;
241 if (brq.data.blocks > card->host->max_blk_count)
242 brq.data.blocks = card->host->max_blk_count;
243 239
244 if (brq.data.blocks > 1) { 240 if (brq.data.blocks > 1) {
245 /* SPI multiblock writes terminate using a special 241 /* SPI multiblock writes terminate using a special
@@ -271,24 +267,6 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
271 267
272 mmc_queue_bounce_pre(mq); 268 mmc_queue_bounce_pre(mq);
273 269
274 /*
275 * Adjust the sg list so it is the same size as the
276 * request.
277 */
278 if (brq.data.blocks !=
279 (req->nr_sectors >> (md->block_bits - 9))) {
280 data_size = brq.data.blocks * brq.data.blksz;
281 for_each_sg(brq.data.sg, sg, brq.data.sg_len, i) {
282 data_size -= sg->length;
283 if (data_size <= 0) {
284 sg->length += data_size;
285 i++;
286 break;
287 }
288 }
289 brq.data.sg_len = i;
290 }
291
292 mmc_wait_for_req(card->host, &brq.mrq); 270 mmc_wait_for_req(card->host, &brq.mrq);
293 271
294 mmc_queue_bounce_post(mq); 272 mmc_queue_bounce_post(mq);
@@ -373,16 +351,11 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
373 if (rq_data_dir(req) != READ) { 351 if (rq_data_dir(req) != READ) {
374 if (mmc_card_sd(card)) { 352 if (mmc_card_sd(card)) {
375 u32 blocks; 353 u32 blocks;
376 unsigned int bytes;
377 354
378 blocks = mmc_sd_num_wr_blocks(card); 355 blocks = mmc_sd_num_wr_blocks(card);
379 if (blocks != (u32)-1) { 356 if (blocks != (u32)-1) {
380 if (card->csd.write_partial)
381 bytes = blocks << md->block_bits;
382 else
383 bytes = blocks << 9;
384 spin_lock_irq(&md->lock); 357 spin_lock_irq(&md->lock);
385 ret = __blk_end_request(req, 0, bytes); 358 ret = __blk_end_request(req, 0, blocks << 9);
386 spin_unlock_irq(&md->lock); 359 spin_unlock_irq(&md->lock);
387 } 360 }
388 } else { 361 } else {
@@ -432,13 +405,6 @@ static struct mmc_blk_data *mmc_blk_alloc(struct mmc_card *card)
432 */ 405 */
433 md->read_only = mmc_blk_readonly(card); 406 md->read_only = mmc_blk_readonly(card);
434 407
435 /*
436 * Both SD and MMC specifications state (although a bit
437 * unclearly in the MMC case) that a block size of 512
438 * bytes must always be supported by the card.
439 */
440 md->block_bits = 9;
441
442 md->disk = alloc_disk(1 << MMC_SHIFT); 408 md->disk = alloc_disk(1 << MMC_SHIFT);
443 if (md->disk == NULL) { 409 if (md->disk == NULL) {
444 ret = -ENOMEM; 410 ret = -ENOMEM;
@@ -476,7 +442,7 @@ static struct mmc_blk_data *mmc_blk_alloc(struct mmc_card *card)
476 442
477 sprintf(md->disk->disk_name, "mmcblk%d", devidx); 443 sprintf(md->disk->disk_name, "mmcblk%d", devidx);
478 444
479 blk_queue_hardsect_size(md->queue.queue, 1 << md->block_bits); 445 blk_queue_hardsect_size(md->queue.queue, 512);
480 446
481 if (!mmc_card_sd(card) && mmc_card_blockaddr(card)) { 447 if (!mmc_card_sd(card) && mmc_card_blockaddr(card)) {
482 /* 448 /*
@@ -514,7 +480,7 @@ mmc_blk_set_blksize(struct mmc_blk_data *md, struct mmc_card *card)
514 480
515 mmc_claim_host(card->host); 481 mmc_claim_host(card->host);
516 cmd.opcode = MMC_SET_BLOCKLEN; 482 cmd.opcode = MMC_SET_BLOCKLEN;
517 cmd.arg = 1 << md->block_bits; 483 cmd.arg = 512;
518 cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_AC; 484 cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_AC;
519 err = mmc_wait_for_cmd(card->host, &cmd, 5); 485 err = mmc_wait_for_cmd(card->host, &cmd, 5);
520 mmc_release_host(card->host); 486 mmc_release_host(card->host);