mmc: core: Send correct error code to the block layer

Send the expected error code to the block layer.

Change-Id: Ib211a79e325ef616f89789c52a76e4dfa86a0f74
Signed-off-by: Sarthak Garg <sartgarg@codeaurora.org>
tirimbino
Sarthak Garg 4 years ago committed by Gerrit - the friendly Code Review server
parent 9e16ab28a7
commit 779d9f4eb5
  1. 19
      drivers/mmc/core/block.c

@ -2437,7 +2437,7 @@ static int mmc_blk_cmdq_issue_discard_rq(struct mmc_queue *mq,
if (!mmc_can_erase(card)) {
err = -EOPNOTSUPP;
blk_end_request(req, err, blk_rq_bytes(req));
blk_end_request(req, BLK_STS_NOTSUPP, blk_rq_bytes(req));
goto out;
}
@ -2488,7 +2488,7 @@ static int mmc_blk_cmdq_issue_secdiscard_rq(struct mmc_queue *mq,
if (!(mmc_can_secure_erase_trim(card))) {
err = -EOPNOTSUPP;
blk_end_request(req, err, blk_rq_bytes(req));
blk_end_request(req, BLK_STS_NOTSUPP, blk_rq_bytes(req));
goto out;
}
@ -3101,6 +3101,7 @@ void mmc_blk_cmdq_complete_rq(struct request *rq)
int err_resp = 0;
bool is_dcmd = false;
bool err_rwsem = false;
blk_status_t blk_err = BLK_STS_OK;
if (down_read_trylock(&ctx_info->err_rwsem)) {
err_rwsem = true;
@ -3118,6 +3119,9 @@ void mmc_blk_cmdq_complete_rq(struct request *rq)
if (cmdq_req->resp_err)
err_resp = cmdq_req->resp_err;
if (err)
blk_err = BLK_STS_IOERR;
if ((err || err_resp) && !cmdq_req->skip_err_handling) {
pr_err("%s: %s: txfr error(%d)/resp_err(%d)\n",
mmc_hostname(mrq->host), __func__, err,
@ -3146,7 +3150,7 @@ void mmc_blk_cmdq_complete_rq(struct request *rq)
mmc_cmdq_post_req(host, cmdq_req->tag, err);
if (cmdq_req->cmdq_req_flags & DCMD) {
clear_bit(CMDQ_STATE_DCMD_ACTIVE, &ctx_info->curr_state);
blk_end_request_all(rq, err);
blk_end_request_all(rq, blk_err);
goto out;
}
/*
@ -3157,11 +3161,11 @@ void mmc_blk_cmdq_complete_rq(struct request *rq)
*/
if (err && cmdq_req->skip_err_handling) {
cmdq_req->skip_err_handling = false;
blk_end_request_all(rq, err);
blk_end_request_all(rq, blk_err);
goto out;
}
blk_end_request(rq, err, cmdq_req->data.bytes_xfered);
blk_end_request(rq, blk_err, cmdq_req->data.bytes_xfered);
out:
@ -3528,7 +3532,7 @@ static int mmc_blk_cmdq_issue_drv_op(struct mmc_card *card,
if (ret) {
pr_err("%s: failed to halt on empty queue\n",
mmc_hostname(card->host));
blk_end_request_all(req, ret);
blk_end_request_all(req, BLK_STS_IOERR);
mmc_put_card(card);
return ret;
}
@ -3642,7 +3646,8 @@ static int mmc_blk_cmdq_issue_rq(struct mmc_queue *mq, struct request *req)
out:
if (req)
blk_end_request_all(req, ret);
blk_end_request_all(req,
ret ? BLK_STS_IOERR : BLK_STS_OK);
mmc_put_card(card);
return ret;

Loading…
Cancel
Save