[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <b6d01fa02e659db911df63a79d825080f03dfcb8.camel@infinera.com>
Date: Tue, 14 Jan 2020 16:26:18 +0000
From: Joakim Tjernlund <Joakim.Tjernlund@...inera.com>
To: "christophe.leroy@....fr" <christophe.leroy@....fr>,
"broonie@...nel.org" <broonie@...nel.org>
CC: "linux-spi@...r.kernel.org" <linux-spi@...r.kernel.org>,
"linuxppc-dev@...ts.ozlabs.org" <linuxppc-dev@...ts.ozlabs.org>,
"devicetree@...r.kernel.org" <devicetree@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"lkp@...el.com" <lkp@...el.com>,
"geert@...ux-m68k.org" <geert@...ux-m68k.org>
Subject: Re: [PATCH v3] spi: fsl: simplify error path in of_fsl_spi_probe()
On Tue, 2020-01-14 at 16:02 +0000, Christophe Leroy wrote:
> CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.
>
>
> No need to 'goto err;' for just doing a return.
> return directly from where the error happens.
>
> Signed-off-by: Christophe Leroy <christophe.leroy@....fr>
> ---
> v3: rebase on today's spi/for-next and using PTR_ERR_OR_ZERO() in one place.
> ---
> drivers/spi/spi-fsl-spi.c | 27 ++++++++-------------------
> 1 file changed, 8 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/spi/spi-fsl-spi.c b/drivers/spi/spi-fsl-spi.c
> index fb4159ad6bf6..3b81772fea0d 100644
> --- a/drivers/spi/spi-fsl-spi.c
> +++ b/drivers/spi/spi-fsl-spi.c
> @@ -706,8 +706,8 @@ static int of_fsl_spi_probe(struct platform_device *ofdev)
> struct device_node *np = ofdev->dev.of_node;
> struct spi_master *master;
> struct resource mem;
> - int irq = 0, type;
> - int ret = -ENOMEM;
> + int irq, type;
> + int ret;
>
> ret = of_mpc8xxx_spi_probe(ofdev);
> if (ret)
> @@ -722,10 +722,8 @@ static int of_fsl_spi_probe(struct platform_device *ofdev)
>
> if (spisel_boot) {
> pinfo->immr_spi_cs = ioremap(get_immrbase() + IMMR_SPI_CS_OFFSET, 4);
> - if (!pinfo->immr_spi_cs) {
> - ret = -ENOMEM;
> - goto err;
> - }
> + if (!pinfo->immr_spi_cs)
> + return -ENOMEM;
> }
> #endif
> /*
> @@ -744,24 +742,15 @@ static int of_fsl_spi_probe(struct platform_device *ofdev)
>
> ret = of_address_to_resource(np, 0, &mem);
> if (ret)
> - goto err;
> + return ret;
>
> irq = platform_get_irq(ofdev, 0);
> - if (irq < 0) {
> - ret = irq;
> - goto err;
> - }
> + if (irq < 0)
> + return irq;
>
> master = fsl_spi_probe(dev, &mem, irq);
> - if (IS_ERR(master)) {
> - ret = PTR_ERR(master);
> - goto err;
> - }
> -
Don't you need to "undo" ioremap, irq etc. in case of later errors?
> - return 0;
>
> -err:
> - return ret;
> + return PTR_ERR_OR_ZERO(master);
> }
>
> static int of_fsl_spi_remove(struct platform_device *ofdev)
> --
> 2.13.3
>
Powered by blists - more mailing lists