diff mbox series

pinctrl: as3722: Use devm_gpiochip_add_data() to simplify remove path

Message ID 20231116223045.274211-1-afd@ti.com
State Accepted
Commit c3c63e66527c18b598bbf9d77f0849852cd32ff9
Headers show
Series pinctrl: as3722: Use devm_gpiochip_add_data() to simplify remove path | expand

Commit Message

Andrew Davis Nov. 16, 2023, 10:30 p.m. UTC
Use devm version of gpiochip add function to handle removal for us.

Signed-off-by: Andrew Davis <afd@ti.com>
---
 drivers/pinctrl/pinctrl-as3722.c | 17 ++---------------
 1 file changed, 2 insertions(+), 15 deletions(-)

Comments

Andy Shevchenko Nov. 17, 2023, 9:16 p.m. UTC | #1
On Thu, Nov 16, 2023 at 04:30:45PM -0600, Andrew Davis wrote:
> Use devm version of gpiochip add function to handle removal for us.

Seems reasonable. Consider also to convert to dev_err_probe()
(in a separate change).

Reviewed-by: Andy Shevchenko <andy@kernel.org>
Andy Shevchenko Nov. 20, 2023, 2:01 p.m. UTC | #2
On Fri, Nov 17, 2023 at 12:30 AM Andrew Davis <afd@ti.com> wrote:
>
> Use devm version of gpiochip add function to handle removal for us.

LGTM,
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>

Consider adding a new patch to convert to use return dev_err_probe(...);
Linus Walleij Nov. 24, 2023, 9:57 a.m. UTC | #3
On Thu, Nov 16, 2023 at 11:30 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>

Patch applied!

Yours,
Linus Walleij
diff mbox series

Patch

diff --git a/drivers/pinctrl/pinctrl-as3722.c b/drivers/pinctrl/pinctrl-as3722.c
index 6a5f23cf7a2a2..0d8c75ce20eda 100644
--- a/drivers/pinctrl/pinctrl-as3722.c
+++ b/drivers/pinctrl/pinctrl-as3722.c
@@ -542,7 +542,6 @@  static int as3722_pinctrl_probe(struct platform_device *pdev)
 
 	as_pci->dev = &pdev->dev;
 	as_pci->as3722 = dev_get_drvdata(pdev->dev.parent);
-	platform_set_drvdata(pdev, as_pci);
 
 	as_pci->pins = as3722_pins_desc;
 	as_pci->num_pins = ARRAY_SIZE(as3722_pins_desc);
@@ -562,7 +561,7 @@  static int as3722_pinctrl_probe(struct platform_device *pdev)
 
 	as_pci->gpio_chip = as3722_gpio_chip;
 	as_pci->gpio_chip.parent = &pdev->dev;
-	ret = gpiochip_add_data(&as_pci->gpio_chip, as_pci);
+	ret = devm_gpiochip_add_data(&pdev->dev, &as_pci->gpio_chip, as_pci);
 	if (ret < 0) {
 		dev_err(&pdev->dev, "Couldn't register gpiochip, %d\n", ret);
 		return ret;
@@ -572,21 +571,10 @@  static int as3722_pinctrl_probe(struct platform_device *pdev)
 				0, 0, AS3722_PIN_NUM);
 	if (ret < 0) {
 		dev_err(&pdev->dev, "Couldn't add pin range, %d\n", ret);
-		goto fail_range_add;
+		return ret;
 	}
 
 	return 0;
-
-fail_range_add:
-	gpiochip_remove(&as_pci->gpio_chip);
-	return ret;
-}
-
-static void as3722_pinctrl_remove(struct platform_device *pdev)
-{
-	struct as3722_pctrl_info *as_pci = platform_get_drvdata(pdev);
-
-	gpiochip_remove(&as_pci->gpio_chip);
 }
 
 static const struct of_device_id as3722_pinctrl_of_match[] = {
@@ -601,7 +589,6 @@  static struct platform_driver as3722_pinctrl_driver = {
 		.of_match_table = as3722_pinctrl_of_match,
 	},
 	.probe = as3722_pinctrl_probe,
-	.remove_new = as3722_pinctrl_remove,
 };
 module_platform_driver(as3722_pinctrl_driver);