[PATCH v2 3/5] power: regulator: Exit from regulator_set_suspend_value on poorly described regulators

Marek Vasut marex at denx.de
Wed Sep 25 04:21:54 CEST 2024


In case the DT regulator node does not contain 'regulator-max-microvolt'
property and does not contain 'regulator-state-mem' subnode (like the
test.dts regul1_scmi: reg at 1 {} regulator node), then regulator_pre_probe()
will parse this regulator node and set uc_pdata->suspend_on = true and
uc_pdata->suspend_uV = uc_pdata->max_uV, where uc_pdata->max_uV is set
to -ENODATA because "regulator-max-microvolt" is missing, and therefore
uc_pdata->suspend_uV is also -ENODATA. In case regulator_autoset() is
used afterward, it will attempt to call regulator_set_suspend_value()
with uV = uc_pdata->suspend_uV = -ENODATA and fail with -EINVAL. Check
for this case in regulator_set_suspend_value() and immediately return 0,
because there is no way to set meaningful suspend voltage, so do nothing
and retain the existing settings of the regulator.

Signed-off-by: Marek Vasut <marex at denx.de>
---
Cc: Ben Wolsieffer <benwolsieffer at gmail.com>
Cc: Caleb Connolly <caleb.connolly at linaro.org>
Cc: Chris Morgan <macromorgan at hotmail.com>
Cc: Dragan Simic <dsimic at manjaro.org>
Cc: Eugen Hristev <eugen.hristev at collabora.com>
Cc: Francesco Dolcini <francesco.dolcini at toradex.com>
Cc: Heinrich Schuchardt <xypron.glpk at gmx.de>
Cc: Jaehoon Chung <jh80.chung at samsung.com>
Cc: Jagan Teki <jagan at amarulasolutions.com>
Cc: Jonas Karlman <jonas at kwiboo.se>
Cc: Kever Yang <kever.yang at rock-chips.com>
Cc: Matteo Lisi <matteo.lisi at engicam.com>
Cc: Mattijs Korpershoek <mkorpershoek at baylibre.com>
Cc: Max Krummenacher <max.krummenacher at toradex.com>
Cc: Neil Armstrong <neil.armstrong at linaro.org>
Cc: Patrice Chotard <patrice.chotard at foss.st.com>
Cc: Patrick Delaunay <patrick.delaunay at foss.st.com>
Cc: Philipp Tomsich <philipp.tomsich at vrull.eu>
Cc: Quentin Schulz <quentin.schulz at cherry.de>
Cc: Sam Day <me at samcday.com>
Cc: Simon Glass <sjg at chromium.org>
Cc: Sumit Garg <sumit.garg at linaro.org>
Cc: Svyatoslav Ryhel <clamor95 at gmail.com>
Cc: Thierry Reding <treding at nvidia.com>
Cc: Tom Rini <trini at konsulko.com>
Cc: Volodymyr Babchuk <Volodymyr_Babchuk at epam.com>
Cc: u-boot-amlogic at groups.io
Cc: u-boot-qcom at groups.io
Cc: u-boot at dh-electronics.com
Cc: u-boot at lists.denx.de
Cc: uboot-stm32 at st-md-mailman.stormreply.com
---
V2: New patch
---
 drivers/power/regulator/regulator-uclass.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/power/regulator/regulator-uclass.c b/drivers/power/regulator/regulator-uclass.c
index 14cf3159203..3c05fdf1966 100644
--- a/drivers/power/regulator/regulator-uclass.c
+++ b/drivers/power/regulator/regulator-uclass.c
@@ -85,6 +85,10 @@ int regulator_set_suspend_value(struct udevice *dev, int uV)
 	const struct dm_regulator_ops *ops = dev_get_driver_ops(dev);
 	struct dm_regulator_uclass_plat *uc_pdata;
 
+	/* Regulator did not set limits, assume already configured. */
+	if (uV == -ENODATA)
+		return 0;
+
 	uc_pdata = dev_get_uclass_plat(dev);
 	if (uc_pdata->min_uV != -ENODATA && uV < uc_pdata->min_uV)
 		return -EINVAL;
-- 
2.45.2



More information about the U-Boot mailing list