diff mbox

[RFC,020/111] staging: etnaviv: use devm_ioremap_resource()

Message ID 1427988653-754-21-git-send-email-l.stach@pengutronix.de (mailing list archive)
State New, archived
Headers show

Commit Message

Lucas Stach April 2, 2015, 3:29 p.m. UTC
From: Russell King <rmk+kernel@arm.linux.org.uk>

Use devm_ioremap_resource() rather than devm_ioremap_nocache() when
remapping resources.  devm_ioremap_resource() is the preferred interface
for this, and is less error-prone than the older devm_ioremap_nocache().

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
 drivers/staging/etnaviv/etnaviv_drv.c | 20 +++++++-------------
 1 file changed, 7 insertions(+), 13 deletions(-)
diff mbox

Patch

diff --git a/drivers/staging/etnaviv/etnaviv_drv.c b/drivers/staging/etnaviv/etnaviv_drv.c
index 863f9d6a0174..7b4999c78417 100644
--- a/drivers/staging/etnaviv/etnaviv_drv.c
+++ b/drivers/staging/etnaviv/etnaviv_drv.c
@@ -39,7 +39,6 @@  void __iomem *etnaviv_ioremap(struct platform_device *pdev, const char *name,
 		const char *dbgname)
 {
 	struct resource *res;
-	unsigned long size;
 	void __iomem *ptr;
 
 	if (name)
@@ -47,21 +46,16 @@  void __iomem *etnaviv_ioremap(struct platform_device *pdev, const char *name,
 	else
 		res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 
-	if (!res) {
-		dev_err(&pdev->dev, "failed to get memory resource: %s\n", name);
-		return ERR_PTR(-EINVAL);
-	}
-
-	size = resource_size(res);
-
-	ptr = devm_ioremap_nocache(&pdev->dev, res->start, size);
-	if (!ptr) {
-		dev_err(&pdev->dev, "failed to ioremap: %s\n", name);
-		return ERR_PTR(-ENOMEM);
+	ptr = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(ptr)) {
+		dev_err(&pdev->dev, "failed to ioremap %s: %ld\n", name,
+			PTR_ERR(ptr));
+		return ptr;
 	}
 
 	if (reglog)
-		printk(KERN_DEBUG "IO:region %s %08x %08lx\n", dbgname, (u32)ptr, size);
+		dev_printk(KERN_DEBUG, &pdev->dev, "IO:region %s 0x%p %08zx\n",
+			   dbgname, ptr, (size_t)resource_size(res));
 
 	return ptr;
 }