All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] drivers: gpio: sprd: use devm_platform_ioremap_resource()
       [not found] <AMz4kuKC5haGbhyVJ4gQ6nMRzdaxJnd3SmeCSM-096p7TAp8cA@mail.gmail.com>
@ 2019-03-12  8:08 ` Enrico Weigelt, metux IT consult
  2019-03-12  8:49   ` Baolin Wang
  0 siblings, 1 reply; 3+ messages in thread
From: Enrico Weigelt, metux IT consult @ 2019-03-12  8:08 UTC (permalink / raw)
  To: linux-kernel
  Cc: linus.walleij, bgolaszewski, orsonzhai, baolin.wang, zhang.lyra,
	linux-gpio

Use the new helper that wraps the calls to platform_get_resource()
and devm_ioremap_resource() together.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
---
 drivers/gpio/gpio-eic-sprd.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/gpio/gpio-eic-sprd.c b/drivers/gpio/gpio-eic-sprd.c
index f0223ce..462cdf4 100644
--- a/drivers/gpio/gpio-eic-sprd.c
+++ b/drivers/gpio/gpio-eic-sprd.c
@@ -567,7 +567,6 @@ static int sprd_eic_probe(struct platform_device *pdev)
 	const struct sprd_eic_variant_data *pdata;
 	struct gpio_irq_chip *irq;
 	struct sprd_eic *sprd_eic;
-	struct resource *res;
 	int ret, i;
 
 	pdata = of_device_get_match_data(&pdev->dev);
@@ -596,13 +595,9 @@ static int sprd_eic_probe(struct platform_device *pdev)
 		 * have one bank EIC, thus base[1] and base[2] can be
 		 * optional.
 		 */
-		res = platform_get_resource(pdev, IORESOURCE_MEM, i);
-		if (!res)
-			continue;
-
-		sprd_eic->base[i] = devm_ioremap_resource(&pdev->dev, res);
+		sprd_eic->base[i] = devm_platform_ioremap_resource(pdev, i);
 		if (IS_ERR(sprd_eic->base[i]))
-			return PTR_ERR(sprd_eic->base[i]);
+			continue;
 	}
 
 	sprd_eic->chip.label = sprd_eic_label_name[sprd_eic->type];
-- 
1.9.1

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

* Re: [PATCH v2] drivers: gpio: sprd: use devm_platform_ioremap_resource()
  2019-03-12  8:08 ` [PATCH v2] drivers: gpio: sprd: use devm_platform_ioremap_resource() Enrico Weigelt, metux IT consult
@ 2019-03-12  8:49   ` Baolin Wang
  2019-03-12  9:30     ` Enrico Weigelt, metux IT consult
  0 siblings, 1 reply; 3+ messages in thread
From: Baolin Wang @ 2019-03-12  8:49 UTC (permalink / raw)
  To: Enrico Weigelt, metux IT consult
  Cc: LKML, Linus Walleij, Bartosz Golaszewski, Orson Zhai,
	Chunyan Zhang, open list:GPIO SUBSYSTEM

On Tue, 12 Mar 2019 at 16:08, Enrico Weigelt, metux IT consult
<info@metux.net> wrote:
>
> Use the new helper that wraps the calls to platform_get_resource()
> and devm_ioremap_resource() together.
>
> Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
> ---
>  drivers/gpio/gpio-eic-sprd.c | 9 ++-------
>  1 file changed, 2 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/gpio/gpio-eic-sprd.c b/drivers/gpio/gpio-eic-sprd.c
> index f0223ce..462cdf4 100644
> --- a/drivers/gpio/gpio-eic-sprd.c
> +++ b/drivers/gpio/gpio-eic-sprd.c
> @@ -567,7 +567,6 @@ static int sprd_eic_probe(struct platform_device *pdev)
>         const struct sprd_eic_variant_data *pdata;
>         struct gpio_irq_chip *irq;
>         struct sprd_eic *sprd_eic;
> -       struct resource *res;
>         int ret, i;
>
>         pdata = of_device_get_match_data(&pdev->dev);
> @@ -596,13 +595,9 @@ static int sprd_eic_probe(struct platform_device *pdev)
>                  * have one bank EIC, thus base[1] and base[2] can be
>                  * optional.
>                  */
> -               res = platform_get_resource(pdev, IORESOURCE_MEM, i);
> -               if (!res)
> -                       continue;
> -
> -               sprd_eic->base[i] = devm_ioremap_resource(&pdev->dev, res);
> +               sprd_eic->base[i] = devm_platform_ioremap_resource(pdev, i);
>                 if (IS_ERR(sprd_eic->base[i]))
> -                       return PTR_ERR(sprd_eic->base[i]);
> +                       continue;
>         }

I still do not think the new API is suitable for this case. Since we
can have optional multiple IO resources, so the original code will not
return errors if we did not get the IO resources, but we must cast
errors if we failed to do ioremap. But you ignore the errors of
ioremap, which is not good.

-- 
Baolin Wang
Best Regards

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

* Re: [PATCH v2] drivers: gpio: sprd: use devm_platform_ioremap_resource()
  2019-03-12  8:49   ` Baolin Wang
@ 2019-03-12  9:30     ` Enrico Weigelt, metux IT consult
  0 siblings, 0 replies; 3+ messages in thread
From: Enrico Weigelt, metux IT consult @ 2019-03-12  9:30 UTC (permalink / raw)
  To: Baolin Wang, Enrico Weigelt, metux IT consult
  Cc: LKML, Linus Walleij, Bartosz Golaszewski, Orson Zhai,
	Chunyan Zhang, open list:GPIO SUBSYSTEM

On 12.03.19 09:49, Baolin Wang wrote:

> I still do not think the new API is suitable for this case. Since we
> can have optional multiple IO resources, so the original code will not
> return errors if we did not get the IO resources, but we must cast
> errors if we failed to do ioremap. But you ignore the errors of
> ioremap, which is not good.

hmm, maybe we can differenciate on the error code ?

patch up devm_platform_ioremap_resource() so it returns -ENOENT if
there's no such resource defined. I suppose, ioremap() doesn't have
a valid case for -ENOENT (but haven't checked yet).


--mtx

-- 
Enrico Weigelt, metux IT consult
Free software and Linux embedded engineering
info@metux.net -- +49-151-27565287

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

end of thread, other threads:[~2019-03-12  9:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <AMz4kuKC5haGbhyVJ4gQ6nMRzdaxJnd3SmeCSM-096p7TAp8cA@mail.gmail.com>
2019-03-12  8:08 ` [PATCH v2] drivers: gpio: sprd: use devm_platform_ioremap_resource() Enrico Weigelt, metux IT consult
2019-03-12  8:49   ` Baolin Wang
2019-03-12  9:30     ` Enrico Weigelt, metux IT consult

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.