* [PATCH v1 1/2] mfd: syscon: Re-use resource_size() to count max_register
@ 2019-11-15 8:49 Andy Shevchenko
2019-11-15 8:49 ` [PATCH v1 2/2] mfd: syscon: Switch to use devm_ioremap_resource() Andy Shevchenko
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Andy Shevchenko @ 2019-11-15 8:49 UTC (permalink / raw)
To: Lee Jones, Arnd Bergmann, linux-kernel; +Cc: Andy Shevchenko
Instead of open coded variant use resource_size() and replace
weird '- 3' to more understandable '- 4'.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/mfd/syscon.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c
index e22197c832e8..13626bb2d432 100644
--- a/drivers/mfd/syscon.c
+++ b/drivers/mfd/syscon.c
@@ -245,7 +245,7 @@ static int syscon_probe(struct platform_device *pdev)
if (!base)
return -ENOMEM;
- syscon_config.max_register = res->end - res->start - 3;
+ syscon_config.max_register = resource_size(res) - 4;
if (pdata)
syscon_config.name = pdata->label;
syscon->regmap = devm_regmap_init_mmio(dev, base, &syscon_config);
--
2.24.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v1 2/2] mfd: syscon: Switch to use devm_ioremap_resource()
2019-11-15 8:49 [PATCH v1 1/2] mfd: syscon: Re-use resource_size() to count max_register Andy Shevchenko
@ 2019-11-15 8:49 ` Andy Shevchenko
2019-11-15 9:12 ` Arnd Bergmann
2019-11-15 9:10 ` [PATCH v1 1/2] mfd: syscon: Re-use resource_size() to count max_register Arnd Bergmann
2019-12-09 8:45 ` Lee Jones
2 siblings, 1 reply; 6+ messages in thread
From: Andy Shevchenko @ 2019-11-15 8:49 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.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v1 1/2] mfd: syscon: Re-use resource_size() to count max_register
2019-11-15 8:49 [PATCH v1 1/2] mfd: syscon: Re-use resource_size() to count max_register Andy Shevchenko
2019-11-15 8:49 ` [PATCH v1 2/2] mfd: syscon: Switch to use devm_ioremap_resource() Andy Shevchenko
@ 2019-11-15 9:10 ` Arnd Bergmann
2019-12-09 8:45 ` Lee Jones
2 siblings, 0 replies; 6+ messages in thread
From: Arnd Bergmann @ 2019-11-15 9:10 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: Lee Jones, linux-kernel
On Fri, Nov 15, 2019 at 9:49 AM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> Instead of open coded variant use resource_size() and replace
> weird '- 3' to more understandable '- 4'.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
Acked-by: Arnd Bergmann <arnd@arndb.de>
> drivers/mfd/syscon.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c
> index e22197c832e8..13626bb2d432 100644
> --- a/drivers/mfd/syscon.c
> +++ b/drivers/mfd/syscon.c
> @@ -245,7 +245,7 @@ static int syscon_probe(struct platform_device *pdev)
> if (!base)
> return -ENOMEM;
>
> - syscon_config.max_register = res->end - res->start - 3;
> + syscon_config.max_register = resource_size(res) - 4;
> if (pdata)
> syscon_config.name = pdata->label;
> syscon->regmap = devm_regmap_init_mmio(dev, base, &syscon_config);
> --
> 2.24.0
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v1 2/2] mfd: syscon: Switch to use devm_ioremap_resource()
2019-11-15 8:49 ` [PATCH v1 2/2] mfd: syscon: Switch to use devm_ioremap_resource() Andy Shevchenko
@ 2019-11-15 9:12 ` Arnd Bergmann
2019-11-15 10:20 ` Andy Shevchenko
0 siblings, 1 reply; 6+ messages in thread
From: Arnd Bergmann @ 2019-11-15 9:12 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: Lee Jones, linux-kernel
On Fri, Nov 15, 2019 at 9:49 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>
IIRC there are some slightly odd uses of syscon that rely on on us not calling
devm_request_mem_region here, which is implied by devm_ioremap_resource()
but not devm_ioremap().
A patch to add a comment about this might be helpful though.
Arnd
> ---
> 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.0
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v1 2/2] mfd: syscon: Switch to use devm_ioremap_resource()
2019-11-15 9:12 ` Arnd Bergmann
@ 2019-11-15 10:20 ` Andy Shevchenko
0 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2019-11-15 10:20 UTC (permalink / raw)
To: Arnd Bergmann; +Cc: Lee Jones, linux-kernel
On Fri, Nov 15, 2019 at 10:12:57AM +0100, Arnd Bergmann wrote:
> On Fri, Nov 15, 2019 at 9:49 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>
>
> IIRC there are some slightly odd uses of syscon that rely on on us not calling
> devm_request_mem_region here, which is implied by devm_ioremap_resource()
> but not devm_ioremap().
Ah, I see.
> A patch to add a comment about this might be helpful though.
I think the comment won't help if there are overlapping regions are in use.
Probably no need to apply this for now.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v1 1/2] mfd: syscon: Re-use resource_size() to count max_register
2019-11-15 8:49 [PATCH v1 1/2] mfd: syscon: Re-use resource_size() to count max_register Andy Shevchenko
2019-11-15 8:49 ` [PATCH v1 2/2] mfd: syscon: Switch to use devm_ioremap_resource() Andy Shevchenko
2019-11-15 9:10 ` [PATCH v1 1/2] mfd: syscon: Re-use resource_size() to count max_register Arnd Bergmann
@ 2019-12-09 8:45 ` Lee Jones
2 siblings, 0 replies; 6+ messages in thread
From: Lee Jones @ 2019-12-09 8:45 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: Arnd Bergmann, linux-kernel
On Fri, 15 Nov 2019, Andy Shevchenko wrote:
> Instead of open coded variant use resource_size() and replace
> weird '- 3' to more understandable '- 4'.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
> drivers/mfd/syscon.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Applied, thanks.
--
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2019-12-09 8:45 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-15 8:49 [PATCH v1 1/2] mfd: syscon: Re-use resource_size() to count max_register Andy Shevchenko
2019-11-15 8:49 ` [PATCH v1 2/2] mfd: syscon: Switch to use devm_ioremap_resource() Andy Shevchenko
2019-11-15 9:12 ` Arnd Bergmann
2019-11-15 10:20 ` Andy Shevchenko
2019-11-15 9:10 ` [PATCH v1 1/2] mfd: syscon: Re-use resource_size() to count max_register Arnd Bergmann
2019-12-09 8:45 ` Lee Jones
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.