Skip to content

Commit 50be9e0

Browse files
Chunyan Zhanglag-linaro
authored andcommitted
leds: sc27xx: Move mutex_init() down
Move the mutex_init() to avoid redundant mutex_destroy() calls after that for each time the probe fails. Signed-off-by: Chunyan Zhang <[email protected]> Reviewed-by: Baolin Wang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Lee Jones <[email protected]>
1 parent 259e33c commit 50be9e0

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

drivers/leds/leds-sc27xx-bltc.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,6 @@ static int sc27xx_led_probe(struct platform_device *pdev)
296296
return -ENOMEM;
297297

298298
platform_set_drvdata(pdev, priv);
299-
mutex_init(&priv->lock);
300299
priv->base = base;
301300
priv->regmap = dev_get_regmap(dev->parent, NULL);
302301
if (!priv->regmap) {
@@ -309,20 +308,20 @@ static int sc27xx_led_probe(struct platform_device *pdev)
309308
err = of_property_read_u32(child, "reg", &reg);
310309
if (err) {
311310
of_node_put(child);
312-
mutex_destroy(&priv->lock);
313311
return err;
314312
}
315313

316314
if (reg >= SC27XX_LEDS_MAX || priv->leds[reg].active) {
317315
of_node_put(child);
318-
mutex_destroy(&priv->lock);
319316
return -EINVAL;
320317
}
321318

322319
priv->leds[reg].fwnode = of_fwnode_handle(child);
323320
priv->leds[reg].active = true;
324321
}
325322

323+
mutex_init(&priv->lock);
324+
326325
err = sc27xx_led_register(dev, priv);
327326
if (err)
328327
mutex_destroy(&priv->lock);

0 commit comments

Comments
 (0)