mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@barebox.org>
To: barebox@lists.infradead.org
Cc: Sohaib Mohamed <sohaib.amhmd@gmail.com>,
	Ahmad Fatoum <a.fatoum@barebox.org>
Subject: [PATCH] regmap: align dev_get_regmap error return with Linux
Date: Mon, 23 Mar 2026 08:24:07 +0100	[thread overview]
Message-ID: <20260323072408.4011172-1-a.fatoum@barebox.org> (raw)

dev_get_regmap returns NULL in Linux and not an error pointer as in
barebox. Align the barebox return, so kernel code using it can be ported
unmodified.

Reported-by: Sohaib Mohamed <sohaib.amhmd@gmail.com>
Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
 drivers/base/regmap/regmap.c          | 4 ++--
 drivers/regulator/stpmic1_regulator.c | 4 ++--
 drivers/watchdog/rn5t568_wdt.c        | 4 ++--
 drivers/watchdog/stpmic1_wdt.c        | 4 ++--
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index e27ba53dec58..e4b20c07809d 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -148,7 +148,7 @@ struct regmap *regmap_init(struct device *dev,
  * @dev:         The device the maps is attached to
  * @name:        Optional name for the map. If given it must match.
  *
- * Returns a pointer to the regmap or a ERR_PTR value on failure
+ * Returns the regmap for the device if one is present, or NULL.
  */
 struct regmap *dev_get_regmap(struct device *dev, const char *name)
 {
@@ -163,7 +163,7 @@ struct regmap *dev_get_regmap(struct device *dev, const char *name)
 			return map;
 	}
 
-	return ERR_PTR(-ENOENT);
+	return NULL;
 }
 
 struct device *regmap_get_device(struct regmap *map)
diff --git a/drivers/regulator/stpmic1_regulator.c b/drivers/regulator/stpmic1_regulator.c
index 3ed351b5801a..eade6046d603 100644
--- a/drivers/regulator/stpmic1_regulator.c
+++ b/drivers/regulator/stpmic1_regulator.c
@@ -401,8 +401,8 @@ static int stpmic1_regulator_register(struct device *dev, int id,
 	cfg->rdev.desc = &cfg->desc;
 	cfg->rdev.dev = dev;
 	cfg->rdev.regmap = dev_get_regmap(dev->parent, NULL);
-	if (IS_ERR(cfg->rdev.regmap))
-		return PTR_ERR(cfg->rdev.regmap);
+	if (!cfg->rdev.regmap)
+		return -ENOENT;
 
 	ret = of_regulator_register(&cfg->rdev, match->of_node);
 	if (ret) {
diff --git a/drivers/watchdog/rn5t568_wdt.c b/drivers/watchdog/rn5t568_wdt.c
index 2011e3e01c5f..8c3e4175f9c0 100644
--- a/drivers/watchdog/rn5t568_wdt.c
+++ b/drivers/watchdog/rn5t568_wdt.c
@@ -117,8 +117,8 @@ static int rn5t568_wdt_probe(struct device *dev)
 	wdt = xzalloc(sizeof(*wdt));
 
 	wdt->regmap = dev_get_regmap(dev->parent, NULL);
-	if (IS_ERR(wdt->regmap))
-		return PTR_ERR(wdt->regmap);
+	if (!wdt->regmap)
+		return -ENOENT;
 
 	wdd = &wdt->wdd;
 	wdd->hwdev = dev;
diff --git a/drivers/watchdog/stpmic1_wdt.c b/drivers/watchdog/stpmic1_wdt.c
index f25656e75c12..21cf721de790 100644
--- a/drivers/watchdog/stpmic1_wdt.c
+++ b/drivers/watchdog/stpmic1_wdt.c
@@ -169,8 +169,8 @@ static int stpmic1_wdt_probe(struct device *dev)
 	wdt = xzalloc(sizeof(*wdt));
 
 	wdt->regmap = dev_get_regmap(dev->parent, NULL);
-	if (IS_ERR(wdt->regmap))
-		return PTR_ERR(wdt->regmap);
+	if (!wdt->regmap)
+		return -ENOENT;
 
 	wdd = &wdt->wdd;
 	wdd->hwdev = dev;
-- 
2.47.3




                 reply	other threads:[~2026-03-23  7:24 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20260323072408.4011172-1-a.fatoum@barebox.org \
    --to=a.fatoum@barebox.org \
    --cc=barebox@lists.infradead.org \
    --cc=sohaib.amhmd@gmail.com \
    /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