diff mbox series

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

Message ID 20190528154601.7597-1-brgl@bgdev.pl
State New
Headers show
Series gpio: em: use the managed version of gpiochip_add_data() | expand

Commit Message

Bartosz Golaszewski May 28, 2019, 3:46 p.m. UTC
From: Bartosz Golaszewski <bgolaszewski@baylibre.com>

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

Cc: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
 drivers/gpio/gpio-em.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Comments

Geert Uytterhoeven May 28, 2019, 4:20 p.m. UTC | #1
On Tue, May 28, 2019 at 5:46 PM Bartosz Golaszewski <brgl@bgdev.pl> wrote:
> From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
>
> Use the managed variant of gpiochip_add_data() and remove the call to
> gpiochip_remove().
>
> Cc: Geert Uytterhoeven <geert+renesas@glider.be>
> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

Gr{oetje,eeting}s,

                        Geert
Bartosz Golaszewski May 31, 2019, 8:11 a.m. UTC | #2
wt., 28 maj 2019 o 18:20 Geert Uytterhoeven <geert@linux-m68k.org> napisał(a):
>
> On Tue, May 28, 2019 at 5:46 PM Bartosz Golaszewski <brgl@bgdev.pl> wrote:
> > From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> >
> > Use the managed variant of gpiochip_add_data() and remove the call to
> > gpiochip_remove().
> >
> > Cc: Geert Uytterhoeven <geert+renesas@glider.be>
> > Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
>
> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
>
> Gr{oetje,eeting}s,
>
>                         Geert
>
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
>
> 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

Applied.

Bart
Geert Uytterhoeven July 9, 2019, 6:49 p.m. UTC | #3
Hi Bartosz,

On Tue, May 28, 2019 at 5:46 PM Bartosz Golaszewski <brgl@bgdev.pl> wrote:
> From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
>
> Use the managed variant of gpiochip_add_data() and remove the call to
> gpiochip_remove().
>
> Cc: Geert Uytterhoeven <geert+renesas@glider.be>
> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> ---
>  drivers/gpio/gpio-em.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/gpio/gpio-em.c b/drivers/gpio/gpio-em.c
> index 40f8c38bec1c..299101d25fa8 100644
> --- a/drivers/gpio/gpio-em.c
> +++ b/drivers/gpio/gpio-em.c
> @@ -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);
>
> -       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())?

>         return 0;

>  }

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

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
Bartosz Golaszewski July 9, 2019, 7:26 p.m. UTC | #4
wt., 9 lip 2019 o 20:49 Geert Uytterhoeven <geert@linux-m68k.org> napisał(a):
>
> Hi Bartosz,
>
> On Tue, May 28, 2019 at 5:46 PM Bartosz Golaszewski <brgl@bgdev.pl> wrote:
> > From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> >
> > Use the managed variant of gpiochip_add_data() and remove the call to
> > gpiochip_remove().
> >
> > Cc: Geert Uytterhoeven <geert+renesas@glider.be>
> > Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> > ---
> >  drivers/gpio/gpio-em.c | 4 +---
> >  1 file changed, 1 insertion(+), 3 deletions(-)
> >
> > diff --git a/drivers/gpio/gpio-em.c b/drivers/gpio/gpio-em.c
> > index 40f8c38bec1c..299101d25fa8 100644
> > --- a/drivers/gpio/gpio-em.c
> > +++ b/drivers/gpio/gpio-em.c
> > @@ -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);
> >
> > -       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

> >         return 0;
>
> >  }
>
> Gr{oetje,eeting}s,
>
>                         Geert
>
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
>
> 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
diff mbox series

Patch

diff --git a/drivers/gpio/gpio-em.c b/drivers/gpio/gpio-em.c
index 40f8c38bec1c..299101d25fa8 100644
--- a/drivers/gpio/gpio-em.c
+++ b/drivers/gpio/gpio-em.c
@@ -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);
 
-	gpiochip_remove(&p->gpio_chip);
-
 	irq_domain_remove(p->irq_domain);
 	return 0;
 }