ASoC: wm8960: Fix error handling in probe
authorGuenter Roeck <linux@roeck-us.net>
Sat, 9 Sep 2023 12:02:37 +0000 (05:02 -0700)
committerMark Brown <broonie@kernel.org>
Mon, 11 Sep 2023 00:23:55 +0000 (01:23 +0100)
Commit 422f10adc3eb ("ASoC: wm8960: Add support for the power supplies")
added regulator support to the wm8960 driver, but neglected to update
error handling in the probe function. This results in warning backtraces
if the probe function fails.

Fixes: 422f10adc3eb ("ASoC: wm8960: Add support for the power supplies")
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Fabio Estevam <festevam@denx.de>
Link: https://lore.kernel.org/r/20230909120237.2646275-1-linux@roeck-us.net
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/codecs/wm8960.c

index 0a50180..7689fe3 100644 (file)
@@ -1468,8 +1468,10 @@ static int wm8960_i2c_probe(struct i2c_client *i2c)
        }
 
        wm8960->regmap = devm_regmap_init_i2c(i2c, &wm8960_regmap);
-       if (IS_ERR(wm8960->regmap))
-               return PTR_ERR(wm8960->regmap);
+       if (IS_ERR(wm8960->regmap)) {
+               ret = PTR_ERR(wm8960->regmap);
+               goto bulk_disable;
+       }
 
        if (pdata)
                memcpy(&wm8960->pdata, pdata, sizeof(struct wm8960_data));
@@ -1479,13 +1481,14 @@ static int wm8960_i2c_probe(struct i2c_client *i2c)
        ret = i2c_master_recv(i2c, &val, sizeof(val));
        if (ret >= 0) {
                dev_err(&i2c->dev, "Not wm8960, wm8960 reg can not read by i2c\n");
-               return -EINVAL;
+               ret = -EINVAL;
+               goto bulk_disable;
        }
 
        ret = wm8960_reset(wm8960->regmap);
        if (ret != 0) {
                dev_err(&i2c->dev, "Failed to issue reset\n");
-               return ret;
+               goto bulk_disable;
        }
 
        if (wm8960->pdata.shared_lrclk) {
@@ -1494,7 +1497,7 @@ static int wm8960_i2c_probe(struct i2c_client *i2c)
                if (ret != 0) {
                        dev_err(&i2c->dev, "Failed to enable LRCM: %d\n",
                                ret);
-                       return ret;
+                       goto bulk_disable;
                }
        }
 
@@ -1528,7 +1531,13 @@ static int wm8960_i2c_probe(struct i2c_client *i2c)
 
        ret = devm_snd_soc_register_component(&i2c->dev,
                        &soc_component_dev_wm8960, &wm8960_dai, 1);
+       if (ret)
+               goto bulk_disable;
 
+       return 0;
+
+bulk_disable:
+       regulator_bulk_disable(ARRAY_SIZE(wm8960->supplies), wm8960->supplies);
        return ret;
 }