mmc: core: Minor simplifications to __mmc_switch
Instead of using several references to card->host, let's use a local variable. That means we can remove the BUG_ON verifications for the same pointers. Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> Signed-off-by: Chris Ball <chris@printf.net>
This commit is contained in:
parent
4509f84775
commit
636bd13c12
|
@ -413,14 +413,12 @@ int __mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value,
|
||||||
unsigned int timeout_ms, bool use_busy_signal, bool send_status,
|
unsigned int timeout_ms, bool use_busy_signal, bool send_status,
|
||||||
bool ignore_crc)
|
bool ignore_crc)
|
||||||
{
|
{
|
||||||
|
struct mmc_host *host = card->host;
|
||||||
int err;
|
int err;
|
||||||
struct mmc_command cmd = {0};
|
struct mmc_command cmd = {0};
|
||||||
unsigned long timeout;
|
unsigned long timeout;
|
||||||
u32 status = 0;
|
u32 status = 0;
|
||||||
|
|
||||||
BUG_ON(!card);
|
|
||||||
BUG_ON(!card->host);
|
|
||||||
|
|
||||||
cmd.opcode = MMC_SWITCH;
|
cmd.opcode = MMC_SWITCH;
|
||||||
cmd.arg = (MMC_SWITCH_MODE_WRITE_BYTE << 24) |
|
cmd.arg = (MMC_SWITCH_MODE_WRITE_BYTE << 24) |
|
||||||
(index << 16) |
|
(index << 16) |
|
||||||
|
@ -437,7 +435,7 @@ int __mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value,
|
||||||
if (index == EXT_CSD_SANITIZE_START)
|
if (index == EXT_CSD_SANITIZE_START)
|
||||||
cmd.sanitize_busy = true;
|
cmd.sanitize_busy = true;
|
||||||
|
|
||||||
err = mmc_wait_for_cmd(card->host, &cmd, MMC_CMD_RETRIES);
|
err = mmc_wait_for_cmd(host, &cmd, MMC_CMD_RETRIES);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
|
@ -449,7 +447,7 @@ int __mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value,
|
||||||
* CRC errors shall only be ignored in cases were CMD13 is used to poll
|
* CRC errors shall only be ignored in cases were CMD13 is used to poll
|
||||||
* to detect busy completion.
|
* to detect busy completion.
|
||||||
*/
|
*/
|
||||||
if (card->host->caps & MMC_CAP_WAIT_WHILE_BUSY)
|
if (host->caps & MMC_CAP_WAIT_WHILE_BUSY)
|
||||||
ignore_crc = false;
|
ignore_crc = false;
|
||||||
|
|
||||||
/* Must check status to be sure of no errors. */
|
/* Must check status to be sure of no errors. */
|
||||||
|
@ -460,9 +458,9 @@ int __mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value,
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
if (card->host->caps & MMC_CAP_WAIT_WHILE_BUSY)
|
if (host->caps & MMC_CAP_WAIT_WHILE_BUSY)
|
||||||
break;
|
break;
|
||||||
if (mmc_host_is_spi(card->host))
|
if (mmc_host_is_spi(host))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -478,18 +476,18 @@ int __mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value,
|
||||||
/* Timeout if the device never leaves the program state. */
|
/* Timeout if the device never leaves the program state. */
|
||||||
if (time_after(jiffies, timeout)) {
|
if (time_after(jiffies, timeout)) {
|
||||||
pr_err("%s: Card stuck in programming state! %s\n",
|
pr_err("%s: Card stuck in programming state! %s\n",
|
||||||
mmc_hostname(card->host), __func__);
|
mmc_hostname(host), __func__);
|
||||||
return -ETIMEDOUT;
|
return -ETIMEDOUT;
|
||||||
}
|
}
|
||||||
} while (R1_CURRENT_STATE(status) == R1_STATE_PRG);
|
} while (R1_CURRENT_STATE(status) == R1_STATE_PRG);
|
||||||
|
|
||||||
if (mmc_host_is_spi(card->host)) {
|
if (mmc_host_is_spi(host)) {
|
||||||
if (status & R1_SPI_ILLEGAL_COMMAND)
|
if (status & R1_SPI_ILLEGAL_COMMAND)
|
||||||
return -EBADMSG;
|
return -EBADMSG;
|
||||||
} else {
|
} else {
|
||||||
if (status & 0xFDFFA000)
|
if (status & 0xFDFFA000)
|
||||||
pr_warning("%s: unexpected status %#x after "
|
pr_warn("%s: unexpected status %#x after switch\n",
|
||||||
"switch", mmc_hostname(card->host), status);
|
mmc_hostname(host), status);
|
||||||
if (status & R1_SWITCH_ERROR)
|
if (status & R1_SWITCH_ERROR)
|
||||||
return -EBADMSG;
|
return -EBADMSG;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue