Skip to content

Commit efc347b

Browse files
geo-starklag-linaro
authored andcommitted
leds: mlxreg: 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 310d265 commit efc347b

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

drivers/leds/leds-mlxreg.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ static int mlxreg_led_probe(struct platform_device *pdev)
256256
{
257257
struct mlxreg_core_platform_data *led_pdata;
258258
struct mlxreg_led_priv_data *priv;
259+
int err;
259260

260261
led_pdata = dev_get_platdata(&pdev->dev);
261262
if (!led_pdata) {
@@ -267,26 +268,21 @@ static int mlxreg_led_probe(struct platform_device *pdev)
267268
if (!priv)
268269
return -ENOMEM;
269270

270-
mutex_init(&priv->access_lock);
271+
err = devm_mutex_init(&pdev->dev, &priv->access_lock);
272+
if (err)
273+
return err;
274+
271275
priv->pdev = pdev;
272276
priv->pdata = led_pdata;
273277

274278
return mlxreg_led_config(priv);
275279
}
276280

277-
static void mlxreg_led_remove(struct platform_device *pdev)
278-
{
279-
struct mlxreg_led_priv_data *priv = dev_get_drvdata(&pdev->dev);
280-
281-
mutex_destroy(&priv->access_lock);
282-
}
283-
284281
static struct platform_driver mlxreg_led_driver = {
285282
.driver = {
286283
.name = "leds-mlxreg",
287284
},
288285
.probe = mlxreg_led_probe,
289-
.remove_new = mlxreg_led_remove,
290286
};
291287

292288
module_platform_driver(mlxreg_led_driver);

0 commit comments

Comments
 (0)