linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] spi: fsl: simplify error path in of_fsl_spi_probe()
@ 2020-01-14 16:02 Christophe Leroy
  2020-01-14 16:09 ` Applied "spi: fsl: simplify error path in of_fsl_spi_probe()" to the spi tree Mark Brown
  2020-01-14 16:26 ` [PATCH v3] spi: fsl: simplify error path in of_fsl_spi_probe() Joakim Tjernlund
  0 siblings, 2 replies; 4+ messages in thread
From: Christophe Leroy @ 2020-01-14 16:02 UTC (permalink / raw)
  To: Mark Brown
  Cc: linux-kernel, linuxppc-dev, linux-spi, devicetree,
	kbuild test robot, Geert Uytterhoeven

No need to 'goto err;' for just doing a return.
return directly from where the error happens.

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.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;
-	}
-
-	return 0;
 
-err:
-	return ret;
+	return PTR_ERR_OR_ZERO(master);
 }
 
 static int of_fsl_spi_remove(struct platform_device *ofdev)
-- 
2.13.3


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Applied "spi: fsl: simplify error path in of_fsl_spi_probe()" to the spi tree
  2020-01-14 16:02 [PATCH v3] spi: fsl: simplify error path in of_fsl_spi_probe() Christophe Leroy
@ 2020-01-14 16:09 ` Mark Brown
  2020-01-14 16:26 ` [PATCH v3] spi: fsl: simplify error path in of_fsl_spi_probe() Joakim Tjernlund
  1 sibling, 0 replies; 4+ messages in thread
From: Mark Brown @ 2020-01-14 16:09 UTC (permalink / raw)
  To: Christophe Leroy
  Cc: devicetree, Geert Uytterhoeven, kbuild test robot, linux-kernel,
	linuxppc-dev, linux-spi, Mark Brown

The patch

   spi: fsl: simplify error path in of_fsl_spi_probe()

has been applied to the spi tree at

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-5.6

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

From 2f3d8035b0f7a8e781b60e0884551dd8a1173a75 Mon Sep 17 00:00:00 2001
From: Christophe Leroy <christophe.leroy@c-s.fr>
Date: Tue, 14 Jan 2020 16:02:40 +0000
Subject: [PATCH] spi: fsl: simplify error path in of_fsl_spi_probe()

No need to 'goto err;' for just doing a return.
return directly from where the error happens.

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
Link: https://lore.kernel.org/r/2a4a7e11b37cfa0558d68f0d35e90d6da858b059.1579017697.git.christophe.leroy@c-s.fr
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 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;
-	}
-
-	return 0;
 
-err:
-	return ret;
+	return PTR_ERR_OR_ZERO(master);
 }
 
 static int of_fsl_spi_remove(struct platform_device *ofdev)
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] spi: fsl: simplify error path in of_fsl_spi_probe()
  2020-01-14 16:02 [PATCH v3] spi: fsl: simplify error path in of_fsl_spi_probe() Christophe Leroy
  2020-01-14 16:09 ` Applied "spi: fsl: simplify error path in of_fsl_spi_probe()" to the spi tree Mark Brown
@ 2020-01-14 16:26 ` Joakim Tjernlund
  2020-01-14 16:57   ` Mark Brown
  1 sibling, 1 reply; 4+ messages in thread
From: Joakim Tjernlund @ 2020-01-14 16:26 UTC (permalink / raw)
  To: christophe.leroy, broonie
  Cc: linux-spi, linuxppc-dev, devicetree, linux-kernel, lkp, geert

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@c-s.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
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] spi: fsl: simplify error path in of_fsl_spi_probe()
  2020-01-14 16:26 ` [PATCH v3] spi: fsl: simplify error path in of_fsl_spi_probe() Joakim Tjernlund
@ 2020-01-14 16:57   ` Mark Brown
  0 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2020-01-14 16:57 UTC (permalink / raw)
  To: Joakim Tjernlund
  Cc: christophe.leroy, linux-spi, linuxppc-dev, devicetree,
	linux-kernel, lkp, geert

[-- Attachment #1: Type: text/plain, Size: 169 bytes --]

On Tue, Jan 14, 2020 at 04:26:18PM +0000, Joakim Tjernlund wrote:

> Don't you need to "undo" ioremap, irq etc. in case of later errors?

Better, convert to devm_ 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-01-14 16:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-14 16:02 [PATCH v3] spi: fsl: simplify error path in of_fsl_spi_probe() Christophe Leroy
2020-01-14 16:09 ` Applied "spi: fsl: simplify error path in of_fsl_spi_probe()" to the spi tree Mark Brown
2020-01-14 16:26 ` [PATCH v3] spi: fsl: simplify error path in of_fsl_spi_probe() Joakim Tjernlund
2020-01-14 16:57   ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).