[PATCH v2] pwm: rockchip: Convert to use dev_err_probe()
Christophe JAILLET
christophe.jaillet at wanadoo.fr
Thu Aug 18 13:14:49 PDT 2022
Le 18/08/2022 à 09:55, zhaoxiao a écrit :
> It's fine to call dev_err_probe() in ->probe() when error code is known.
> Convert the driver to use dev_err_probe().
>
> Signed-off-by: zhaoxiao <zhaoxiao at uniontech.com>
> ---
> v2: remove the %d in the message.
Hi,
You did more than that.
>
> drivers/pwm/pwm-rockchip.c | 10 +++-------
> 1 file changed, 3 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/pwm/pwm-rockchip.c b/drivers/pwm/pwm-rockchip.c
> index f3647b317152..c6e088c1a6bf 100644
> --- a/drivers/pwm/pwm-rockchip.c
> +++ b/drivers/pwm/pwm-rockchip.c
> @@ -330,16 +330,12 @@ static int rockchip_pwm_probe(struct platform_device *pdev)
>
> if (IS_ERR(pc->pclk)) {
> ret = PTR_ERR(pc->pclk);
> - if (ret != -EPROBE_DEFER)
> - dev_err(&pdev->dev, "Can't get APB clk: %d\n", ret);
> - return ret;
> + return dev_err_probe(&pdev->dev, ret, "Can't get APB clk\n");
> }
You could use PTR_ERR(pc->pclk) directly. There is no need to assign it
to 'ret'. This would simplify even further the code. ({} can be removed)
>
> ret = clk_prepare_enable(pc->clk);
> - if (ret) {
> - dev_err(&pdev->dev, "Can't prepare enable PWM clk: %d\n", ret);
> - return ret;
> - }
> + if (ret)
> + dev_err_probe(&pdev->dev, ret, "Can't prepare enable PWM clk\n");
Is a 'return' before dev_err_probe() missing?
Before we were returning the error code, now we ignore it and continue.
If done on purpose, you should explain why in the commit log.
>
> ret = clk_prepare_enable(pc->pclk);
> if (ret) {
Why just converting 2 dev_err() and leaving the other one in the probe
untouched?
CJ
More information about the Linux-rockchip
mailing list