From: George Stark <gnstark@salutedevices.com>
To: <pavel@ucw.cz>, <lee@kernel.org>, <vadimp@nvidia.com>,
<mpe@ellerman.id.au>, <npiggin@gmail.com>,
<christophe.leroy@csgroup.eu>, <gnstark@salutedevices.com>
Cc: <linux-leds@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<linuxppc-dev@lists.ozlabs.org>, <kernel@sberdevices.ru>
Subject: [PATCH 4/8] leds: mlxreg: explicitly unregister LEDs at module's shutdown
Date: Wed, 25 Oct 2023 16:07:33 +0300 [thread overview]
Message-ID: <20231025130737.2015468-5-gnstark@salutedevices.com> (raw)
In-Reply-To: <20231025130737.2015468-1-gnstark@salutedevices.com>
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-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
next prev parent reply other threads:[~2023-10-25 13:07 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-25 13:07 [PATCH 0/8] devm_led_classdev_register() usage problem George Stark
2023-10-25 13:07 ` [PATCH 1/8] leds: powernv: explicitly unregister LEDs at module's shutdown George Stark
2023-10-25 13:07 ` [PATCH 2/8] leds: nic78bx: " George Stark
2023-11-06 8:13 ` Christophe Leroy
2023-11-09 23:28 ` George Stark
2023-10-25 13:07 ` [PATCH 3/8] leds: an30259a: " George Stark
2023-10-25 13:07 ` George Stark [this message]
2023-10-25 13:07 ` [PATCH 5/8] leds: aw200xx: " George Stark
2023-10-25 13:07 ` [PATCH 6/8] leds: aw2013: " George Stark
2023-10-25 13:07 ` [PATCH 7/8] leds: lp3952: " George Stark
2023-11-04 7:18 ` [PATCH 0/8] devm_led_classdev_register() usage problem George Stark
2023-11-24 15:30 ` Andy Shevchenko
2023-11-06 8:11 ` Christophe Leroy
2023-11-24 15:28 ` Andy Shevchenko
2023-11-25 0:47 ` George Stark
2023-11-25 11:04 ` Jonathan Cameron
2023-11-27 12:41 ` Andy Shevchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231025130737.2015468-5-gnstark@salutedevices.com \
--to=gnstark@salutedevices.com \
--cc=christophe.leroy@csgroup.eu \
--cc=kernel@sberdevices.ru \
--cc=lee@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
--cc=npiggin@gmail.com \
--cc=pavel@ucw.cz \
--cc=vadimp@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®