[PATCH 3/5] pinctrl: dw: use devm_gpiochip_add_data

From: Clement Leger
Date: Wed Dec 04 2019 - 05:11:13 EST


Use managed gpiochip_add_data for easier handling of exit paths.

Signed-off-by: Clement Leger <cleger@xxxxxxxxx>
---
drivers/pinctrl/dw/pinctrl-dwapb.c | 13 +------------
1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/drivers/pinctrl/dw/pinctrl-dwapb.c b/drivers/pinctrl/dw/pinctrl-dwapb.c
index 62e598bdd9ff..3750205408e3 100644
--- a/drivers/pinctrl/dw/pinctrl-dwapb.c
+++ b/drivers/pinctrl/dw/pinctrl-dwapb.c
@@ -529,7 +529,7 @@ static int dwapb_gpio_add_port(struct dwapb_gpio *gpio,
if (pp->has_irq)
dwapb_configure_irqs(gpio, port, pp);

- err = gpiochip_add_data(&port->gc, port);
+ err = devm_gpiochip_add_data(gpio->dev, &port->gc, port);
if (err)
dev_err(gpio->dev, "failed to register gpiochip for port%d\n",
port->idx);
@@ -543,15 +543,6 @@ static int dwapb_gpio_add_port(struct dwapb_gpio *gpio,
return err;
}

-static void dwapb_gpio_unregister(struct dwapb_gpio *gpio)
-{
- unsigned int m;
-
- for (m = 0; m < gpio->nr_ports; ++m)
- if (gpio->ports[m].is_registered)
- gpiochip_remove(&gpio->ports[m].gc);
-}
-
static struct dwapb_platform_data *
dwapb_gpio_get_pdata(struct device *dev)
{
@@ -719,7 +710,6 @@ static int dwapb_gpio_probe(struct platform_device *pdev)
return 0;

out_unregister:
- dwapb_gpio_unregister(gpio);
dwapb_irq_teardown(gpio);
clk_disable_unprepare(gpio->clk);

@@ -730,7 +720,6 @@ static int dwapb_gpio_remove(struct platform_device *pdev)
{
struct dwapb_gpio *gpio = platform_get_drvdata(pdev);

- dwapb_gpio_unregister(gpio);
dwapb_irq_teardown(gpio);
reset_control_assert(gpio->rst);
clk_disable_unprepare(gpio->clk);
--
2.15.0.276.g89ea799