mmc: core: Factor out some of the code in mmc_go_idle()
authorVictor Shih <victor.shih@genesyslogic.com.tw>
Fri, 13 Sep 2024 10:28:20 +0000 (18:28 +0800)
committerUlf Hansson <ulf.hansson@linaro.org>
Mon, 14 Oct 2024 10:40:10 +0000 (12:40 +0200)
Move some part out from mmc_go_idle() into a new function called
__mmc_go_idle(), allowing it to be re-used, which is shown from a
subsequent change.

Signed-off-by: Victor Shih <victor.shih@genesyslogic.com.tw>
Link: https://lore.kernel.org/r/20240913102836.6144-7-victorshihgli@gmail.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/mmc/core/mmc_ops.c
drivers/mmc/core/mmc_ops.h

index 3b3adbd..5c8e62e 100644 (file)
@@ -144,10 +144,24 @@ int mmc_set_dsr(struct mmc_host *host)
        return mmc_wait_for_cmd(host, &cmd, MMC_CMD_RETRIES);
 }
 
+int __mmc_go_idle(struct mmc_host *host)
+{
+       struct mmc_command cmd = {};
+       int err;
+
+       cmd.opcode = MMC_GO_IDLE_STATE;
+       cmd.arg = 0;
+       cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_NONE | MMC_CMD_BC;
+
+       err = mmc_wait_for_cmd(host, &cmd, 0);
+       mmc_delay(1);
+
+       return err;
+}
+
 int mmc_go_idle(struct mmc_host *host)
 {
        int err;
-       struct mmc_command cmd = {};
 
        /*
         * Non-SPI hosts need to prevent chipselect going active during
@@ -163,13 +177,7 @@ int mmc_go_idle(struct mmc_host *host)
                mmc_delay(1);
        }
 
-       cmd.opcode = MMC_GO_IDLE_STATE;
-       cmd.arg = 0;
-       cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_NONE | MMC_CMD_BC;
-
-       err = mmc_wait_for_cmd(host, &cmd, 0);
-
-       mmc_delay(1);
+       err = __mmc_go_idle(host);
 
        if (!mmc_host_is_spi(host)) {
                mmc_set_chip_select(host, MMC_CS_DONTCARE);
index 0601711..0df3ebd 100644 (file)
@@ -25,6 +25,7 @@ struct mmc_command;
 int mmc_select_card(struct mmc_card *card);
 int mmc_deselect_cards(struct mmc_host *host);
 int mmc_set_dsr(struct mmc_host *host);
+int __mmc_go_idle(struct mmc_host *host);
 int mmc_go_idle(struct mmc_host *host);
 int mmc_send_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr);
 int mmc_set_relative_addr(struct mmc_card *card);