diff mbox series

[V2] leds: sc27xx: Move mutex_init() to the end of probe

Message ID 20230925032453.724518-1-chunyan.zhang@unisoc.com
State Superseded
Headers show
Series [V2] leds: sc27xx: Move mutex_init() to the end of probe | expand

Commit Message

Chunyan Zhang Sept. 25, 2023, 3:24 a.m. UTC
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>
---
V2:
- Move the mutex_init() to the end of .probe() instead of adding
mutex_destroy() according to Lee's comments.
---
 drivers/leds/leds-sc27xx-bltc.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

Comments

Lee Jones Sept. 28, 2023, 1:37 p.m. UTC | #1
On Mon, 25 Sep 2023, Chunyan Zhang wrote:

> 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>
> ---
> V2:
> - Move the mutex_init() to the end of .probe() instead of adding
> mutex_destroy() according to Lee's comments.
> ---
>  drivers/leds/leds-sc27xx-bltc.c | 9 ++++-----
>  1 file changed, 4 insertions(+), 5 deletions(-)

Nice patch, but doesn't apply.

Please rebase (onto linux-next or for-leds-next) and resend.
diff mbox series

Patch

diff --git a/drivers/leds/leds-sc27xx-bltc.c b/drivers/leds/leds-sc27xx-bltc.c
index e199ea15e406..d9183addf7f5 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", &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;
 		}
 
@@ -325,9 +322,11 @@  static int sc27xx_led_probe(struct platform_device *pdev)
 
 	err = sc27xx_led_register(dev, priv);
 	if (err)
-		mutex_destroy(&priv->lock);
+		return err;
 
-	return err;
+	mutex_init(&priv->lock);
+
+	return 0;
 }
 
 static int sc27xx_led_remove(struct platform_device *pdev)