[PATCH v10 5/6] mmc: core: Move reset functions for eMMC
From: Ulf Hansson
Date: Tue Oct 27 2026 - 10:43:35 EST
To prepare for a subsequent change and to simplify review, let's move the
function for resetting the eMMC card a few lines up in the file.
Signed-off-by: Ulf Hansson <ulf.hansson@xxxxxxxxxxxxxxxx>
---
drivers/mmc/core/mmc.c | 66 +++++++++++++++++++++---------------------
1 file changed, 33 insertions(+), 33 deletions(-)
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index c936272bcd81..d4bf0f25bd74 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -2271,6 +2271,39 @@ static int mmc_shutdown(struct mmc_host *host)
return err;
}
+static bool mmc_card_can_reset(struct mmc_card *card)
+{
+ u8 rst_n_function;
+
+ rst_n_function = card->ext_csd.rst_n_function;
+ return ((rst_n_function & EXT_CSD_RST_N_EN_MASK) == EXT_CSD_RST_N_ENABLED);
+}
+
+static int _mmc_hw_reset(struct mmc_host *host)
+{
+ struct mmc_card *card = host->card;
+
+ /*
+ * In the case of recovery, we can't expect flushing the cache to work
+ * always, but we have a go and ignore errors.
+ */
+ _mmc_flush_cache(host);
+
+ if ((host->caps & MMC_CAP_HW_RESET) && host->ops->card_hw_reset &&
+ mmc_card_can_reset(card)) {
+ /* If the card accept RST_n signal, send it. */
+ mmc_set_clock(host, host->f_init);
+ host->ops->card_hw_reset(host);
+ /* Set initial state and call mmc_set_ios */
+ mmc_set_initial_state(host);
+ } else {
+ /* Do a brute force power cycle */
+ mmc_power_cycle(host, card->ocr);
+ mmc_pwrseq_reset(host);
+ }
+ return mmc_init_card(host, card->ocr, card);
+}
+
/*
* Callback for resume.
*/
@@ -2319,39 +2352,6 @@ static int mmc_runtime_resume(struct mmc_host *host)
return 0;
}
-static bool mmc_card_can_reset(struct mmc_card *card)
-{
- u8 rst_n_function;
-
- rst_n_function = card->ext_csd.rst_n_function;
- return ((rst_n_function & EXT_CSD_RST_N_EN_MASK) == EXT_CSD_RST_N_ENABLED);
-}
-
-static int _mmc_hw_reset(struct mmc_host *host)
-{
- struct mmc_card *card = host->card;
-
- /*
- * In the case of recovery, we can't expect flushing the cache to work
- * always, but we have a go and ignore errors.
- */
- _mmc_flush_cache(host);
-
- if ((host->caps & MMC_CAP_HW_RESET) && host->ops->card_hw_reset &&
- mmc_card_can_reset(card)) {
- /* If the card accept RST_n signal, send it. */
- mmc_set_clock(host, host->f_init);
- host->ops->card_hw_reset(host);
- /* Set initial state and call mmc_set_ios */
- mmc_set_initial_state(host);
- } else {
- /* Do a brute force power cycle */
- mmc_power_cycle(host, card->ocr);
- mmc_pwrseq_reset(host);
- }
- return mmc_init_card(host, card->ocr, card);
-}
-
/**
* _mmc_handle_undervoltage - Handle an undervoltage event for MMC/eMMC devices
* @host: MMC host structure
--
2.43.0