Skip to contentSkip to conversation

gpio: em: use the managed version of gpiochip_add_data()

PATCH Geert Uytterhoeven 2 participants 2 messages Jul 9, 2019 1 message not in the archive GPIO

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

Hi Bartosz,

Quoted 25 lines · Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

Use the managed variant of gpiochip_add_data() and remove the call to gpiochip_remove().

---
 drivers/gpio/gpio-em.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpio/gpio-em.c +1 -1
index 40f8c38bec1c..299101d25fa8 100644
@@ -359,7 +359,7 @@ static int em_gio_probe(struct platform_device *pdev)
                goto err1;
        }
 
-       ret = gpiochip_add_data(gpio_chip, p);
+       ret = devm_gpiochip_add_data(&pdev->dev, gpio_chip, p);
        if (ret) {
                dev_err(&pdev->dev, "failed to add GPIO controller\n");
                goto err1;

drivers/gpio/gpio-em.c static int em_gio_remove(struct platform_device *pdev) · line 379

Quoted 6 lines
drivers/gpio/gpio-em.c +0 -2
@@ -376,8 +376,6 @@ static int em_gio_remove(struct platform_device *pdev)
 {
        struct em_gio_priv *p = platform_get_drvdata(pdev);
 
-       gpiochip_remove(&p->gpio_chip);
-
        irq_domain_remove(p->irq_domain);

On a second thought, is it safe to call irq_domain_remove() before gpiochip_remove() (which calls gpiochip_irqchip_remove())?

Quoted 3 lines
drivers/gpio/gpio-em.c +0 -0
        return 0;
 

}

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

#2 lore raw

wt., 9 lip 2019 o 20:49 Geert Uytterhoeven <[email protected]> napisał(a):

Quoted 32 lines

Hi Bartosz,

Quoted 28 lines · Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

Use the managed variant of gpiochip_add_data() and remove the call to gpiochip_remove().

---
 drivers/gpio/gpio-em.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpio/gpio-em.c +1 -1
index 40f8c38bec1c..299101d25fa8 100644
@@ -359,7 +359,7 @@ static int em_gio_probe(struct platform_device *pdev)
                goto err1;
        }
 
-       ret = gpiochip_add_data(gpio_chip, p);
+       ret = devm_gpiochip_add_data(&pdev->dev, gpio_chip, p);
        if (ret) {
                dev_err(&pdev->dev, "failed to add GPIO controller\n");
                goto err1;
@@ -376,8 +376,6 @@ static int em_gio_remove(struct platform_device *pdev)
 {
        struct em_gio_priv *p = platform_get_drvdata(pdev);
 
Quoted 7 lines

drivers/gpio/gpio-em.c static int em_gio_remove(struct platform_device *pdev) · line 379

Quoted 3 lines
drivers/gpio/gpio-em.c +0 -2
-       gpiochip_remove(&p->gpio_chip);
-
        irq_domain_remove(p->irq_domain);

On a second thought, is it safe to call irq_domain_remove() before gpiochip_remove() (which calls gpiochip_irqchip_remove())?

Good call. I think the most elegant solution here would be to use devm_add_action() to keep the ordering right. I'll send a follow-up tomorrow morning.

Bart

Quoted 14 lines
Quoted 3 lines
drivers/gpio/gpio-em.c +0 -0
        return 0;
 

}

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds