[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200811070308.GB2904@bogon.m.sigxcpu.org>
Date: Tue, 11 Aug 2020 09:03:08 +0200
From: Guido Günther <agx@...xcpu.org>
To: Anson Huang <Anson.Huang@....com>
Cc: shawnguo@...nel.org, s.hauer@...gutronix.de, kernel@...gutronix.de,
festevam@...il.com, daniel.baluta@....com,
linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
Linux-imx@....com
Subject: Re: [PATCH] soc: imx: gpcv2: Use dev_err_probe() to simplify error
handling
Hi,
On Tue, Aug 11, 2020 at 11:04:42AM +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>
> ---
> drivers/soc/imx/gpcv2.c | 15 +++++----------
> 1 file changed, 5 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/soc/imx/gpcv2.c b/drivers/soc/imx/gpcv2.c
> index 6cf8a7a..db7e7fc 100644
> --- a/drivers/soc/imx/gpcv2.c
> +++ b/drivers/soc/imx/gpcv2.c
> @@ -487,22 +487,17 @@ static int imx_pgc_domain_probe(struct platform_device *pdev)
>
> domain->regulator = devm_regulator_get_optional(domain->dev, "power");
> if (IS_ERR(domain->regulator)) {
> - if (PTR_ERR(domain->regulator) != -ENODEV) {
> - if (PTR_ERR(domain->regulator) != -EPROBE_DEFER)
> - dev_err(domain->dev, "Failed to get domain's regulator\n");
> - return PTR_ERR(domain->regulator);
> - }
> + if (PTR_ERR(domain->regulator) != -ENODEV)
> + return dev_err_probe(domain->dev, PTR_ERR(domain->regulator),
> + "Failed to get domain's regulator\n");
> } else if (domain->voltage) {
> regulator_set_voltage(domain->regulator,
> domain->voltage, domain->voltage);
> }
>
> ret = imx_pgc_get_clocks(domain);
> - if (ret) {
> - if (ret != -EPROBE_DEFER)
> - dev_err(domain->dev, "Failed to get domain's clocks\n");
> - return ret;
> - }
> + if (ret)
> + return dev_err_probe(domain->dev, ret, "Failed to get domain's clocks\n");
>
> ret = pm_genpd_init(&domain->genpd, NULL, true);
> if (ret) {
Reviewed-by: Guido Günther <agx@...xcpu.org>
-- Guido
> --
> 2.7.4
>
Powered by blists - more mailing lists