Skip to contentSkip to conversation

hwmon: pwm-fan: Use dev_err_probe() to simplify error handling

PATCH Applied Anson Huang 2 participants 2 messages Aug 17, 2020 – Aug 21, 2020 Hardware monitoring

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hwmon: pwm-fan: Use dev_err_probe() to simplify error handling

dev_err_probe() can reduce code size, uniform error handling and record the defer probe reason etc., use it to simplify the code.

---
 drivers/hwmon/pwm-fan.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
drivers/hwmon/pwm-fan.c +2 -8
index 17bb642..bdba214 100644
@@ -293,14 +293,8 @@ static int pwm_fan_probe(struct platform_device *pdev)
 	mutex_init(&ctx->lock);
 
 	ctx->pwm = devm_of_pwm_get(dev, dev->of_node, NULL);
-	if (IS_ERR(ctx->pwm)) {
-		ret = PTR_ERR(ctx->pwm);
-
-		if (ret != -EPROBE_DEFER)
-			dev_err(dev, "Could not get PWM: %d\n", ret);
-
-		return ret;
-	}
+	if (IS_ERR(ctx->pwm))
+		return dev_err_probe(dev, PTR_ERR(ctx->pwm), "Could not get PWM\n");
 
 	platform_set_drvdata(pdev, ctx);
 
Signature · 1 line
2.7.4
maintainer Applied
#1 lore raw
Quoted 4 lines · Anson Huang

dev_err_probe() can reduce code size, uniform error handling and record the defer probe reason etc., use it to simplify the code.

Applied.

Thanks,
Guenter

Quoted 25 lines
---
 drivers/hwmon/pwm-fan.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
drivers/hwmon/pwm-fan.c +2 -8
index 17bb642..bdba214 100644
@@ -293,14 +293,8 @@ static int pwm_fan_probe(struct platform_device *pdev)
 	mutex_init(&ctx->lock);
 
 	ctx->pwm = devm_of_pwm_get(dev, dev->of_node, NULL);
-	if (IS_ERR(ctx->pwm)) {
-		ret = PTR_ERR(ctx->pwm);
-
-		if (ret != -EPROBE_DEFER)
-			dev_err(dev, "Could not get PWM: %d\n", ret);
-
-		return ret;
-	}
+	if (IS_ERR(ctx->pwm))
+		return dev_err_probe(dev, PTR_ERR(ctx->pwm), "Could not get PWM\n");
 
 	platform_set_drvdata(pdev, ctx);