lkml.org 
[lkml]   [2023]   [Oct]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 7/8] leds: lp3952: explicitly unregister LEDs at module's shutdown
Date
LEDs are registered using devm_led_classdev_register() and automatically
unregistered after module's remove(). led_classdev_unregister() calls
led_set_brightness() to turn off the LEDs and module's appropriate callback
uses resources those were destroyed already in module's remove().
So explicitly unregister LEDs at module shutdown.

Signed-off-by: George Stark <gnstark@salutedevices.com>
---
drivers/leds/leds-lp3952.c | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/drivers/leds/leds-lp3952.c b/drivers/leds/leds-lp3952.c
index 3bd55652a706..2de49192011a 100644
--- a/drivers/leds/leds-lp3952.c
+++ b/drivers/leds/leds-lp3952.c
@@ -257,8 +257,13 @@ static int lp3952_probe(struct i2c_client *client)
static void lp3952_remove(struct i2c_client *client)
{
struct lp3952_led_array *priv;
+ int i;

priv = i2c_get_clientdata(client);
+ for (i = 0; i < LP3952_LED_ALL; i++)
+ if (priv->leds[i].priv)
+ devm_led_classdev_unregister(&client->dev,
+ &priv->leds[i].cdev);
lp3952_on_off(priv, LP3952_LED_ALL, false);
gpiod_set_value(priv->enable_gpio, 0);
}
--
2.38.4
\
 
 \ /
  Last update: 2023-10-25 15:09    [W:0.210 / U:0.036 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site