linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] gpio: twl4030: Use devm_gpiochip_add_data() to simplify remove path
@ 2023-05-15 17:40 Andrew Davis
  2023-05-16 13:35 ` Linus Walleij
  2023-05-17  9:40 ` Bartosz Golaszewski
  0 siblings, 2 replies; 3+ messages in thread
From: Andrew Davis @ 2023-05-15 17:40 UTC (permalink / raw)
  To: Peter Tyser, Andy Shevchenko, Linus Walleij, Bartosz Golaszewski
  Cc: linux-gpio, linux-kernel, Andrew Davis

Use devm version of gpiochip add function to handle removal for us.

Signed-off-by: Andrew Davis <afd@ti.com>
---

Changes from v2:
 - Rebase on v6.4-rc2

Changes from v1:
 - Actually add the devm call

 drivers/gpio/gpio-twl4030.c | 23 +++--------------------
 1 file changed, 3 insertions(+), 20 deletions(-)

diff --git a/drivers/gpio/gpio-twl4030.c b/drivers/gpio/gpio-twl4030.c
index c1bb2c3ca6f2..3708ed2314e8 100644
--- a/drivers/gpio/gpio-twl4030.c
+++ b/drivers/gpio/gpio-twl4030.c
@@ -492,18 +492,6 @@ static struct twl4030_gpio_platform_data *of_gpio_twl4030(struct device *dev,
 	return omap_twl_info;
 }
 
-/* Cannot use as gpio_twl4030_probe() calls us */
-static int gpio_twl4030_remove(struct platform_device *pdev)
-{
-	struct gpio_twl4030_priv *priv = platform_get_drvdata(pdev);
-
-	gpiochip_remove(&priv->gpio_chip);
-
-	/* REVISIT no support yet for deregistering all the IRQs */
-	WARN_ON(!is_module());
-	return 0;
-}
-
 static int gpio_twl4030_probe(struct platform_device *pdev)
 {
 	struct twl4030_gpio_platform_data *pdata = dev_get_platdata(&pdev->dev);
@@ -577,16 +565,13 @@ static int gpio_twl4030_probe(struct platform_device *pdev)
 	if (pdata->use_leds)
 		priv->gpio_chip.ngpio += 2;
 
-	ret = gpiochip_add_data(&priv->gpio_chip, priv);
+	ret = devm_gpiochip_add_data(&pdev->dev, &priv->gpio_chip, priv);
 	if (ret < 0) {
 		dev_err(&pdev->dev, "could not register gpiochip, %d\n", ret);
 		priv->gpio_chip.ngpio = 0;
-		gpio_twl4030_remove(pdev);
-		goto out;
+		return ret;
 	}
 
-	platform_set_drvdata(pdev, priv);
-
 	if (pdata->setup) {
 		int status;
 
@@ -596,8 +581,7 @@ static int gpio_twl4030_probe(struct platform_device *pdev)
 			dev_dbg(&pdev->dev, "setup --> %d\n", status);
 	}
 
-out:
-	return ret;
+	return 0;
 }
 
 static const struct of_device_id twl_gpio_match[] = {
@@ -615,7 +599,6 @@ static struct platform_driver gpio_twl4030_driver = {
 		.of_match_table = twl_gpio_match,
 	},
 	.probe		= gpio_twl4030_probe,
-	.remove		= gpio_twl4030_remove,
 };
 
 static int __init gpio_twl4030_init(void)
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v3] gpio: twl4030: Use devm_gpiochip_add_data() to simplify remove path
  2023-05-15 17:40 [PATCH v3] gpio: twl4030: Use devm_gpiochip_add_data() to simplify remove path Andrew Davis
@ 2023-05-16 13:35 ` Linus Walleij
  2023-05-17  9:40 ` Bartosz Golaszewski
  1 sibling, 0 replies; 3+ messages in thread
From: Linus Walleij @ 2023-05-16 13:35 UTC (permalink / raw)
  To: Andrew Davis
  Cc: Peter Tyser, Andy Shevchenko, Bartosz Golaszewski, linux-gpio,
	linux-kernel

On Mon, May 15, 2023 at 7:40 PM Andrew Davis <afd@ti.com> wrote:

> Use devm version of gpiochip add function to handle removal for us.
>
> Signed-off-by: Andrew Davis <afd@ti.com>

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v3] gpio: twl4030: Use devm_gpiochip_add_data() to simplify remove path
  2023-05-15 17:40 [PATCH v3] gpio: twl4030: Use devm_gpiochip_add_data() to simplify remove path Andrew Davis
  2023-05-16 13:35 ` Linus Walleij
@ 2023-05-17  9:40 ` Bartosz Golaszewski
  1 sibling, 0 replies; 3+ messages in thread
From: Bartosz Golaszewski @ 2023-05-17  9:40 UTC (permalink / raw)
  To: Andrew Davis
  Cc: Peter Tyser, Andy Shevchenko, Linus Walleij, linux-gpio,
	linux-kernel

On Mon, May 15, 2023 at 7:40 PM Andrew Davis <afd@ti.com> wrote:
>
> Use devm version of gpiochip add function to handle removal for us.
>
> Signed-off-by: Andrew Davis <afd@ti.com>
> ---
>

Applied, thanks!

Bart

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-05-17  9:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-15 17:40 [PATCH v3] gpio: twl4030: Use devm_gpiochip_add_data() to simplify remove path Andrew Davis
2023-05-16 13:35 ` Linus Walleij
2023-05-17  9:40 ` Bartosz Golaszewski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).