Skip to content

Commit c382e2e

Browse files
geo-starklag-linaro
authored andcommitted
leds: an30259a: Use devm_mutex_init() for mutex initialization
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 mutex which was destroyed already in module's remove() so use devm API instead. Signed-off-by: George Stark <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Lee Jones <[email protected]>
1 parent efc347b commit c382e2e

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

drivers/leds/leds-an30259a.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,10 @@ static int an30259a_probe(struct i2c_client *client)
283283
if (err < 0)
284284
return err;
285285

286-
mutex_init(&chip->mutex);
286+
err = devm_mutex_init(&client->dev, &chip->mutex);
287+
if (err)
288+
return err;
289+
287290
chip->client = client;
288291
i2c_set_clientdata(client, chip);
289292

@@ -317,17 +320,9 @@ static int an30259a_probe(struct i2c_client *client)
317320
return 0;
318321

319322
exit:
320-
mutex_destroy(&chip->mutex);
321323
return err;
322324
}
323325

324-
static void an30259a_remove(struct i2c_client *client)
325-
{
326-
struct an30259a *chip = i2c_get_clientdata(client);
327-
328-
mutex_destroy(&chip->mutex);
329-
}
330-
331326
static const struct of_device_id an30259a_match_table[] = {
332327
{ .compatible = "panasonic,an30259a", },
333328
{ /* sentinel */ },
@@ -347,7 +342,6 @@ static struct i2c_driver an30259a_driver = {
347342
.of_match_table = an30259a_match_table,
348343
},
349344
.probe = an30259a_probe,
350-
.remove = an30259a_remove,
351345
.id_table = an30259a_id,
352346
};
353347

0 commit comments

Comments
 (0)