Commit b2928e10 authored by Linus Walleij's avatar Linus Walleij Committed by Ulf Hansson

mmc: block: refactor mmc_blk_rw_try_restart()

The mmc_blk_rw_start_new() was named after the label inside
mmc_blk_issue_rw_rq() but is really a confusing name for this
function: what it does is to try to restart the latest issued
command on the host and card of the current MMC queue.

So rename it mmc_blk_rw_try_restart() that reflects what it
is doing and at this point also refactore the function to
treat the removed card as an exception and just exit if this
happens and run on in the function if that is not happening.
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
parent c3399ef5
...@@ -1598,20 +1598,27 @@ static void mmc_blk_rw_cmd_abort(struct mmc_card *card, struct request *req) ...@@ -1598,20 +1598,27 @@ static void mmc_blk_rw_cmd_abort(struct mmc_card *card, struct request *req)
blk_rq_cur_bytes(req)); blk_rq_cur_bytes(req));
} }
static void mmc_blk_rw_start_new(struct mmc_queue *mq, struct mmc_card *card, /**
struct request *req) * mmc_blk_rw_try_restart() - tries to restart the current async request
* @mq: the queue with the card and host to restart
* @req: a new request that want to be started after the current one
*/
static void mmc_blk_rw_try_restart(struct mmc_queue *mq, struct request *req)
{ {
if (!req) if (!req)
return; return;
if (mmc_card_removed(card)) { /*
* If the card was removed, just cancel everything and return.
*/
if (mmc_card_removed(mq->card)) {
req->rq_flags |= RQF_QUIET; req->rq_flags |= RQF_QUIET;
blk_end_request_all(req, -EIO); blk_end_request_all(req, -EIO);
} else { return;
mmc_blk_rw_rq_prep(mq->mqrq_cur, card, 0, mq);
mmc_start_areq(card->host,
&mq->mqrq_cur->mmc_active, NULL);
} }
/* Else proceed and try to restart the current async request */
mmc_blk_rw_rq_prep(mq->mqrq_cur, mq->card, 0, mq);
mmc_start_areq(mq->card->host, &mq->mqrq_cur->mmc_active, NULL);
} }
static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *new_req) static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *new_req)
...@@ -1698,11 +1705,11 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *new_req) ...@@ -1698,11 +1705,11 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *new_req)
ret = mmc_blk_cmd_err(md, card, brq, old_req, ret); ret = mmc_blk_cmd_err(md, card, brq, old_req, ret);
if (mmc_blk_reset(md, card->host, type)) { if (mmc_blk_reset(md, card->host, type)) {
mmc_blk_rw_cmd_abort(card, old_req); mmc_blk_rw_cmd_abort(card, old_req);
mmc_blk_rw_start_new(mq, card, new_req); mmc_blk_rw_try_restart(mq, new_req);
return; return;
} }
if (!ret) { if (!ret) {
mmc_blk_rw_start_new(mq, card, new_req); mmc_blk_rw_try_restart(mq, new_req);
return; return;
} }
break; break;
...@@ -1715,7 +1722,7 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *new_req) ...@@ -1715,7 +1722,7 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *new_req)
if (!mmc_blk_reset(md, card->host, type)) if (!mmc_blk_reset(md, card->host, type))
break; break;
mmc_blk_rw_cmd_abort(card, old_req); mmc_blk_rw_cmd_abort(card, old_req);
mmc_blk_rw_start_new(mq, card, new_req); mmc_blk_rw_try_restart(mq, new_req);
return; return;
case MMC_BLK_DATA_ERR: { case MMC_BLK_DATA_ERR: {
int err; int err;
...@@ -1725,7 +1732,7 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *new_req) ...@@ -1725,7 +1732,7 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *new_req)
break; break;
if (err == -ENODEV) { if (err == -ENODEV) {
mmc_blk_rw_cmd_abort(card, old_req); mmc_blk_rw_cmd_abort(card, old_req);
mmc_blk_rw_start_new(mq, card, new_req); mmc_blk_rw_try_restart(mq, new_req);
return; return;
} }
/* Fall through */ /* Fall through */
...@@ -1746,19 +1753,19 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *new_req) ...@@ -1746,19 +1753,19 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *new_req)
ret = blk_end_request(old_req, -EIO, ret = blk_end_request(old_req, -EIO,
brq->data.blksz); brq->data.blksz);
if (!ret) { if (!ret) {
mmc_blk_rw_start_new(mq, card, new_req); mmc_blk_rw_try_restart(mq, new_req);
return; return;
} }
break; break;
case MMC_BLK_NOMEDIUM: case MMC_BLK_NOMEDIUM:
mmc_blk_rw_cmd_abort(card, old_req); mmc_blk_rw_cmd_abort(card, old_req);
mmc_blk_rw_start_new(mq, card, new_req); mmc_blk_rw_try_restart(mq, new_req);
return; return;
default: default:
pr_err("%s: Unhandled return value (%d)", pr_err("%s: Unhandled return value (%d)",
old_req->rq_disk->disk_name, status); old_req->rq_disk->disk_name, status);
mmc_blk_rw_cmd_abort(card, old_req); mmc_blk_rw_cmd_abort(card, old_req);
mmc_blk_rw_start_new(mq, card, new_req); mmc_blk_rw_try_restart(mq, new_req);
return; return;
} }
......
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