[PATCH v2] power: regulator: Fix regulator_enable/disable() macros

Jonas Karlman jonas at kwiboo.se
Fri Jul 10 15:15:53 CEST 2026


The commit 076265b75e61 ("compat: regulator: add enable/disable macros")
added regulator_enable/disable() macros to provide a closer analogue to
the Linux API.

These new macros wrap regulator_set_enable() that may return detailed
error codes and should typically not directly be called by drivers.

Change the macros to wrap regulator_set_enable_if_allowed() that masks
error codes consumers typically do not expect to closer match the
behavior of the Linux API.

Also move the macros outside the #if #else blocks to make the macros
available when !CONFIG_IS_ENABLED(DM_REGULATOR).

Fixes: 076265b75e61 ("compat: regulator: add enable/disable macros")
Signed-off-by: Jonas Karlman <jonas at kwiboo.se>
---
Changes in v2:
- Move macros outside the #if #else blocks
---
 include/power/regulator.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/power/regulator.h b/include/power/regulator.h
index b8023721a165..8d4d1450b905 100644
--- a/include/power/regulator.h
+++ b/include/power/regulator.h
@@ -371,9 +371,6 @@ int regulator_get_enable(struct udevice *dev);
  */
 int regulator_set_enable(struct udevice *dev, bool enable);
 
-#define regulator_enable(dev) regulator_set_enable(dev, true)
-#define regulator_disable(dev) regulator_set_enable(dev, false)
-
 /**
  * regulator_set_enable_if_allowed: set regulator enable state if allowed by
  *					regulator
@@ -651,4 +648,7 @@ static inline int device_get_supply_regulator(struct udevice *dev, const char *s
 }
 #endif
 
+#define regulator_enable(dev) regulator_set_enable_if_allowed(dev, true)
+#define regulator_disable(dev) regulator_set_enable_if_allowed(dev, false)
+
 #endif /* _INCLUDE_REGULATOR_H_ */
-- 
2.54.0



More information about the U-Boot mailing list