mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH master] soc: rockchip: io-domain: handle missing supply correctly
@ 2024-04-15  5:31 Ahmad Fatoum
  2024-04-16 10:26 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2024-04-15  5:31 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

The original Linux code calls regulator_get_optional and handles its
-ENODEV return code, which morphed into regulator_get when ported to
barebox. The error handling stayed as-is leading to causing supplies to
trigger errors instead of being silently ignored.

As we use NULL to describe the dummy regulator in barebox, we can add a
trivial regulator_get_optional implementation and use it to fix the
I/O domain driver.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/soc/rockchip/io-domain.c | 2 +-
 include/regulator.h              | 8 ++++++++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/soc/rockchip/io-domain.c b/drivers/soc/rockchip/io-domain.c
index 9f60b6eb4c28..453d393cb09f 100644
--- a/drivers/soc/rockchip/io-domain.c
+++ b/drivers/soc/rockchip/io-domain.c
@@ -165,7 +165,7 @@ static int rockchip_iodomain_probe(struct device *dev)
 		if (!supply_name)
 			continue;
 
-		reg = regulator_get(dev, supply_name);
+		reg = regulator_get_optional(dev, supply_name);
 		if (IS_ERR(reg)) {
 			ret = PTR_ERR(reg);
 
diff --git a/include/regulator.h b/include/regulator.h
index 135fe6d91fd3..305da0d774ba 100644
--- a/include/regulator.h
+++ b/include/regulator.h
@@ -3,6 +3,7 @@
 #define __REGULATOR_H
 
 #include <linux/bitops.h>
+#include <linux/err.h>
 
 struct device;
 
@@ -284,4 +285,11 @@ static inline int regulator_get_voltage(struct regulator *regulator)
 
 #endif
 
+static inline struct regulator *regulator_get_optional(struct device *dev,
+						       const char *id)
+{
+	return regulator_get(dev, id) ?: ERR_PTR(-ENODEV);
+}
+
+
 #endif /* __REGULATOR_H */
-- 
2.39.2




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH master] soc: rockchip: io-domain: handle missing supply correctly
  2024-04-15  5:31 [PATCH master] soc: rockchip: io-domain: handle missing supply correctly Ahmad Fatoum
@ 2024-04-16 10:26 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2024-04-16 10:26 UTC (permalink / raw)
  To: barebox, Ahmad Fatoum


On Mon, 15 Apr 2024 07:31:30 +0200, Ahmad Fatoum wrote:
> The original Linux code calls regulator_get_optional and handles its
> -ENODEV return code, which morphed into regulator_get when ported to
> barebox. The error handling stayed as-is leading to causing supplies to
> trigger errors instead of being silently ignored.
> 
> As we use NULL to describe the dummy regulator in barebox, we can add a
> trivial regulator_get_optional implementation and use it to fix the
> I/O domain driver.
> 
> [...]

Applied, thanks!

[1/1] soc: rockchip: io-domain: handle missing supply correctly
      https://git.pengutronix.de/cgit/barebox/commit/?id=284a876cee1f (link may not be stable)

Best regards,
-- 
Sascha Hauer <s.hauer@pengutronix.de>




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-04-16 10:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-15  5:31 [PATCH master] soc: rockchip: io-domain: handle missing supply correctly Ahmad Fatoum
2024-04-16 10:26 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox