Thread (2 messages) flat view 2 messages, 2 authors, 2021-08-06
STALE1863d

[PATCH] power: supply: cpcap-battery: Use IS_ERR() to check and simplify code

From: Tang Bin <hidden>
Date: 2021-07-20 06:20:43
Also in: lkml
Subsystem: power supply class/subsystem and drivers, the rest · Maintainers: Sebastian Reichel, Linus Torvalds

Use IS_ERR() and PTR_ERR() instead of PTR_ERR_OR_ZERO() to
simplify code, avoid redundant judgements.

Signed-off-by: Zhang Shengju <redacted>
Signed-off-by: Tang Bin <redacted>
---
 drivers/power/supply/cpcap-battery.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/power/supply/cpcap-battery.c b/drivers/power/supply/cpcap-battery.c
index 90eba3646..7007e5d53 100644
--- a/drivers/power/supply/cpcap-battery.c
+++ b/drivers/power/supply/cpcap-battery.c
@@ -912,10 +912,9 @@ static int cpcap_battery_probe(struct platform_device *pdev)
 
 	ddata->psy = devm_power_supply_register(ddata->dev, psy_desc,
 						&psy_cfg);
-	error = PTR_ERR_OR_ZERO(ddata->psy);
-	if (error) {
+	if (IS_ERR(ddata->psy)) {
 		dev_err(ddata->dev, "failed to register power supply\n");
-		return error;
+		return PTR_ERR(ddata->psy);
 	}
 
 	atomic_set(&ddata->active, 1);
-- 
2.20.1.windows.1


Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help