linux-renesas-soc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] gpio: em: Miscellaneous probe cleanups
@ 2019-05-27 12:40 Geert Uytterhoeven
  2019-05-27 12:40 ` [PATCH 1/2] gpio: em: Remove error messages on out-of-memory conditions Geert Uytterhoeven
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Geert Uytterhoeven @ 2019-05-27 12:40 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski
  Cc: Niklas Söderlund, linux-gpio, linux-renesas-soc, Geert Uytterhoeven

	Hi Linus, Bartosz,

This small series contains two cleanups for the GPIO driver for the
venerable Renesas EMMA Mobile EV2 SoC.

These are compile-tested only, due to lack of hardware.

Thanks!

Geert Uytterhoeven (2):
  gpio: em: Remove error messages on out-of-memory conditions
  gpio: em: Return early on error in em_gio_probe()

 drivers/gpio/gpio-em.c | 30 +++++++++---------------------
 1 file changed, 9 insertions(+), 21 deletions(-)

-- 
2.17.1

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds

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

* [PATCH 1/2] gpio: em: Remove error messages on out-of-memory conditions
  2019-05-27 12:40 [PATCH 0/2] gpio: em: Miscellaneous probe cleanups Geert Uytterhoeven
@ 2019-05-27 12:40 ` Geert Uytterhoeven
  2019-06-01 17:47   ` Linus Walleij
  2019-05-27 12:40 ` [PATCH 2/2] gpio: em: Return early on error in em_gio_probe() Geert Uytterhoeven
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 7+ messages in thread
From: Geert Uytterhoeven @ 2019-05-27 12:40 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski
  Cc: Niklas Söderlund, linux-gpio, linux-renesas-soc, Geert Uytterhoeven

There is no need to print error messages when memory allocations or
related operations fail, as the core will take care of that.

Change the returned error codes to -ENOMEM to match the failure cause
while at it.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
 drivers/gpio/gpio-em.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/gpio/gpio-em.c b/drivers/gpio/gpio-em.c
index 982e699a5b816582..18937a9b1a14a72c 100644
--- a/drivers/gpio/gpio-em.c
+++ b/drivers/gpio/gpio-em.c
@@ -305,16 +305,14 @@ static int em_gio_probe(struct platform_device *pdev)
 	p->base0 = devm_ioremap_nocache(&pdev->dev, io[0]->start,
 					resource_size(io[0]));
 	if (!p->base0) {
-		dev_err(&pdev->dev, "failed to remap low I/O memory\n");
-		ret = -ENXIO;
+		ret = -ENOMEM;
 		goto err0;
 	}
 
 	p->base1 = devm_ioremap_nocache(&pdev->dev, io[1]->start,
 				   resource_size(io[1]));
 	if (!p->base1) {
-		dev_err(&pdev->dev, "failed to remap high I/O memory\n");
-		ret = -ENXIO;
+		ret = -ENOMEM;
 		goto err0;
 	}
 
-- 
2.17.1


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

