* [PATCH 1/2] leds: tca6507: Use devm_gpiochip_add_data() to simplify remove path
@ 2023-11-16 22:41 Andrew Davis
2023-11-16 22:41 ` [PATCH 2/2] leds: tca6507: Use devm_led_classdev_register() " Andrew Davis
2023-11-23 15:10 ` [PATCH 1/2] leds: tca6507: Use devm_gpiochip_add_data() " Lee Jones
0 siblings, 2 replies; 3+ messages in thread
From: Andrew Davis @ 2023-11-16 22:41 UTC (permalink / raw)
To: Pavel Machek, Lee Jones; +Cc: linux-leds, linux-kernel, Andrew Davis
Use devm version of gpiochip add function to handle removal for us.
Signed-off-by: Andrew Davis <afd@ti.com>
---
drivers/leds/leds-tca6507.c | 12 +-----------
1 file changed, 1 insertion(+), 11 deletions(-)
diff --git a/drivers/leds/leds-tca6507.c b/drivers/leds/leds-tca6507.c
index e190746140959..9a6af6d8b5b5d 100644
--- a/drivers/leds/leds-tca6507.c
+++ b/drivers/leds/leds-tca6507.c
@@ -638,19 +638,13 @@ static int tca6507_probe_gpios(struct device *dev,
tca->gpio.direction_output = tca6507_gpio_direction_output;
tca->gpio.set = tca6507_gpio_set_value;
tca->gpio.parent = dev;
- err = gpiochip_add_data(&tca->gpio, tca);
+ err = devm_gpiochip_add_data(dev, &tca->gpio, tca);
if (err) {
tca->gpio.ngpio = 0;
return err;
}
return 0;
}
-
-static void tca6507_remove_gpio(struct tca6507_chip *tca)
-{
- if (tca->gpio.ngpio)
- gpiochip_remove(&tca->gpio);
-}
#else /* CONFIG_GPIOLIB */
static int tca6507_probe_gpios(struct device *dev,
struct tca6507_chip *tca,
@@ -658,9 +652,6 @@ static int tca6507_probe_gpios(struct device *dev,
{
return 0;
}
-static void tca6507_remove_gpio(struct tca6507_chip *tca)
-{
-}
#endif /* CONFIG_GPIOLIB */
static struct tca6507_platform_data *
@@ -793,7 +784,6 @@ static void tca6507_remove(struct i2c_client *client)
if (tca_leds[i].led_cdev.name)
led_classdev_unregister(&tca_leds[i].led_cdev);
}
- tca6507_remove_gpio(tca);
cancel_work_sync(&tca->work);
}
--
2.39.2
^ permalink raw reply [flat|nested] 3+ messages in thread* [PATCH 2/2] leds: tca6507: Use devm_led_classdev_register() to simplify remove path
2023-11-16 22:41 [PATCH 1/2] leds: tca6507: Use devm_gpiochip_add_data() to simplify remove path Andrew Davis
@ 2023-11-16 22:41 ` Andrew Davis
2023-11-23 15:10 ` [PATCH 1/2] leds: tca6507: Use devm_gpiochip_add_data() " Lee Jones
1 sibling, 0 replies; 3+ messages in thread
From: Andrew Davis @ 2023-11-16 22:41 UTC (permalink / raw)
To: Pavel Machek, Lee Jones; +Cc: linux-leds, linux-kernel, Andrew Davis
Use devm version of LED classdev register add function to handle removal.
Signed-off-by: Andrew Davis <afd@ti.com>
---
drivers/leds/leds-tca6507.c | 18 +++---------------
1 file changed, 3 insertions(+), 15 deletions(-)
diff --git a/drivers/leds/leds-tca6507.c b/drivers/leds/leds-tca6507.c
index 9a6af6d8b5b5d..4f22f42249467 100644
--- a/drivers/leds/leds-tca6507.c
+++ b/drivers/leds/leds-tca6507.c
@@ -753,37 +753,25 @@ static int tca6507_probe(struct i2c_client *client)
l->led_cdev.brightness_set = tca6507_brightness_set;
l->led_cdev.blink_set = tca6507_blink_set;
l->bank = -1;
- err = led_classdev_register(dev, &l->led_cdev);
+ err = devm_led_classdev_register(dev, &l->led_cdev);
if (err < 0)
- goto exit;
+ return err;
}
}
err = tca6507_probe_gpios(dev, tca, pdata);
if (err)
- goto exit;
+ return err;
/* set all registers to known state - zero */
tca->reg_set = 0x7f;
schedule_work(&tca->work);
return 0;
-exit:
- while (i--) {
- if (tca->leds[i].led_cdev.name)
- led_classdev_unregister(&tca->leds[i].led_cdev);
- }
- return err;
}
static void tca6507_remove(struct i2c_client *client)
{
- int i;
struct tca6507_chip *tca = i2c_get_clientdata(client);
- struct tca6507_led *tca_leds = tca->leds;
- for (i = 0; i < NUM_LEDS; i++) {
- if (tca_leds[i].led_cdev.name)
- led_classdev_unregister(&tca_leds[i].led_cdev);
- }
cancel_work_sync(&tca->work);
}
--
2.39.2
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH 1/2] leds: tca6507: Use devm_gpiochip_add_data() to simplify remove path
2023-11-16 22:41 [PATCH 1/2] leds: tca6507: Use devm_gpiochip_add_data() to simplify remove path Andrew Davis
2023-11-16 22:41 ` [PATCH 2/2] leds: tca6507: Use devm_led_classdev_register() " Andrew Davis
@ 2023-11-23 15:10 ` Lee Jones
1 sibling, 0 replies; 3+ messages in thread
From: Lee Jones @ 2023-11-23 15:10 UTC (permalink / raw)
To: Pavel Machek, Lee Jones, Andrew Davis; +Cc: linux-leds, linux-kernel
On Thu, 16 Nov 2023 16:41:20 -0600, Andrew Davis wrote:
> Use devm version of gpiochip add function to handle removal for us.
>
>
Applied, thanks!
[1/2] leds: tca6507: Use devm_gpiochip_add_data() to simplify remove path
commit: 50b683a8b9884f032c3d268b8a68df799219e91b
[2/2] leds: tca6507: Use devm_led_classdev_register() to simplify remove path
commit: 612af3a44921f21c361a369899fec61698aa08e1
--
Lee Jones [李琼斯]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-11-23 15:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-16 22:41 [PATCH 1/2] leds: tca6507: Use devm_gpiochip_add_data() to simplify remove path Andrew Davis
2023-11-16 22:41 ` [PATCH 2/2] leds: tca6507: Use devm_led_classdev_register() " Andrew Davis
2023-11-23 15:10 ` [PATCH 1/2] leds: tca6507: Use devm_gpiochip_add_data() " Lee Jones
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®