diff mbox series

[v4] pwm: rockchip: Convert to use dev_err_probe()

Message ID 20220819092627.19416-1-zhaoxiao@uniontech.com
State Superseded
Headers show
Series [v4] pwm: rockchip: Convert to use dev_err_probe() | expand

Commit Message

zhaoxiao Aug. 19, 2022, 9:26 a.m. UTC
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@uniontech.com>
---
 v4: add the missing dev_err function.
 drivers/pwm/pwm-rockchip.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

Comments

Christophe JAILLET Aug. 22, 2022, 7:29 a.m. UTC | #1
Le 19/08/2022 à 11:26, 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().

Hi, just a last comment below.

> 
> Signed-off-by: zhaoxiao <zhaoxiao@uniontech.com>
> ---
>   v4: add the missing dev_err function.
>   drivers/pwm/pwm-rockchip.c | 18 ++++++------------
>   1 file changed, 6 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/pwm/pwm-rockchip.c b/drivers/pwm/pwm-rockchip.c
> index f3647b317152..e6ee14c6a159 100644
> --- a/drivers/pwm/pwm-rockchip.c
> +++ b/drivers/pwm/pwm-rockchip.c
> @@ -328,22 +328,16 @@ static int rockchip_pwm_probe(struct platform_device *pdev)
>   	else
>   		pc->pclk = pc->clk;
>   
> -	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;
> -	}
> +	if (IS_ERR(pc->pclk))
> +		return dev_err_probe(&pdev->dev, PTR_ERR(pc->pclk), "Can't get APB clk\n");
>   
>   	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)
> +		return dev_err_probe(&pdev->dev, ret, "Can't prepare enable PWM clk\n");
>   
>   	ret = clk_prepare_enable(pc->pclk);
>   	if (ret) {
> -		dev_err(&pdev->dev, "Can't prepare enable APB clk: %d\n", ret);
> +		dev_err_probe(&pdev->dev, ret, "Can't prepare enable APB clk: %d\n", ret);

As in the previous patches, %d and the final ret are not needed. 
dev_err_probe() will already display an error code in a human readable way.

>   		goto err_clk;
>   	}
>   
> @@ -360,7 +354,7 @@ static int rockchip_pwm_probe(struct platform_device *pdev)
>   
>   	ret = pwmchip_add(&pc->chip);
>   	if (ret < 0) {
> -		dev_err(&pdev->dev, "pwmchip_add() failed: %d\n", ret);
> +		dev_err_probe(&pdev->dev, ret, "pwmchip_add() failed: %d\n", ret);

Same here.

Otherwise, LGTM.

CJ

>   		goto err_pclk;
>   	}
>
diff mbox series

Patch

diff --git a/drivers/pwm/pwm-rockchip.c b/drivers/pwm/pwm-rockchip.c
index f3647b317152..e6ee14c6a159 100644
--- a/drivers/pwm/pwm-rockchip.c
+++ b/drivers/pwm/pwm-rockchip.c
@@ -328,22 +328,16 @@  static int rockchip_pwm_probe(struct platform_device *pdev)
 	else
 		pc->pclk = pc->clk;
 
-	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;
-	}
+	if (IS_ERR(pc->pclk))
+		return dev_err_probe(&pdev->dev, PTR_ERR(pc->pclk), "Can't get APB clk\n");
 
 	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)
+		return dev_err_probe(&pdev->dev, ret, "Can't prepare enable PWM clk\n");
 
 	ret = clk_prepare_enable(pc->pclk);
 	if (ret) {
-		dev_err(&pdev->dev, "Can't prepare enable APB clk: %d\n", ret);
+		dev_err_probe(&pdev->dev, ret, "Can't prepare enable APB clk: %d\n", ret);
 		goto err_clk;
 	}
 
@@ -360,7 +354,7 @@  static int rockchip_pwm_probe(struct platform_device *pdev)
 
 	ret = pwmchip_add(&pc->chip);
 	if (ret < 0) {
-		dev_err(&pdev->dev, "pwmchip_add() failed: %d\n", ret);
+		dev_err_probe(&pdev->dev, ret, "pwmchip_add() failed: %d\n", ret);
 		goto err_pclk;
 	}