[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231025130737.2015468-5-gnstark@salutedevices.com>
Date: Wed, 25 Oct 2023 16:07:33 +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 4/8] leds: mlxreg: 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-mlxreg.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/drivers/leds/leds-mlxreg.c b/drivers/leds/leds-mlxreg.c
index b7855c93bd72..6d65e39c3372 100644
--- a/drivers/leds/leds-mlxreg.c
+++ b/drivers/leds/leds-mlxreg.c
@@ -258,6 +258,7 @@ static int mlxreg_led_probe(struct platform_device *pdev)
{
struct mlxreg_core_platform_data *led_pdata;
struct mlxreg_led_priv_data *priv;
+ int res;
led_pdata = dev_get_platdata(&pdev->dev);
if (!led_pdata) {
@@ -273,13 +274,22 @@ static int mlxreg_led_probe(struct platform_device *pdev)
priv->pdev = pdev;
priv->pdata = led_pdata;
- return mlxreg_led_config(priv);
+ if (!devres_open_group(&pdev->dev, priv, GFP_KERNEL))
+ return -ENOMEM;
+
+ res = mlxreg_led_config(priv);
+ if (res)
+ devres_remove_group(&pdev->dev, priv);
+
+ return res;
}
static int mlxreg_led_remove(struct platform_device *pdev)
{
struct mlxreg_led_priv_data *priv = dev_get_drvdata(&pdev->dev);
+ devres_release_group(&pdev->dev, priv);
+
mutex_destroy(&priv->access_lock);
return 0;
--
2.38.4
Powered by blists - more mailing lists