mirror of
https://github.com/torvalds/linux.git
synced 2024-11-22 04:02:20 +00:00
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: George Stark <gnstark@salutedevices.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Link: https://lore.kernel.org/r/20240411161032.609544-7-gnstark@salutedevices.com Signed-off-by: Lee Jones <lee@kernel.org>
This commit is contained in:
parent
c230c03ba8
commit
310d26520e
@ -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),
|
||||
|
Loading…
Reference in New Issue
Block a user