diff mbox series

[v2] gpio: mmio: use devm_platform_ioremap_resource_byname()

Message ID 1581936521-2982-1-git-send-email-qiwuchen55@gmail.com
State New
Headers show
Series [v2] gpio: mmio: use devm_platform_ioremap_resource_byname() | expand

Commit Message

qiwuchen55@gmail.com Feb. 17, 2020, 10:48 a.m. UTC
From: chenqiwu <chenqiwu@xiaomi.com>

Use devm_platform_ioremap_resource_byname() instead of calling
platform_get_resource_byname() and devm_ioremap_resource()
separately to simplify code.

Signed-off-by: chenqiwu <chenqiwu@xiaomi.com>
---
changes in v2:
 - remove bgpio_map() entirely.
---
 drivers/gpio/gpio-mmio.c | 28 +++++-----------------------
 1 file changed, 5 insertions(+), 23 deletions(-)
diff mbox series

Patch

diff --git a/drivers/gpio/gpio-mmio.c b/drivers/gpio/gpio-mmio.c
index f729e3e..b7170d6 100644
--- a/drivers/gpio/gpio-mmio.c
+++ b/drivers/gpio/gpio-mmio.c
@@ -654,24 +654,6 @@  int bgpio_init(struct gpio_chip *gc, struct device *dev,
 
 #if IS_ENABLED(CONFIG_GPIO_GENERIC_PLATFORM)
 
-static void __iomem *bgpio_map(struct platform_device *pdev,
-			       const char *name,
-			       resource_size_t sane_sz)
-{
-	struct resource *r;
-	resource_size_t sz;
-
-	r = platform_get_resource_byname(pdev, IORESOURCE_MEM, name);
-	if (!r)
-		return NULL;
-
-	sz = resource_size(r);
-	if (sz != sane_sz)
-		return IOMEM_ERR_PTR(-EINVAL);
-
-	return devm_ioremap_resource(&pdev->dev, r);
-}
-
 #ifdef CONFIG_OF
 static const struct of_device_id bgpio_of_match[] = {
 	{ .compatible = "brcm,bcm6345-gpio" },
@@ -742,23 +724,23 @@  static int bgpio_pdev_probe(struct platform_device *pdev)
 
 	sz = resource_size(r);
 
-	dat = bgpio_map(pdev, "dat", sz);
+	dat = devm_platform_ioremap_resource_byname(pdev, "dat");
 	if (IS_ERR(dat))
 		return PTR_ERR(dat);
 
-	set = bgpio_map(pdev, "set", sz);
+	set = devm_platform_ioremap_resource_byname(pdev, "set");
 	if (IS_ERR(set))
 		return PTR_ERR(set);
 
-	clr = bgpio_map(pdev, "clr", sz);
+	clr = devm_platform_ioremap_resource_byname(pdev, "clr");
 	if (IS_ERR(clr))
 		return PTR_ERR(clr);
 
-	dirout = bgpio_map(pdev, "dirout", sz);
+	dirout = devm_platform_ioremap_resource_byname(pdev, "dirout");
 	if (IS_ERR(dirout))
 		return PTR_ERR(dirout);
 
-	dirin = bgpio_map(pdev, "dirin", sz);
+	dirin = devm_platform_ioremap_resource_byname(pdev, "dirin");
 	if (IS_ERR(dirin))
 		return PTR_ERR(dirin);