Skip to contentSkip to conversation

mfd: syscon: Switch to use devm_ioremap_resource()

PATCH In review Andy Shevchenko 3 participants 3 messages Jan 10, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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
index 13626bb2d432..fad961b2e4a5 100644
@@ -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.1
maintainer
#1 lore raw
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.

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

Quoted 17 lines
drivers/mfd/syscon.c +3 -6
index 13626bb2d432..fad961b2e4a5 100644
@@ -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);
#2 lore raw
Quoted 8 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 7 lines
Quoted 1 line

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.

Signature · 2 lines
With Best Regards,
Andy Shevchenko