Skip to contentSkip to conversation

regmap: align dev_get_regmap error return with Linux

PATCH Applied Ahmad Fatoum 2 participants 2 messages Mar 23 – Apr 13

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 regmap: align dev_get_regmap error return with Linux

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.

---
 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(-)
drivers/base/regmap/regmap.c +2 -2
index e27ba53dec58..e4b20c07809d 100644
@@ -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)
drivers/regulator/stpmic1_regulator.c +2 -2
index 3ed351b5801a..eade6046d603 100644
@@ -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) {
drivers/watchdog/rn5t568_wdt.c +2 -2
index 2011e3e01c5f..8c3e4175f9c0 100644
@@ -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;
drivers/watchdog/stpmic1_wdt.c +2 -2
index f25656e75c12..21cf721de790 100644
@@ -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;
Signature · 1 line
2.47.3