[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <810346b6-c8a4-8c40-8fe3-242332428313@csgroup.eu>
Date: Mon, 6 Nov 2023 08:13:19 +0000
From: Christophe Leroy <christophe.leroy@...roup.eu>
To: George Stark <gnstark@...utedevices.com>,
"pavel@....cz" <pavel@....cz>, "lee@...nel.org" <lee@...nel.org>,
"vadimp@...dia.com" <vadimp@...dia.com>,
"mpe@...erman.id.au" <mpe@...erman.id.au>,
"npiggin@...il.com" <npiggin@...il.com>
CC: "linux-leds@...r.kernel.org" <linux-leds@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"linuxppc-dev@...ts.ozlabs.org" <linuxppc-dev@...ts.ozlabs.org>,
"kernel@...rdevices.ru" <kernel@...rdevices.ru>
Subject: Re: [PATCH 2/8] leds: nic78bx: explicitly unregister LEDs at module's
shutdown
Le 25/10/2023 à 15:07, George Stark a écrit :
> 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-nic78bx.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/leds/leds-nic78bx.c b/drivers/leds/leds-nic78bx.c
> index f196f52eec1e..12b70fcad37f 100644
> --- a/drivers/leds/leds-nic78bx.c
> +++ b/drivers/leds/leds-nic78bx.c
> @@ -170,6 +170,10 @@ static int nic78bx_probe(struct platform_device *pdev)
> static int nic78bx_remove(struct platform_device *pdev)
> {
> struct nic78bx_led_data *led_data = platform_get_drvdata(pdev);
> + int i;
> +
> + for (i = 0; i < ARRAY_SIZE(nic78bx_leds); i++)
> + devm_led_classdev_unregister(&pdev->dev, &nic78bx_leds[i].cdev);
The whole purpose of devm_ functions is that you don't need to call
unregister when removing the driver as the dev core will do it for you.
I understand your problem but I think this is not the solution.
>
> /* Lock LED register */
> outb(NIC78BX_LOCK_VALUE,
Powered by blists - more mailing lists