mfd: syscon: Re-use resource_size() to count max_register
Subsystems (2)
PATCH 1/2 mfd: syscon: Re-use resource_size() to count max_register
Instead of open coded variant use resource_size() and replace weird '- 3' to more understandable '- 4'.
--- drivers/mfd/syscon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mfd/syscon.c +1 -1
@@ -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);
Signature · 1 line
2.24.0
PATCH 2/2 mfd: syscon: Switch to use devm_ioremap_resource()
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.
--- drivers/mfd/syscon.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/mfd/syscon.c +3 -6
@@ -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)
Signature · 1 line
2.24.0
Arnd Bergmann
maintainerRe: [PATCH v1 2/2] mfd: syscon: Switch to use devm_ioremap_resource()
Quoted 6 lines · 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 <[email protected]>
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
Quoted 27 lines
--- drivers/mfd/syscon.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)drivers/mfd/syscon.c +3
-7@@ -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
Re: [PATCH v1 2/2] mfd: syscon: Switch to use devm_ioremap_resource()
Quoted 7 lines · Arnd Bergmann
Quoted 5 lines · 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.
Quoted 5 lines
Quoted 1 line
Signed-off-by Andy Shevchenko <[email protected]>IIRC there are some slightly odd uses of syscon that rely on on us not calling
devm_request_mem_regionhere, which is implied bydevm_ioremap_resource()but notdevm_ioremap().
Ah, I see.
Quoted 1 line
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.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 6 lines · Andy Shevchenko
Instead of open coded variant use
resource_size()and replace weird '- 3' to more understandable '- 4'.Signed-off-by Andy Shevchenko <[email protected]>---
Quoted 19 lines
drivers/mfd/syscon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/mfd/syscon.c +1
-2@@ -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
Lee Jones
AppliedQuoted 7 lines · Andy Shevchenko
Instead of open coded variant use
resource_size()and replace weird '- 3' to more understandable '- 4'.Signed-off-by Andy Shevchenko <[email protected]>--- drivers/mfd/syscon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Applied, thanks.
Signature · 4 lines
Lee Jones [李琼斯] Linaro Services Technical Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog