Commit e872f1e2 authored by Adrian Hunter's avatar Adrian Hunter Committed by Ulf Hansson

mmc: sdhci: Tidy sdhci_request() a bit

In preparation for further changes, tidy sdhci_request() a bit.
Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
Tested-by: default avatarBaolin Wang <baolin.wang7@gmail.com>
Link: https://lore.kernel.org/r/20200412090349.1607-5-adrian.hunter@intel.comSigned-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
parent 98a2642f
...@@ -1659,6 +1659,17 @@ static void sdhci_send_command(struct sdhci_host *host, struct mmc_command *cmd) ...@@ -1659,6 +1659,17 @@ static void sdhci_send_command(struct sdhci_host *host, struct mmc_command *cmd)
sdhci_writew(host, SDHCI_MAKE_CMD(cmd->opcode, flags), SDHCI_COMMAND); sdhci_writew(host, SDHCI_MAKE_CMD(cmd->opcode, flags), SDHCI_COMMAND);
} }
static bool sdhci_present_error(struct sdhci_host *host,
struct mmc_command *cmd, bool present)
{
if (!present || host->flags & SDHCI_DEVICE_DEAD) {
cmd->error = -ENOMEDIUM;
return true;
}
return false;
}
static void sdhci_read_rsp_136(struct sdhci_host *host, struct mmc_command *cmd) static void sdhci_read_rsp_136(struct sdhci_host *host, struct mmc_command *cmd)
{ {
int i, reg; int i, reg;
...@@ -2048,11 +2059,10 @@ EXPORT_SYMBOL_GPL(sdhci_set_power_and_bus_voltage); ...@@ -2048,11 +2059,10 @@ EXPORT_SYMBOL_GPL(sdhci_set_power_and_bus_voltage);
void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq) void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq)
{ {
struct sdhci_host *host; struct sdhci_host *host = mmc_priv(mmc);
int present; struct mmc_command *cmd;
unsigned long flags; unsigned long flags;
bool present;
host = mmc_priv(mmc);
/* Firstly check card presence */ /* Firstly check card presence */
present = mmc->ops->get_cd(mmc); present = mmc->ops->get_cd(mmc);
...@@ -2061,16 +2071,19 @@ void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq) ...@@ -2061,16 +2071,19 @@ void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq)
sdhci_led_activate(host); sdhci_led_activate(host);
if (!present || host->flags & SDHCI_DEVICE_DEAD) { if (sdhci_present_error(host, mrq->cmd, present))
mrq->cmd->error = -ENOMEDIUM; goto out_finish;
sdhci_finish_mrq(host, mrq);
} else { cmd = sdhci_manual_cmd23(host, mrq) ? mrq->sbc : mrq->cmd;
if (sdhci_manual_cmd23(host, mrq))
sdhci_send_command(host, mrq->sbc);
else
sdhci_send_command(host, mrq->cmd);
}
sdhci_send_command(host, cmd);
spin_unlock_irqrestore(&host->lock, flags);
return;
out_finish:
sdhci_finish_mrq(host, mrq);
spin_unlock_irqrestore(&host->lock, flags); spin_unlock_irqrestore(&host->lock, flags);
} }
EXPORT_SYMBOL_GPL(sdhci_request); EXPORT_SYMBOL_GPL(sdhci_request);
......
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