[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200811065838.762prkrizjwelod6@pengutronix.de>
Date: Tue, 11 Aug 2020 08:58:38 +0200
From: Uwe Kleine-König <u.kleine-koenig@...gutronix.de>
To: Anson Huang <Anson.Huang@....com>
Cc: thierry.reding@...il.com, lee.jones@...aro.org,
shawnguo@...nel.org, s.hauer@...gutronix.de, kernel@...gutronix.de,
festevam@...il.com, linux-pwm@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
Linux-imx@....com
Subject: Re: [PATCH V2 3/3] pwm: imx1: Use dev_err_probe() to simplify error
handling
On Tue, Aug 11, 2020 at 02:24:32PM +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@....com>
> ---
> changes since V1:
> - remove redundant return value print.
> ---
> drivers/pwm/pwm-imx1.c | 21 ++++++---------------
> 1 file changed, 6 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/pwm/pwm-imx1.c b/drivers/pwm/pwm-imx1.c
> index f8b2c2e..4877734 100644
> --- a/drivers/pwm/pwm-imx1.c
> +++ b/drivers/pwm/pwm-imx1.c
> @@ -145,23 +145,14 @@ static int pwm_imx1_probe(struct platform_device *pdev)
> platform_set_drvdata(pdev, imx);
>
> imx->clk_ipg = devm_clk_get(&pdev->dev, "ipg");
> - if (IS_ERR(imx->clk_ipg)) {
> - dev_err(&pdev->dev, "getting ipg clock failed with %ld\n",
> - PTR_ERR(imx->clk_ipg));
> - return PTR_ERR(imx->clk_ipg);
> - }
> + if (IS_ERR(imx->clk_ipg))
> + return dev_err_probe(&pdev->dev, PTR_ERR(imx->clk_ipg),
> + "getting ipg clock failed\n");
>
> imx->clk_per = devm_clk_get(&pdev->dev, "per");
> - if (IS_ERR(imx->clk_per)) {
> - int ret = PTR_ERR(imx->clk_per);
> -
> - if (ret != -EPROBE_DEFER)
> - dev_err(&pdev->dev,
> - "failed to get peripheral clock: %d\n",
> - ret);
> -
> - return ret;
> - }
> + if (IS_ERR(imx->clk_per))
> + return dev_err_probe(&pdev->dev, PTR_ERR(imx->clk_per),
> + "failed to get peripheral clock\n");
Acked-by: Uwe Kleine-König <u.kleine-koenig@...gutronix.de>
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | https://www.pengutronix.de/ |
Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)
Powered by blists - more mailing lists