Re: [PATCH v2 04/10] leds: aw200xx: use devm API to cleanup module's resources
From: Andy Shevchenko <hidden>
Date: 2023-12-04 18:17:07
Also in:
linux-leds, lkml
From: Andy Shevchenko <hidden>
Date: 2023-12-04 18:17:07
Also in:
linux-leds, lkml
On Mon, Dec 4, 2023 at 8:07 PM George Stark [off-list ref] wrote:
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().
...
+static void aw200xx_chip_reset_action(void *data)
+{
+ const struct aw200xx *chip = (struct aw200xx *)data;
+
+ aw200xx_chip_reset(chip);
+}
+
+static void aw200xx_disable_action(void *data)
+{
+ const struct aw200xx *chip = (struct aw200xx *)data;
+
+ aw200xx_disable(chip);
+}They can be made oneliners. ...
+ if (devm_mutex_init(&client->dev, &chip->mutex)) + return -ENOMEM;
Do not shadow the real error code. -- With Best Regards, Andy Shevchenko