Skip to content

Commit

Permalink
pwm: lpc18xx: Convert to use dev_err_probe()
Browse files Browse the repository at this point in the history
This has various upsides:
 - It emits the symbolic name of the error code
 - It is silent in the EPROBE_DEFER case and properly sets the defer reason
 - It reduces the number of code lines slightly

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
  • Loading branch information
Uwe Kleine-König authored and Thierry Reding committed Jul 29, 2022
1 parent ea95b29 commit 2ba1aed
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions drivers/pwm/pwm-lpc18xx-sct.c
Original file line number Diff line number Diff line change
Expand Up @@ -359,21 +359,19 @@ static int lpc18xx_pwm_probe(struct platform_device *pdev)
return PTR_ERR(lpc18xx_pwm->base);

lpc18xx_pwm->pwm_clk = devm_clk_get(&pdev->dev, "pwm");
if (IS_ERR(lpc18xx_pwm->pwm_clk)) {
dev_err(&pdev->dev, "failed to get pwm clock\n");
return PTR_ERR(lpc18xx_pwm->pwm_clk);
}
if (IS_ERR(lpc18xx_pwm->pwm_clk))
return dev_err_probe(&pdev->dev, PTR_ERR(lpc18xx_pwm->pwm_clk),
"failed to get pwm clock\n");

ret = clk_prepare_enable(lpc18xx_pwm->pwm_clk);
if (ret < 0) {
dev_err(&pdev->dev, "could not prepare or enable pwm clock\n");
return ret;
}
if (ret < 0)
return dev_err_probe(&pdev->dev, ret,
"could not prepare or enable pwm clock\n");

lpc18xx_pwm->clk_rate = clk_get_rate(lpc18xx_pwm->pwm_clk);
if (!lpc18xx_pwm->clk_rate) {
dev_err(&pdev->dev, "pwm clock has no frequency\n");
ret = -EINVAL;
ret = dev_err_probe(&pdev->dev,
-EINVAL, "pwm clock has no frequency\n");
goto disable_pwmclk;
}

Expand Down Expand Up @@ -423,7 +421,7 @@ static int lpc18xx_pwm_probe(struct platform_device *pdev)

ret = pwmchip_add(&lpc18xx_pwm->chip);
if (ret < 0) {
dev_err(&pdev->dev, "pwmchip_add failed: %d\n", ret);
dev_err_probe(&pdev->dev, ret, "pwmchip_add failed\n");
goto disable_pwmclk;
}

Expand Down

0 comments on commit 2ba1aed

Please sign in to comment.