¿ªÔÆÌåÓý

ctrl + shift + ? for shortcuts
© 2025 Groups.io

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


Marek Vasut
 

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@1 {} regulator node), then regulator_pre_probe(=
)
will parse this regulator node and set uc_pdata->suspend_on =3D true and
uc_pdata->suspend_uV =3D 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 =3D uc_pdata->suspend_uV =3D -ENODATA and fail with -EINVAL. Chec=
k
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@...>
---
Cc: Ben Wolsieffer <benwolsieffer@...>
Cc: Caleb Connolly <caleb.connolly@...>
Cc: Chris Morgan <macromorgan@...>
Cc: Dragan Simic <dsimic@...>
Cc: Eugen Hristev <eugen.hristev@...>
Cc: Francesco Dolcini <francesco.dolcini@...>
Cc: Heinrich Schuchardt <xypron.glpk@...>
Cc: Jaehoon Chung <jh80.chung@...>
Cc: Jagan Teki <jagan@...>
Cc: Jonas Karlman <jonas@...>
Cc: Kever Yang <kever.yang@...>
Cc: Matteo Lisi <matteo.lisi@...>
Cc: Mattijs Korpershoek <mkorpershoek@...>
Cc: Max Krummenacher <max.krummenacher@...>
Cc: Neil Armstrong <neil.armstrong@...>
Cc: Patrice Chotard <patrice.chotard@...>
Cc: Patrick Delaunay <patrick.delaunay@...>
Cc: Philipp Tomsich <philipp.tomsich@...>
Cc: Quentin Schulz <quentin.schulz@...>
Cc: Sam Day <me@...>
Cc: Simon Glass <sjg@...>
Cc: Sumit Garg <sumit.garg@...>
Cc: Svyatoslav Ryhel <clamor95@...>
Cc: Thierry Reding <treding@...>
Cc: Tom Rini <trini@...>
Cc: Volodymyr Babchuk <Volodymyr_Babchuk@...>
Cc: [email protected]
Cc: [email protected]
Cc: u-boot@...
Cc: u-boot@...
Cc: uboot-stm32@...
---
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/r=
egulator/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, i=
nt uV)
const struct dm_regulator_ops *ops =3D dev_get_driver_ops(dev);
struct dm_regulator_uclass_plat *uc_pdata;
=20
+ /* Regulator did not set limits, assume already configured. */
+ if (uV =3D=3D -ENODATA)
+ return 0;
+
uc_pdata =3D dev_get_uclass_plat(dev);
if (uc_pdata->min_uV !=3D -ENODATA && uV < uc_pdata->min_uV)
return -EINVAL;
--=20
2.45.2