@@ -432,6 +432,8 @@ static int mmc_send_status_error(struct mmc_host *host, u32 status,
mmc_hostname(host), status);
if (status & R1_SWITCH_ERROR)
return -EBADMSG;
+ } else {
+ return R1_STATUS(status) ? -EIO : 0;
}
return 0;
@@ -459,7 +461,7 @@ int mmc_switch_status(struct mmc_card *card)
int mmc_poll_for_busy(struct mmc_card *card, unsigned int timeout_ms,
bool send_status, bool retry_crc_err, bool use_r1b_resp,
- unsigned int retries)
+ unsigned int retries, bool poll_for_switch)
{
struct mmc_host *host = card->host;
int err;
@@ -504,7 +506,8 @@ int mmc_poll_for_busy(struct mmc_card *card, unsigned int timeout_ms,
} else if (err) {
return err;
} else {
- err = mmc_send_status_error(host, status, true);
+ err = mmc_send_status_error(host, status,
+ poll_for_switch);
if (err)
return err;
busy = R1_CURRENT_STATE(status) == R1_STATE_PRG
@@ -592,7 +595,7 @@ int __mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value,
/* Let's try to poll to find out when the command is completed. */
err = mmc_poll_for_busy(card, timeout_ms, send_status, retry_crc_err,
- use_r1b_resp, MMC_CMD_RETRIES);
+ use_r1b_resp, MMC_CMD_RETRIES, true);
if (err)
goto out;
@@ -35,7 +35,7 @@
int mmc_get_ext_csd(struct mmc_card *card, u8 **new_ext_csd);
int mmc_poll_for_busy(struct mmc_card *card, unsigned int timeout_ms,
bool send_status, bool retry_crc_err, bool use_r1b_resp,
- unsigned int retries);
+ unsigned int retries, bool poll_for_switch);
int mmc_switch_status(struct mmc_card *card);
int __mmc_switch_status(struct mmc_card *card, bool crc_err_fatal);
int __mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value,
Add new flag, poll_for_switch, to tell mmc_send_status_error() how to translate the device status into return code. No functional change intended. Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com> --- drivers/mmc/core/mmc_ops.c | 9 ++++++--- drivers/mmc/core/mmc_ops.h | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-)