mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] regulator: core: fix the broken behavior of regulator_dev_lookup()
@ 2024-09-11 12:03 Wei Fang
  2024-09-11 16:25 ` Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Wei Fang @ 2024-09-11 12:03 UTC (permalink / raw)
  To: lgirdwood, broonie, wenst; +Cc: aisheng.dong, linux-kernel, imx

The behavior of regulator_dev_lookup() for non-DT way has been broken
since the commit b8c325545714 ("regulator: Move OF-specific regulator
lookup code to of_regulator.c").

Before the commit, of_get_regulator() was used to get the regulator,
which returns NULL if the regulator is not found. So the regulator
will be looked up through regulator_lookup_by_name() if no matching
regulator is found in regulator_map_list.

However, currently, of_regulator_dev_lookup() is used to instead of
of_get_regulator(), but the variable 'r' is set to ERR_PTR(-ENODEV)
instead of NULL if the regulator is not found. In this case, if no
regulator is found in regulator_map_list, the variable 'r' is still
ERR_PTR(-ENODEV), So regulator_dev_lookup() returns the value of 'r'
directly instead of continuing to look up the regulator through
regulator_lookup_by_name().

Fixes: b8c325545714 ("regulator: Move OF-specific regulator lookup code to of_regulator.c")
Signed-off-by: Wei Fang <wei.fang@nxp.com>
---
 drivers/regulator/core.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 835a5531d045..40dbff4017f5 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1965,6 +1965,9 @@ static struct regulator_dev *regulator_dev_lookup(struct device *dev,
 			return r;
 		if (PTR_ERR(r) == -EPROBE_DEFER)
 			return r;
+
+		if (PTR_ERR(r) == -ENODEV)
+			r = NULL;
 	}
 
 	/* if not found, try doing it non-dt way */
-- 
2.34.1


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

end of thread, other threads:[~2024-09-11 16:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-11 12:03 [PATCH] regulator: core: fix the broken behavior of regulator_dev_lookup() Wei Fang
2024-09-11 16:25 ` Mark Brown

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

all inboxes | Powered by JetHome®