[PATCH v2 2/3] mmc: core: Add mmc_delay_us() for microsecond precision delays

Judith Mendez <[email protected]> Wed, 22 Jul 2026 15:57:00 -0500
Newsgroups org.kernel.vger.linux-mmc,org.kernel.vger.linux-devicetree,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
Add mmc_delay_us() to support microsecond-granularity delays needed
in MMC framework. It uses 25% margin consistent with  mmc_delay() for
timing flexibility.

Signed-off-by: Judith Mendez <[email protected]>
---
Changes since v1:
- add patch 2/3
---
 drivers/mmc/core/core.h | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/drivers/mmc/core/core.h b/drivers/mmc/core/core.h
index a028b48be1644..55e9fb3bab9f7 100644
--- a/drivers/mmc/core/core.h
+++ b/drivers/mmc/core/core.h
@@ -73,6 +73,19 @@ static inline void mmc_delay(unsigned int ms)
 		msleep(ms);
 }
 
+static inline void mmc_delay_us(unsigned int us)
+{
+	if (us < 1000) {
+		usleep_range(us, us + (us >> 2));
+	} else {
+		unsigned int rem_us = us % 1000;
+
+		msleep(us / 1000);
+		if (rem_us)
+			usleep_range(rem_us, rem_us + (rem_us >> 2));
+	}
+}
+
 void mmc_rescan(struct work_struct *work);
 void mmc_start_host(struct mmc_host *host);
 void __mmc_stop_host(struct mmc_host *host);
-- 
2.54.0