[PATCH 18/20] gpio/rockchip: make use of device property
Jianqun Xu
jay.xu at rock-chips.com
Tue Sep 20 03:31:06 PDT 2022
Get the iomem resource by devm_platform_ioremap_resource and get the irq
by platform_get_irq.
Signed-off-by: Jianqun Xu <jay.xu at rock-chips.com>
---
drivers/gpio/gpio-rockchip.c | 25 ++++++++++---------------
1 file changed, 10 insertions(+), 15 deletions(-)
diff --git a/drivers/gpio/gpio-rockchip.c b/drivers/gpio/gpio-rockchip.c
index d08435619f12..a94ebd95d285 100644
--- a/drivers/gpio/gpio-rockchip.c
+++ b/drivers/gpio/gpio-rockchip.c
@@ -9,7 +9,6 @@
#include <linux/acpi.h>
#include <linux/bitops.h>
#include <linux/clk.h>
-#include <linux/device.h>
#include <linux/err.h>
#include <linux/gpio/driver.h>
#include <linux/init.h>
@@ -17,6 +16,8 @@
#include <linux/io.h>
#include <linux/module.h>
#include <linux/of.h>
+#include <linux/platform_device.h>
+#include <linux/property.h>
#include <linux/of_address.h>
#include <linux/of_device.h>
#include <linux/of_irq.h>
@@ -651,22 +652,8 @@ static int rockchip_gpiolib_register(struct rockchip_pin_bank *bank)
static int rockchip_get_bank_data(struct rockchip_pin_bank *bank)
{
- struct resource res;
int id = 0;
- if (of_address_to_resource(bank->of_node, 0, &res)) {
- dev_err(bank->dev, "cannot find IO resource for bank\n");
- return -ENOENT;
- }
-
- bank->reg_base = devm_ioremap_resource(bank->dev, &res);
- if (IS_ERR(bank->reg_base))
- return PTR_ERR(bank->reg_base);
-
- bank->irq = irq_of_parse_and_map(bank->of_node, 0);
- if (!bank->irq)
- return -EINVAL;
-
bank->clk = of_clk_get(bank->of_node, 0);
if (IS_ERR(bank->clk))
return PTR_ERR(bank->clk);
@@ -765,6 +752,14 @@ static int rockchip_gpio_probe(struct platform_device *pdev)
if (ret)
return ret;
+ bank->reg_base = devm_platform_ioremap_resource(pdev, 0);
+ if (IS_ERR(bank->reg_base))
+ return PTR_ERR(bank->reg_base);
+
+ bank->irq = platform_get_irq(pdev, 0);
+ if (bank->irq < 0)
+ return bank->irq;
+
ret = rockchip_gpiolib_register(bank);
if (ret) {
dev_err(bank->dev, "Failed to register gpio %d\n", ret);
--
2.25.1
More information about the Linux-rockchip
mailing list