Skip to content

Commit 1ebd494

Browse files
tititiou36broonie
authored andcommitted
ASoC: codecs: rt5665: Fix some error handling paths in rt5665_probe()
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: 33ada14 ("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>
1 parent 7d783d9 commit 1ebd494

File tree

1 file changed

+4
-20
lines changed

1 file changed

+4
-20
lines changed

sound/soc/codecs/rt5665.c

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,7 @@
3131
#include "rl6231.h"
3232
#include "rt5665.h"
3333

34-
#define RT5665_NUM_SUPPLIES 3
35-
36-
static const char *rt5665_supply_names[RT5665_NUM_SUPPLIES] = {
34+
static const char * const rt5665_supply_names[] = {
3735
"AVDD",
3836
"MICVDD",
3937
"VBAT",
@@ -46,7 +44,6 @@ struct rt5665_priv {
4644
struct gpio_desc *gpiod_ldo1_en;
4745
struct gpio_desc *gpiod_reset;
4846
struct snd_soc_jack *hs_jack;
49-
struct regulator_bulk_data supplies[RT5665_NUM_SUPPLIES];
5047
struct delayed_work jack_detect_work;
5148
struct delayed_work calibrate_work;
5249
struct delayed_work jd_check_work;
@@ -4471,8 +4468,6 @@ static void rt5665_remove(struct snd_soc_component *component)
44714468
struct rt5665_priv *rt5665 = snd_soc_component_get_drvdata(component);
44724469

44734470
regmap_write(rt5665->regmap, RT5665_RESET, 0);
4474-
4475-
regulator_bulk_disable(ARRAY_SIZE(rt5665->supplies), rt5665->supplies);
44764471
}
44774472

44784473
#ifdef CONFIG_PM
@@ -4758,7 +4753,7 @@ static int rt5665_i2c_probe(struct i2c_client *i2c)
47584753
{
47594754
struct rt5665_platform_data *pdata = dev_get_platdata(&i2c->dev);
47604755
struct rt5665_priv *rt5665;
4761-
int i, ret;
4756+
int ret;
47624757
unsigned int val;
47634758

47644759
rt5665 = devm_kzalloc(&i2c->dev, sizeof(struct rt5665_priv),
@@ -4774,24 +4769,13 @@ static int rt5665_i2c_probe(struct i2c_client *i2c)
47744769
else
47754770
rt5665_parse_dt(rt5665, &i2c->dev);
47764771

4777-
for (i = 0; i < ARRAY_SIZE(rt5665->supplies); i++)
4778-
rt5665->supplies[i].supply = rt5665_supply_names[i];
4779-
4780-
ret = devm_regulator_bulk_get(&i2c->dev, ARRAY_SIZE(rt5665->supplies),
4781-
rt5665->supplies);
4772+
ret = devm_regulator_bulk_get_enable(&i2c->dev, ARRAY_SIZE(rt5665_supply_names),
4773+
rt5665_supply_names);
47824774
if (ret != 0) {
47834775
dev_err(&i2c->dev, "Failed to request supplies: %d\n", ret);
47844776
return ret;
47854777
}
47864778

4787-
ret = regulator_bulk_enable(ARRAY_SIZE(rt5665->supplies),
4788-
rt5665->supplies);
4789-
if (ret != 0) {
4790-
dev_err(&i2c->dev, "Failed to enable supplies: %d\n", ret);
4791-
return ret;
4792-
}
4793-
4794-
47954779
rt5665->gpiod_ldo1_en = devm_gpiod_get_optional(&i2c->dev,
47964780
"realtek,ldo1-en",
47974781
GPIOD_OUT_HIGH);

0 commit comments

Comments
 (0)