Commit 504f191f authored by Adrian Hunter's avatar Adrian Hunter Committed by Pierre Ossman

mmc_block: print better error messages

Add command response and card status to error
messages.
Signed-off-by: default avatarAdrian Hunter <ext-adrian.hunter@nokia.com>
Signed-off-by: default avatarPierre Ossman <drzeus@drzeus.cx>
parent 86e8286a
...@@ -207,6 +207,23 @@ static u32 mmc_sd_num_wr_blocks(struct mmc_card *card) ...@@ -207,6 +207,23 @@ static u32 mmc_sd_num_wr_blocks(struct mmc_card *card)
return ntohl(blocks); return ntohl(blocks);
} }
static u32 get_card_status(struct mmc_card *card, struct request *req)
{
struct mmc_command cmd;
int err;
memset(&cmd, 0, sizeof(struct mmc_command));
cmd.opcode = MMC_SEND_STATUS;
if (!mmc_host_is_spi(card->host))
cmd.arg = card->rca << 16;
cmd.flags = MMC_RSP_SPI_R2 | MMC_RSP_R1 | MMC_CMD_AC;
err = mmc_wait_for_cmd(card->host, &cmd, 0);
if (err)
printk(KERN_ERR "%s: error %d sending status comand",
req->rq_disk->disk_name, err);
return cmd.resp[0];
}
static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
{ {
struct mmc_blk_data *md = mq->data; struct mmc_blk_data *md = mq->data;
...@@ -218,7 +235,7 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) ...@@ -218,7 +235,7 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
do { do {
struct mmc_command cmd; struct mmc_command cmd;
u32 readcmd, writecmd; u32 readcmd, writecmd, status = 0;
memset(&brq, 0, sizeof(struct mmc_blk_request)); memset(&brq, 0, sizeof(struct mmc_blk_request));
brq.mrq.cmd = &brq.cmd; brq.mrq.cmd = &brq.cmd;
...@@ -273,19 +290,32 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) ...@@ -273,19 +290,32 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
* until later as we need to wait for the card to leave * until later as we need to wait for the card to leave
* programming mode even when things go wrong. * programming mode even when things go wrong.
*/ */
if (brq.cmd.error || brq.data.error || brq.stop.error)
status = get_card_status(card, req);
if (brq.cmd.error) { if (brq.cmd.error) {
printk(KERN_ERR "%s: error %d sending read/write command\n", printk(KERN_ERR "%s: error %d sending read/write "
req->rq_disk->disk_name, brq.cmd.error); "command, response %#x, card status %#x\n",
req->rq_disk->disk_name, brq.cmd.error,
brq.cmd.resp[0], status);
} }
if (brq.data.error) { if (brq.data.error) {
printk(KERN_ERR "%s: error %d transferring data\n", if (brq.data.error == -ETIMEDOUT && brq.mrq.stop)
req->rq_disk->disk_name, brq.data.error); /* 'Stop' response contains card status */
status = brq.mrq.stop->resp[0];
printk(KERN_ERR "%s: error %d transferring data,"
" sector %u, nr %u, card status %#x\n",
req->rq_disk->disk_name, brq.data.error,
(unsigned)req->sector,
(unsigned)req->nr_sectors, status);
} }
if (brq.stop.error) { if (brq.stop.error) {
printk(KERN_ERR "%s: error %d sending stop command\n", printk(KERN_ERR "%s: error %d sending stop command, "
req->rq_disk->disk_name, brq.stop.error); "response %#x, card status %#x\n",
req->rq_disk->disk_name, brq.stop.error,
brq.stop.resp[0], status);
} }
if (!mmc_host_is_spi(card->host) && rq_data_dir(req) != READ) { if (!mmc_host_is_spi(card->host) && rq_data_dir(req) != READ) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment