[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231025130737.2015468-8-gnstark@salutedevices.com>
Date: Wed, 25 Oct 2023 16:07:36 +0300
From: George Stark <gnstark@...utedevices.com>
To: <pavel@....cz>, <lee@...nel.org>, <vadimp@...dia.com>,
<mpe@...erman.id.au>, <npiggin@...il.com>,
<christophe.leroy@...roup.eu>, <gnstark@...utedevices.com>
CC: <linux-leds@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<linuxppc-dev@...ts.ozlabs.org>, <kernel@...rdevices.ru>
Subject: [PATCH 7/8] leds: lp3952: explicitly unregister LEDs at module's shutdown
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@...utedevices.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
Powered by blists - more mailing lists