* [PATCH 2/2] gpio: em: Return early on error in em_gio_probe()
  2019-05-27 12:40 [PATCH 0/2] gpio: em: Miscellaneous probe cleanups Geert Uytterhoeven
  2019-05-27 12:40 ` [PATCH 1/2] gpio: em: Remove error messages on out-of-memory conditions Geert Uytterhoeven
@ 2019-05-27 12:40 ` Geert Uytterhoeven
  2019-06-01 17:48   ` Linus Walleij
  2019-05-28 15:47 ` [PATCH 0/2] gpio: em: Miscellaneous probe cleanups Bartosz Golaszewski
  2019-06-02 21:15 ` Linus Walleij
  3 siblings, 1 reply; 7+ messages in thread
From: Geert Uytterhoeven @ 2019-05-27 12:40 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski
  Cc: Niklas Söderlund, linux-gpio, linux-renesas-soc, Geert Uytterhoeven

em_gio_probe() uses managed initializations for everything but creating
the IRQ domain.  Hence in most failure cases, no cleanup needs to be
performed at all.

Make this clearer for the casual reviewer by returning early, instead of
jumping to an out-of-sight label.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
 drivers/gpio/gpio-em.c | 28 +++++++++-------------------
 1 file changed, 9 insertions(+), 19 deletions(-)

diff --git a/drivers/gpio/gpio-em.c b/drivers/gpio/gpio-em.c
index 18937a9b1a14a72c..40f8c38bec1c24af 100644
--- a/drivers/gpio/gpio-em.c
+++ b/drivers/gpio/gpio-em.c
@@ -282,10 +282,8 @@ static int em_gio_probe(struct platform_device *pdev)
 	int ret;
 
 	p = devm_kzalloc(&pdev->dev, sizeof(*p), GFP_KERNEL);
-	if (!p) {
-		ret = -ENOMEM;
-		goto err0;
-	}
+	if (!p)
+		return -ENOMEM;
 
 	p->pdev = pdev;
 	platform_set_drvdata(pdev, p);
@@ -298,28 +296,22 @@ static int em_gio_probe(struct platform_device *pdev)
 
 	if (!io[0] || !io[1] || !irq[0] || !irq[1]) {
 		dev_err(&pdev->dev, "missing IRQ or IOMEM\n");
-		ret = -EINVAL;
-		goto err0;
+		return -EINVAL;
 	}
 
 	p->base0 = devm_ioremap_nocache(&pdev->dev, io[0]->start,
 					resource_size(io[0]));
-	if (!p->base0) {
-		ret = -ENOMEM;
-		goto err0;
-	}
+	if (!p->base0)
+		return -ENOMEM;
 
 	p->base1 = devm_ioremap_nocache(&pdev->dev, io[1]->start,
 				   resource_size(io[1]));
-	if (!p->base1) {
-		ret = -ENOMEM;
-		goto err0;
-	}
+	if (!p->base1)
+		return -ENOMEM;
 
 	if (of_property_read_u32(pdev->dev.of_node, "ngpios", &ngpios)) {
 		dev_err(&pdev->dev, "Missing ngpios OF property\n");
-		ret = -EINVAL;
-		goto err0;
+		return -EINVAL;
 	}
 
 	gpio_chip = &p->gpio_chip;
@@ -349,9 +341,8 @@ static int em_gio_probe(struct platform_device *pdev)
 	p->irq_domain = irq_domain_add_simple(pdev->dev.of_node, ngpios, 0,
 					      &em_gio_irq_domain_ops, p);
 	if (!p->irq_domain) {
-		ret = -ENXIO;
 		dev_err(&pdev->dev, "cannot initialize irq domain\n");
-		goto err0;
+		return -ENXIO;
 	}
 
 	if (devm_request_irq(&pdev->dev, irq[0]->start,
@@ -378,7 +369,6 @@ static int em_gio_probe(struct platform_device *pdev)
 
 err1:
 	irq_domain_remove(p->irq_domain);
-err0:
 	return ret;
 }
 
-- 
2.17.1


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

* Re: [PATCH 0/2] gpio: em: Miscellaneous probe cleanups
  2019-05-27 12:40 [PATCH 0/2] gpio: em: Miscellaneous probe cleanups Geert Uytterhoeven
  2019-05-27 12:40 ` [PATCH 1/2] gpio: em: Remove error messages on out-of-memory conditions Geert Uytterhoeven
  2019-05-27 12:40 ` [PATCH 2/2] gpio: em: Return early on error in em_gio_probe() Geert Uytterhoeven
@ 2019-05-28 15:47 ` Bartosz Golaszewski
  2019-06-02 21:15 ` Linus Walleij
  3 siblings, 0 replies; 7+ messages in thread
From: Bartosz Golaszewski @ 2019-05-28 15:47 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Linus Walleij, Niklas Söderlund, linux-gpio, Linux-Renesas

pon., 27 maj 2019 o 14:40 Geert Uytterhoeven <geert+renesas@glider.be>
napisał(a):
>
>         Hi Linus, Bartosz,
>
> This small series contains two cleanups for the GPIO driver for the
> venerable Renesas EMMA Mobile EV2 SoC.
>
> These are compile-tested only, due to lack of hardware.
>
> Thanks!
>
> Geert Uytterhoeven (2):
>   gpio: em: Remove error messages on out-of-memory conditions
>   gpio: em: Return early on error in em_gio_probe()
>
>  drivers/gpio/gpio-em.c | 30 +++++++++---------------------
>  1 file changed, 9 insertions(+), 21 deletions(-)
>
> --
> 2.17.1
>
> Gr{oetje,eeting}s,
>
>                                                 Geert
>
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
>
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
>                                                             -- Linus Torvalds

Hi Geert,

applied both and also sent a follow-up that makes this driver use the
managed variant of gpiochip_add_data().

Bart

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

* Re: [PATCH 1/2] gpio: em: Remove error messages on out-of-memory conditions
  2019-05-27 12:40 ` [PATCH 1/2] gpio: em: Remove error messages on out-of-memory conditions Geert Uytterhoeven
