aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mmc/card
diff options
context:
space:
mode:
authorRussell King - ARM Linux <linux@arm.linux.org.uk>2011-06-20 15:10:49 -0400
committerChris Ball <cjb@laptop.org>2011-07-20 17:20:55 -0400
commit4c2b8f26eb8b54203e0e7834e0f7a11a7ae15ef1 (patch)
treeedc0e825137eb395f372194ed451741d4f0e82eb /drivers/mmc/card
parenta01f3ccf845067de32189f8a8e85d22c381f93b9 (diff)
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. 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.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index ff347319ff80..bee21063748b 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -812,6 +812,14 @@ static inline void mmc_apply_rel_rw(struct mmc_blk_request *brq,
812 } 812 }
813} 813}
814 814
815#define CMD_ERRORS \
816 (R1_OUT_OF_RANGE | /* Command argument out of range */ \
817 R1_ADDRESS_ERROR | /* Misaligned address */ \
818 R1_BLOCK_LEN_ERROR | /* Transferred block length incorrect */\
819 R1_WP_VIOLATION | /* Tried to write to protected block */ \
820 R1_CC_ERROR | /* Card controller error */ \
821 R1_ERROR) /* General/unknown error */
822
815static int mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *req) 823static int mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *req)
816{ 824{
817 struct mmc_blk_data *md = mq->data; 825 struct mmc_blk_data *md = mq->data;
@@ -967,6 +975,22 @@ static int mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *req)
967 } 975 }
968 } 976 }
969 977
978 /*
979 * Check for errors relating to the execution of the
980 * initial command - such as address errors. No data
981 * has been transferred.
982 */
983 if (brq.cmd.resp[0] & CMD_ERRORS) {
984 pr_err("%s: r/w command failed, status = %#x\n",
985 req->rq_disk->disk_name, brq.cmd.resp[0]);
986 goto cmd_abort;
987 }
988
989 /*
990 * Everything else is either success, or a data error of some
991 * kind. If it was a write, we may have transitioned to
992 * program mode, which we have to wait for it to complete.
993 */
970 if (!mmc_host_is_spi(card->host) && rq_data_dir(req) != READ) { 994 if (!mmc_host_is_spi(card->host) && rq_data_dir(req) != READ) {
971 u32 status; 995 u32 status;
972 do { 996 do {
@@ -986,7 +1010,7 @@ static int mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *req)
986 } 1010 }
987 1011
988 if (brq.data.error) { 1012 if (brq.data.error) {
989 pr_err("%s: error %d transferring data, sector %u nr %u, cmd response %#x card status %#x\n", 1013 pr_err("%s: error %d transferring data, sector %u, nr %u, cmd response %#x, card status %#x\n",
990 req->rq_disk->disk_name, brq.data.error, 1014 req->rq_disk->disk_name, brq.data.error,
991 (unsigned)blk_rq_pos(req), 1015 (unsigned)blk_rq_pos(req),
992 (unsigned)blk_rq_sectors(req), 1016 (unsigned)blk_rq_sectors(req),