All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] mfd: syscon: Switch to use devm_ioremap_resource()
@ 2020-01-10 10:15 Andy Shevchenko
  2020-01-10 10:38 ` Arnd Bergmann
  0 siblings, 1 reply; 3+ messages in thread
From: Andy Shevchenko @ 2020-01-10 10:15 UTC (permalink / raw)
  To: Lee Jones, Arnd Bergmann, linux-kernel; +Cc: Andy Shevchenko

Instead of checking resource pointer for being NULL and
report some not very standard error codes in this case,
switch to devm_ioremap_resource() API.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/mfd/syscon.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c
index 13626bb2d432..fad961b2e4a5 100644
--- a/drivers/mfd/syscon.c
+++ b/drivers/mfd/syscon.c
@@ -238,12 +238,9 @@ static int syscon_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res)
-		return -ENOENT;
-
-	base = devm_ioremap(dev, res->start, resource_size(res));
-	if (!base)
-		return -ENOMEM;
+	base = devm_ioremap_resource(dev, res);
+	if (IS_ERR(base))
+		return PTR_ERR(base);
 
 	syscon_config.max_register = resource_size(res) - 4;
 	if (pdata)
-- 
2.24.1


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

* Re: [PATCH v1] mfd: syscon: Switch to use devm_ioremap_resource()
  2020-01-10 10:15 [PATCH v1] mfd: syscon: Switch to use devm_ioremap_resource() Andy Shevchenko
@ 2020-01-10 10:38 ` Arnd Bergmann
  2020-01-10 12:02   ` Andy Shevchenko
  0 siblings, 1 reply; 3+ messages in thread
From: Arnd Bergmann @ 2020-01-10 10:38 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: Lee Jones, linux-kernel

On Fri, Jan 10, 2020 at 11:15 AM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> Instead of checking resource pointer for being NULL and
> report some not very standard error codes in this case,
> switch to devm_ioremap_resource() API.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

With syscon, I'm worried there are users that map the same region in another
driver, so doing devm_ioremap_resource() here will make another driver fail.

Maybe just change the error code and add a comment warning about that
instead?

      Arnd

> diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c
> index 13626bb2d432..fad961b2e4a5 100644
> --- a/drivers/mfd/syscon.c
> +++ b/drivers/mfd/syscon.c
> @@ -238,12 +238,9 @@ static int syscon_probe(struct platform_device *pdev)
>                 return -ENOMEM;
>
>         res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -       if (!res)
> -               return -ENOENT;
> -
> -       base = devm_ioremap(dev, res->start, resource_size(res));
> -       if (!base)
> -               return -ENOMEM;
> +       base = devm_ioremap_resource(dev, res);
> +       if (IS_ERR(base))
> +               return PTR_ERR(base);

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

* Re: [PATCH v1] mfd: syscon: Switch to use devm_ioremap_resource()
  2020-01-10 10:38 ` Arnd Bergmann
@ 2020-01-10 12:02   ` Andy Shevchenko
  0 siblings, 0 replies; 3+ messages in thread
From: Andy Shevchenko @ 2020-01-10 12:02 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: Andy Shevchenko, Lee Jones, linux-kernel

On Fri, Jan 10, 2020 at 12:40 PM Arnd Bergmann <arnd@arndb.de> wrote:
>
> On Fri, Jan 10, 2020 at 11:15 AM Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
> >
> > Instead of checking resource pointer for being NULL and
> > report some not very standard error codes in this case,
> > switch to devm_ioremap_resource() API.
> >
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
>
> With syscon, I'm worried there are users that map the same region in another
> driver, so doing devm_ioremap_resource() here will make another driver fail.
>
> Maybe just change the error code and add a comment warning about that
> instead?

Oh, yes, you are right.

Thanks for review.

-- 
With Best Regards,
Andy Shevchenko

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

end of thread, other threads:[~2020-01-10 12:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-10 10:15 [PATCH v1] mfd: syscon: Switch to use devm_ioremap_resource() Andy Shevchenko
2020-01-10 10:38 ` Arnd Bergmann
2020-01-10 12:02   ` Andy Shevchenko

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.