Skip to content

Commit

Permalink
hwmon: (pwm-fan) Use dev_err_probe() to simplify error handling
Browse files Browse the repository at this point in the history
dev_err_probe() can reduce code size, uniform error handling and record the
defer probe reason etc., use it to simplify the code.

Signed-off-by: Anson Huang <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Guenter Roeck <[email protected]>
  • Loading branch information
Anson-Huang authored and groeck committed Sep 23, 2020
1 parent 4e1b4d2 commit 65b2aad
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions drivers/hwmon/pwm-fan.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 65b2aad

Please sign in to comment.