diff options
author | Russell King - ARM Linux <linux@arm.linux.org.uk> | 2011-06-20 20:10:49 +0100 |
---|---|---|
committer | Ken Sumrall <ksumrall@android.com> | 2011-10-26 17:15:27 -0700 |
commit | 2080390ad2f1a8c076a2405cb4a30060c77e6baf (patch) | |
tree | 7fca6e23379b183aa92e62d313f21d7e85466ad9 /drivers/mmc/card | |
parent | 91d56b5cb51ceeb06c88e7557f7181827d721d0d (diff) | |
download | kernel_samsung_crespo-2080390ad2f1a8c076a2405cb4a30060c77e6baf.zip kernel_samsung_crespo-2080390ad2f1a8c076a2405cb4a30060c77e6baf.tar.gz kernel_samsung_crespo-2080390ad2f1a8c076a2405cb4a30060c77e6baf.tar.bz2 |
mmc: block: add checking of r/w command response
Check the status bits in the r/w command response for any errors.
If error bits are set, then we won't have seen any data transferred,
so it's pointless doing any further checking.
Change-Id: If118a4bcbb0e57a7d95b5e40d662fca87fdcba7f
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Tested-by: Pawel Moll <pawel.moll@arm.com>
Signed-off-by: Chris Ball <cjb@laptop.org>
Diffstat (limited to 'drivers/mmc/card')
-rw-r--r-- | drivers/mmc/card/block.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c index 2eca7da..26c28bf 100644 --- a/drivers/mmc/card/block.c +++ b/drivers/mmc/card/block.c @@ -808,6 +808,14 @@ static inline void mmc_apply_rel_rw(struct mmc_blk_request *brq, } } +#define CMD_ERRORS \ + (R1_OUT_OF_RANGE | /* Command argument out of range */ \ + R1_ADDRESS_ERROR | /* Misaligned address */ \ + R1_BLOCK_LEN_ERROR | /* Transferred block length incorrect */\ + R1_WP_VIOLATION | /* Tried to write to protected block */ \ + R1_CC_ERROR | /* Card controller error */ \ + R1_ERROR) /* General/unknown error */ + static int mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *req) { struct mmc_blk_data *md = mq->data; @@ -963,6 +971,22 @@ static int mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *req) } } + /* + * Check for errors relating to the execution of the + * initial command - such as address errors. No data + * has been transferred. + */ + if (brq.cmd.resp[0] & CMD_ERRORS) { + pr_err("%s: r/w command failed, status = %#x\n", + req->rq_disk->disk_name, brq.cmd.resp[0]); + goto cmd_abort; + } + + /* + * Everything else is either success, or a data error of some + * kind. If it was a write, we may have transitioned to + * program mode, which we have to wait for it to complete. + */ if (!mmc_host_is_spi(card->host) && rq_data_dir(req) != READ) { u32 status; do { @@ -982,7 +1006,7 @@ static int mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *req) } if (brq.data.error) { - pr_err("%s: error %d transferring data, sector %u nr %u, cmd response %#x card status %#x\n", + pr_err("%s: error %d transferring data, sector %u, nr %u, cmd response %#x, card status %#x\n", req->rq_disk->disk_name, brq.data.error, (unsigned)blk_rq_pos(req), (unsigned)blk_rq_sectors(req), |