@ 2019-06-01 17:47   ` Linus Walleij
  0 siblings, 0 replies; 7+ messages in thread
From: Linus Walleij @ 2019-06-01 17:47 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Bartosz Golaszewski, Niklas Söderlund,
	open list:GPIO SUBSYSTEM, Linux-Renesas

On Mon, May 27, 2019 at 2:40 PM Geert Uytterhoeven
<geert+renesas@glider.be> wrote:

> There is no need to print error messages when memory allocations or
> related operations fail, as the core will take care of that.
>
> Change the returned error codes to -ENOMEM to match the failure cause
> while at it.
>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>

Patch applied.

Yours,
Linus Walleij

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

* Re: [PATCH 2/2] gpio: em: Return early on error in em_gio_probe()
  2019-05-27 12:40 ` [PATCH 2/2] gpio: em: Return early on error in em_gio_probe() Geert Uytterhoeven
@ 2019-06-01 17:48   ` Linus Walleij
  0 siblings, 0 replies; 7+ messages in thread
From: Linus Walleij @ 2019-06-01 17:48 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Bartosz Golaszewski, Niklas Söderlund,
	open list:GPIO SUBSYSTEM, Linux-Renesas

On Mon, May 27, 2019 at 2:40 PM Geert Uytterhoeven
<geert+renesas@glider.be> wrote:

> em_gio_probe() uses managed initializations for everything but creating
> the IRQ domain.  Hence in most failure cases, no cleanup needs to be
> performed at all.
>
> Make this clearer for the casual reviewer by returning early, instead of
> jumping to an out-of-sight label.
>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>

Patch applied.

Yours,
Linus Walleij

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

* Re: [PATCH 0/2] gpio: em: Miscellaneous probe cleanups
  2019-05-27 12:40 [PATCH 0/2] gpio: em: Miscellaneous probe cleanups Geert Uytterhoeven
                   ` (2 preceding siblings ...)
  2019-05-28 15:47 ` [PATCH 0/2] gpio: em: Miscellaneous probe cleanups Bartosz Golaszewski
@ 2019-06-02 21:15 ` Linus Walleij
  3 siblings, 0 replies; 7+ messages in thread
From: Linus Walleij @ 2019-06-02 21:15 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Bartosz Golaszewski, Niklas Söderlund,
	open list:GPIO SUBSYSTEM, Linux-Renesas

On Mon, May 27, 2019 at 2:40 PM Geert Uytterhoeven
<geert+renesas@glider.be> wrote:

> This small series contains two cleanups for the GPIO driver for the
> venerable Renesas EMMA Mobile EV2 SoC.

Ooops I missed that Bartosz already applied these, took them
out of my tree again and wait for his pull request instead.

Yours,
Linus Walleij

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

end of thread, other threads:[~2019-06-02 21:16 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-27 12:40 [PATCH 0/2] gpio: em: Miscellaneous probe cleanups Geert Uytterhoeven
2019-05-27 12:40 ` [PATCH 1/2] gpio: em: Remove error messages on out-of-memory conditions Geert Uytterhoeven
2019-06-01 17:47   ` Linus Walleij
2019-05-27 12:40 ` [PATCH 2/2] gpio: em: Return early on error in em_gio_probe() Geert Uytterhoeven
2019-06-01 17:48   ` Linus Walleij
2019-05-28 15:47 ` [PATCH 0/2] gpio: em: Miscellaneous probe cleanups Bartosz Golaszewski
2019-06-02 21:15 ` Linus Walleij

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).