mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH] regulator: core: don't call of_regulator_get with NULL argument
Date: Thu,  1 Dec 2022 14:38:53 +0100	[thread overview]
Message-ID: <20221201133853.639287-1-a.fatoum@pengutronix.de> (raw)

regulator_get calls either of_regulator_get or dev_regulator_get, both
of which accept a supply parameter. Only dev_regulator_get gracefully
handles a NULL supply by considering all registered regulators.

of_regulator_get on the other hand, will complain at debug level,
before returning NULL:

  uart-pl011 fe201000.serial@7e201000.of: No <NULL>-supply node found,
  using dummy regulator

Avoid this message by skipping of_regulator_get if no supply was found
and directly call dev_regulator_get.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/regulator/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 4876f0f44bdd..d25aba38c3e2 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -388,7 +388,7 @@ struct regulator *regulator_get(struct device_d *dev, const char *supply)
 	struct regulator *r;
 	int ret;
 
-	if (dev->device_node) {
+	if (dev->device_node && supply) {
 		ri = of_regulator_get(dev, supply);
 		if (IS_ERR(ri))
 			return ERR_CAST(ri);
-- 
2.30.2




             reply	other threads:[~2022-12-01 13:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-01 13:38 Ahmad Fatoum [this message]
2022-12-02  8:50 ` Marco Felsch
2022-12-02  9:03   ` Ahmad Fatoum
2022-12-02  8:53 ` Sascha Hauer

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=20221201133853.639287-1-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.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