Commit 310d2652 authored by George Stark's avatar George Stark Committed by Lee Jones

leds: nic78bx: Use devm API to cleanup module's resources

In this driver LEDs are registered using devm_led_classdev_register()
so they are automatically unregistered after module's remove() is done.
led_classdev_unregister() calls module's led_set_brightness() to turn off
the LEDs and that callback uses resources which were destroyed already
in module's remove() so use devm API instead of remove().
Signed-off-by: default avatarGeorge Stark <gnstark@salutedevices.com>
Reviewed-by: default avatarAndy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20240411161032.609544-7-gnstark@salutedevices.comSigned-off-by: default avatarLee Jones <lee@kernel.org>
parent c230c03b
......@@ -118,6 +118,15 @@ static struct nic78bx_led nic78bx_leds[] = {
}
};
static void lock_led_reg_action(void *data)
{
struct nic78bx_led_data *led_data = data;
/* Lock LED register */
outb(NIC78BX_LOCK_VALUE,
led_data->io_base + NIC78BX_LOCK_REG_OFFSET);
}
static int nic78bx_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
......@@ -152,6 +161,10 @@ static int nic78bx_probe(struct platform_device *pdev)
led_data->io_base = io_rc->start;
spin_lock_init(&led_data->lock);
ret = devm_add_action(dev, lock_led_reg_action, led_data);
if (ret)
return ret;
for (i = 0; i < ARRAY_SIZE(nic78bx_leds); i++) {
nic78bx_leds[i].data = led_data;
......@@ -167,15 +180,6 @@ static int nic78bx_probe(struct platform_device *pdev)
return ret;
}
static void nic78bx_remove(struct platform_device *pdev)
{
struct nic78bx_led_data *led_data = platform_get_drvdata(pdev);
/* Lock LED register */
outb(NIC78BX_LOCK_VALUE,
led_data->io_base + NIC78BX_LOCK_REG_OFFSET);
}
static const struct acpi_device_id led_device_ids[] = {
{"NIC78B3", 0},
{"", 0},
......@@ -184,7 +188,6 @@ MODULE_DEVICE_TABLE(acpi, led_device_ids);
static struct platform_driver led_driver = {
.probe = nic78bx_probe,
.remove_new = nic78bx_remove,
.driver = {
.name = KBUILD_MODNAME,
.acpi_match_table = ACPI_PTR(led_device_ids),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment