From: Wei Fang <wei.fang@nxp.com>
To: lgirdwood@gmail.com, broonie@kernel.org, wenst@chromium.org
Cc: aisheng.dong@nxp.com, linux-kernel@vger.kernel.org, imx@lists.linux.dev
Subject: [PATCH] regulator: core: fix the broken behavior of regulator_dev_lookup()
Date: Wed, 11 Sep 2024 20:03:38 +0800 [thread overview]
Message-ID: <20240911120338.526384-1-wei.fang@nxp.com> (raw)
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
next reply other threads:[~2024-09-11 12:18 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-11 12:03 Wei Fang [this message]
2024-09-11 16:25 ` Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240911120338.526384-1-wei.fang@nxp.com \
--to=wei.fang@nxp.com \
--cc=aisheng.dong@nxp.com \
--cc=broonie@kernel.org \
--cc=imx@lists.linux.dev \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=wenst@chromium.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®