]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ASoC: codecs: rt5665: Fix some error handling paths in rt5665_probe()
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Sat, 22 Mar 2025 07:45:49 +0000 (08:45 +0100)
committerMark Brown <broonie@kernel.org>
Mon, 31 Mar 2025 15:14:07 +0000 (16:14 +0100)
Should an error occur after a successful regulator_bulk_enable() call,
regulator_bulk_disable() should be called, as already done in the remove
function.

Instead of adding an error handling path in the probe, switch from
devm_regulator_bulk_get() to devm_regulator_bulk_get_enable() and
simplify the remove function and some other places accordingly.

Finally, add a missing const when defining rt5665_supply_names to please
checkpatch and constify a few bytes.

Fixes: 33ada14a26c8 ("ASoC: add rt5665 codec driver")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://patch.msgid.link/e3c2aa1b2fdfa646752d94f4af968630c0d58248.1742629525.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/codecs/rt5665.c

index e0d1991cffdb894cfc4794905d49d316fe92f4bb..bcb6d7c6f301a350953b4d924795b67a038a50e1 100644 (file)
@@ -31,9 +31,7 @@
 #include "rl6231.h"
 #include "rt5665.h"
 
-#define RT5665_NUM_SUPPLIES 3
-
-static const char *rt5665_supply_names[RT5665_NUM_SUPPLIES] = {
+static const char * const rt5665_supply_names[] = {
        "AVDD",
        "MICVDD",
        "VBAT",
@@ -46,7 +44,6 @@ struct rt5665_priv {
        struct gpio_desc *gpiod_ldo1_en;
        struct gpio_desc *gpiod_reset;
        struct snd_soc_jack *hs_jack;
-       struct regulator_bulk_data supplies[RT5665_NUM_SUPPLIES];
        struct delayed_work jack_detect_work;
        struct delayed_work calibrate_work;
        struct delayed_work jd_check_work;
@@ -4471,8 +4468,6 @@ static void rt5665_remove(struct snd_soc_component *component)
        struct rt5665_priv *rt5665 = snd_soc_component_get_drvdata(component);
 
        regmap_write(rt5665->regmap, RT5665_RESET, 0);
-
-       regulator_bulk_disable(ARRAY_SIZE(rt5665->supplies), rt5665->supplies);
 }
 
 #ifdef CONFIG_PM
@@ -4758,7 +4753,7 @@ static int rt5665_i2c_probe(struct i2c_client *i2c)
 {
        struct rt5665_platform_data *pdata = dev_get_platdata(&i2c->dev);
        struct rt5665_priv *rt5665;
-       int i, ret;
+       int ret;
        unsigned int val;
 
        rt5665 = devm_kzalloc(&i2c->dev, sizeof(struct rt5665_priv),
@@ -4774,24 +4769,13 @@ static int rt5665_i2c_probe(struct i2c_client *i2c)
        else
                rt5665_parse_dt(rt5665, &i2c->dev);
 
-       for (i = 0; i < ARRAY_SIZE(rt5665->supplies); i++)
-               rt5665->supplies[i].supply = rt5665_supply_names[i];
-
-       ret = devm_regulator_bulk_get(&i2c->dev, ARRAY_SIZE(rt5665->supplies),
-                                     rt5665->supplies);
+       ret = devm_regulator_bulk_get_enable(&i2c->dev, ARRAY_SIZE(rt5665_supply_names),
+                                            rt5665_supply_names);
        if (ret != 0) {
                dev_err(&i2c->dev, "Failed to request supplies: %d\n", ret);
                return ret;
        }
 
-       ret = regulator_bulk_enable(ARRAY_SIZE(rt5665->supplies),
-                                   rt5665->supplies);
-       if (ret != 0) {
-               dev_err(&i2c->dev, "Failed to enable supplies: %d\n", ret);
-               return ret;
-       }
-
-
        rt5665->gpiod_ldo1_en = devm_gpiod_get_optional(&i2c->dev,
                                                        "realtek,ldo1-en",
                                                        GPIOD_OUT_HIGH);