diff options
author | Chunyan Zhang <chunyan.zhang@unisoc.com> | 2023-10-13 10:20:10 +0800 |
---|---|---|
committer | Lee Jones <lee@kernel.org> | 2023-11-01 11:29:15 +0000 |
commit | 50be9e029b3ac72848685d7a74d1bd32b36309bf (patch) | |
tree | 7b4abeae569530ffb5b7013cd127dc6f1e184dd1 /drivers | |
parent | 259e33cbb1712a7dd844fc9757661cc47cb0e39b (diff) |
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 <chunyan.zhang@unisoc.com>
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>
Link: https://lore.kernel.org/r/20231013022010.854367-1-chunyan.zhang@unisoc.com
Signed-off-by: Lee Jones <lee@kernel.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/leds/leds-sc27xx-bltc.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/drivers/leds/leds-sc27xx-bltc.c b/drivers/leds/leds-sc27xx-bltc.c index af1f00a2f328..f04db793e8d6 100644 --- a/drivers/leds/leds-sc27xx-bltc.c +++ b/drivers/leds/leds-sc27xx-bltc.c @@ -296,7 +296,6 @@ static int sc27xx_led_probe(struct platform_device *pdev) return -ENOMEM; platform_set_drvdata(pdev, priv); - mutex_init(&priv->lock); priv->base = base; priv->regmap = dev_get_regmap(dev->parent, NULL); if (!priv->regmap) { @@ -309,13 +308,11 @@ static int sc27xx_led_probe(struct platform_device *pdev) err = of_property_read_u32(child, "reg", ®); if (err) { of_node_put(child); - mutex_destroy(&priv->lock); return err; } if (reg >= SC27XX_LEDS_MAX || priv->leds[reg].active) { of_node_put(child); - mutex_destroy(&priv->lock); return -EINVAL; } @@ -323,6 +320,8 @@ static int sc27xx_led_probe(struct platform_device *pdev) priv->leds[reg].active = true; } + mutex_init(&priv->lock); + err = sc27xx_led_register(dev, priv); if (err) mutex_destroy(&priv->lock); |