diff mbox series

[V2,1/3] pwm: imx-tpm: Use dev_err_probe() to simplify error handling

Message ID 1597127072-26365-1-git-send-email-Anson.Huang@nxp.com (mailing list archive)
State New, archived
Headers show
Series [V2,1/3] pwm: imx-tpm: Use dev_err_probe() to simplify error handling | expand

Commit Message

Anson Huang Aug. 11, 2020, 6:24 a.m. UTC
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 <Anson.Huang@nxp.com>
---
changes since V1:
	- remove redundant return value print.
---
 drivers/pwm/pwm-imx-tpm.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

Comments

Lee Jones Aug. 11, 2020, 6:37 a.m. UTC | #1
On Tue, 11 Aug 2020, Anson Huang wrote:

> 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 <Anson.Huang@nxp.com>
> ---
> changes since V1:
> 	- remove redundant return value print.
> ---
>  drivers/pwm/pwm-imx-tpm.c | 10 +++-------
>  1 file changed, 3 insertions(+), 7 deletions(-)

Acked-by: Lee Jones <lee.jones@linaro.org>
Uwe Kleine-König Aug. 11, 2020, 7 a.m. UTC | #2
On Tue, Aug 11, 2020 at 02:24:30PM +0800, Anson Huang wrote:
> 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 <Anson.Huang@nxp.com>

Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

Thanks
Uwe
Anson Huang Sept. 17, 2020, 6:37 a.m. UTC | #3
Gentle ping...

> Subject: [PATCH V2 1/3] pwm: imx-tpm: 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.
> 
> Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
> ---
> changes since V1:
> 	- remove redundant return value print.
> ---
>  drivers/pwm/pwm-imx-tpm.c | 10 +++-------
>  1 file changed, 3 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/pwm/pwm-imx-tpm.c b/drivers/pwm/pwm-imx-tpm.c index
> fcdf6be..aaf629b 100644
> --- a/drivers/pwm/pwm-imx-tpm.c
> +++ b/drivers/pwm/pwm-imx-tpm.c
> @@ -350,13 +350,9 @@ static int pwm_imx_tpm_probe(struct
> platform_device *pdev)
>  		return PTR_ERR(tpm->base);
> 
>  	tpm->clk = devm_clk_get(&pdev->dev, NULL);
> -	if (IS_ERR(tpm->clk)) {
> -		ret = PTR_ERR(tpm->clk);
> -		if (ret != -EPROBE_DEFER)
> -			dev_err(&pdev->dev,
> -				"failed to get PWM clock: %d\n", ret);
> -		return ret;
> -	}
> +	if (IS_ERR(tpm->clk))
> +		return dev_err_probe(&pdev->dev, PTR_ERR(tpm->clk),
> +				     "failed to get PWM clock\n");
> 
>  	ret = clk_prepare_enable(tpm->clk);
>  	if (ret) {
> --
> 2.7.4
Thierry Reding Nov. 11, 2020, 6:05 p.m. UTC | #4
On Tue, Aug 11, 2020 at 02:24:30PM +0800, Anson Huang wrote:
> 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 <Anson.Huang@nxp.com>
> ---
> changes since V1:
> 	- remove redundant return value print.
> ---
>  drivers/pwm/pwm-imx-tpm.c | 10 +++-------
>  1 file changed, 3 insertions(+), 7 deletions(-)

All three patches applied, thanks.

Thierry
diff mbox series

Patch

diff --git a/drivers/pwm/pwm-imx-tpm.c b/drivers/pwm/pwm-imx-tpm.c
index fcdf6be..aaf629b 100644
--- a/drivers/pwm/pwm-imx-tpm.c
+++ b/drivers/pwm/pwm-imx-tpm.c
@@ -350,13 +350,9 @@  static int pwm_imx_tpm_probe(struct platform_device *pdev)
 		return PTR_ERR(tpm->base);
 
 	tpm->clk = devm_clk_get(&pdev->dev, NULL);
-	if (IS_ERR(tpm->clk)) {
-		ret = PTR_ERR(tpm->clk);
-		if (ret != -EPROBE_DEFER)
-			dev_err(&pdev->dev,
-				"failed to get PWM clock: %d\n", ret);
-		return ret;
-	}
+	if (IS_ERR(tpm->clk))
+		return dev_err_probe(&pdev->dev, PTR_ERR(tpm->clk),
+				     "failed to get PWM clock\n");
 
 	ret = clk_prepare_enable(tpm->clk);
 	if (ret) {