diff mbox series

[1/2] mmc: core: add helpers mmc_regulator_set_ocr_vmmc_up/off

Message ID 2553f3bc-b1e6-4af2-fb6c-def486dd99a3@gmail.com
State New
Headers show
Series mmc: add helpers mmc_regulator_set_ocr_vmmc_up/off | expand

Commit Message

Heiner Kallweit Feb. 15, 2023, 8:11 p.m. UTC
A lot of drivers use this code, therefore let's factor it out to
helpers.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 include/linux/mmc/host.h | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
diff mbox series

Patch

diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
index 812e6b583..f93fb8c7d 100644
--- a/include/linux/mmc/host.h
+++ b/include/linux/mmc/host.h
@@ -597,6 +597,23 @@  static inline int mmc_regulator_set_vqmmc(struct mmc_host *mmc,
 }
 #endif
 
+static inline int mmc_regulator_set_ocr_vmmc_up(struct mmc_host *mmc,
+						struct mmc_ios *ios)
+{
+	if (IS_ERR(mmc->supply.vmmc))
+		return 0;
+
+	return mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, ios->vdd);
+}
+
+static inline int mmc_regulator_set_ocr_vmmc_off(struct mmc_host *mmc)
+{
+	if (IS_ERR(mmc->supply.vmmc))
+		return 0;
+
+	return mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, 0);
+}
+
 int mmc_regulator_get_supply(struct mmc_host *mmc);
 
 static inline int mmc_card_is_removable(struct mmc_host *host)