Skip to contentSkip to conversation

watchdog: jz4740: Fix return value check in jz4740_wdt_probe()

PATCH In review 'Wei Yongjun 3 participants 3 messages Mar 4, 2021 – May 17, 2021

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

PATCH 1/1 watchdog: jz4740: Fix return value check in jz4740_wdt_probe()

From: Wei Yongjun <[email protected]>

In case of error, the function device_node_to_regmap() returns ERR_PTR() and never returns NULL. The NULL test in the return value check should be replaced with IS_ERR().

Fixes 6d532143c915 ("watchdog: jz4740: Use regmap provided by TCU driver")
---
 drivers/watchdog/jz4740_wdt.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/watchdog/jz4740_wdt.c +2 -2
index bdf9564efa29..395bde79e292 100644
@@ -176,9 +176,9 @@ static int jz4740_wdt_probe(struct platform_device *pdev)
 	watchdog_set_drvdata(jz4740_wdt, drvdata);
 
 	drvdata->map = device_node_to_regmap(dev->parent->of_node);
-	if (!drvdata->map) {
+	if (IS_ERR(drvdata->map)) {
 		dev_err(dev, "regmap not found\n");
-		return -EINVAL;
+		return PTR_ERR(drvdata->map);
 	}
 
 	return devm_watchdog_register_device(dev, &drvdata->wdt);
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines · Wei Yongjun

From: Wei Yongjun <[email protected]>

In case of error, the function device_node_to_regmap() returns ERR_PTR() and never returns NULL. The NULL test in the return value check should be replaced with IS_ERR().

Fixes 6d532143c915 ("watchdog: jz4740: Use regmap provided by TCU driver")

Cheers,
-Paul

Quoted 22 lines
---
 drivers/watchdog/jz4740_wdt.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/watchdog/jz4740_wdt.c +2 -2
index bdf9564efa29..395bde79e292 100644
@@ -176,9 +176,9 @@ static int jz4740_wdt_probe(struct 
 platform_device *pdev)
 	watchdog_set_drvdata(jz4740_wdt, drvdata);
 
 	drvdata->map = device_node_to_regmap(dev->parent->of_node);
-	if (!drvdata->map) {
+	if (IS_ERR(drvdata->map)) {
 		dev_err(dev, "regmap not found\n");
-		return -EINVAL;
+		return PTR_ERR(drvdata->map);
 	}
 

return devm_watchdog_register_device(dev, &drvdata->wdt);

maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to 'Wei Yongjun
Quoted 10 lines · Wei Yongjun

From: Wei Yongjun <[email protected]>

In case of error, the function device_node_to_regmap() returns ERR_PTR() and never returns NULL. The NULL test in the return value check should be replaced with IS_ERR().

Fixes 6d532143c915 ("watchdog: jz4740: Use regmap provided by TCU driver")
Quoted 20 lines
---
 drivers/watchdog/jz4740_wdt.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/watchdog/jz4740_wdt.c +2 -2
index bdf9564efa29..395bde79e292 100644
@@ -176,9 +176,9 @@ static int jz4740_wdt_probe(struct platform_device *pdev)
 	watchdog_set_drvdata(jz4740_wdt, drvdata);
 
 	drvdata->map = device_node_to_regmap(dev->parent->of_node);
-	if (!drvdata->map) {
+	if (IS_ERR(drvdata->map)) {
 		dev_err(dev, "regmap not found\n");
-		return -EINVAL;
+		return PTR_ERR(drvdata->map);
 	}
 
 	return devm_watchdog_register_device(dev, &drvdata->wdt);