Skip to content

Commit 4a086e4

Browse files
committed
ASoC: wm8996: Switch to using common code for managing CPVDD supply
Nice code saving. Signed-off-by: Mark Brown <[email protected]>
1 parent 177f72f commit 4a086e4

File tree

1 file changed

+5
-27
lines changed

1 file changed

+5
-27
lines changed

sound/soc/codecs/wm8996.c

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ struct wm8996_priv {
7373

7474
struct regulator_bulk_data supplies[WM8996_NUM_SUPPLIES];
7575
struct notifier_block disable_nb[WM8996_NUM_SUPPLIES];
76-
struct regulator *cpvdd;
7776
int bg_ena;
7877

7978
struct wm8996_pdata pdata;
@@ -793,29 +792,18 @@ static int bg_event(struct snd_soc_dapm_widget *w,
793792
static int cp_event(struct snd_soc_dapm_widget *w,
794793
struct snd_kcontrol *kcontrol, int event)
795794
{
796-
struct snd_soc_codec *codec = w->codec;
797-
struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec);
798795
int ret = 0;
799796

800797
switch (event) {
801-
case SND_SOC_DAPM_PRE_PMU:
802-
ret = regulator_enable(wm8996->cpvdd);
803-
if (ret != 0)
804-
dev_err(codec->dev, "Failed to enable CPVDD: %d\n",
805-
ret);
806-
break;
807798
case SND_SOC_DAPM_POST_PMU:
808799
msleep(5);
809800
break;
810-
case SND_SOC_DAPM_POST_PMD:
811-
regulator_disable_deferred(wm8996->cpvdd, 20);
812-
break;
813801
default:
814802
BUG();
815803
ret = -EINVAL;
816804
}
817805

818-
return ret;
806+
return 0;
819807
}
820808

821809
static int rmv_short_event(struct snd_soc_dapm_widget *w,
@@ -1117,12 +1105,12 @@ SND_SOC_DAPM_INPUT("IN2RP"),
11171105
SND_SOC_DAPM_INPUT("DMIC1DAT"),
11181106
SND_SOC_DAPM_INPUT("DMIC2DAT"),
11191107

1108+
SND_SOC_DAPM_REGULATOR_SUPPLY("CPVDD", 20),
11201109
SND_SOC_DAPM_SUPPLY_S("SYSCLK", 1, WM8996_AIF_CLOCKING_1, 0, 0, NULL, 0),
11211110
SND_SOC_DAPM_SUPPLY_S("SYSDSPCLK", 2, WM8996_CLOCKING_1, 1, 0, NULL, 0),
11221111
SND_SOC_DAPM_SUPPLY_S("AIFCLK", 2, WM8996_CLOCKING_1, 2, 0, NULL, 0),
11231112
SND_SOC_DAPM_SUPPLY_S("Charge Pump", 2, WM8996_CHARGE_PUMP_1, 15, 0, cp_event,
1124-
SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
1125-
SND_SOC_DAPM_POST_PMD),
1113+
SND_SOC_DAPM_POST_PMU),
11261114
SND_SOC_DAPM_SUPPLY("Bandgap", SND_SOC_NOPM, 0, 0, bg_event,
11271115
SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
11281116
SND_SOC_DAPM_SUPPLY("LDO2", WM8996_POWER_MANAGEMENT_2, 1, 0, NULL, 0),
@@ -1281,6 +1269,7 @@ static const struct snd_soc_dapm_route wm8996_dapm_routes[] = {
12811269
{ "AIFCLK", NULL, "SYSCLK" },
12821270
{ "SYSDSPCLK", NULL, "SYSCLK" },
12831271
{ "Charge Pump", NULL, "SYSCLK" },
1272+
{ "Charge Pump", NULL, "CPVDD" },
12841273

12851274
{ "MICB1", NULL, "LDO2" },
12861275
{ "MICB1", NULL, "MICB1 Audio" },
@@ -3049,7 +3038,6 @@ static int wm8996_remove(struct snd_soc_codec *codec)
30493038
for (i = 0; i < ARRAY_SIZE(wm8996->supplies); i++)
30503039
regulator_unregister_notifier(wm8996->supplies[i].consumer,
30513040
&wm8996->disable_nb[i]);
3052-
regulator_put(wm8996->cpvdd);
30533041
regulator_bulk_free(ARRAY_SIZE(wm8996->supplies), wm8996->supplies);
30543042

30553043
return 0;
@@ -3172,18 +3160,11 @@ static __devinit int wm8996_i2c_probe(struct i2c_client *i2c,
31723160
goto err_gpio;
31733161
}
31743162

3175-
wm8996->cpvdd = regulator_get(&i2c->dev, "CPVDD");
3176-
if (IS_ERR(wm8996->cpvdd)) {
3177-
ret = PTR_ERR(wm8996->cpvdd);
3178-
dev_err(&i2c->dev, "Failed to get CPVDD: %d\n", ret);
3179-
goto err_get;
3180-
}
3181-
31823163
ret = regulator_bulk_enable(ARRAY_SIZE(wm8996->supplies),
31833164
wm8996->supplies);
31843165
if (ret != 0) {
31853166
dev_err(&i2c->dev, "Failed to enable supplies: %d\n", ret);
3186-
goto err_cpvdd;
3167+
goto err_get;
31873168
}
31883169

31893170
if (wm8996->pdata.ldo_ena > 0) {
@@ -3245,8 +3226,6 @@ static __devinit int wm8996_i2c_probe(struct i2c_client *i2c,
32453226
if (wm8996->pdata.ldo_ena > 0)
32463227
gpio_set_value_cansleep(wm8996->pdata.ldo_ena, 0);
32473228
regulator_bulk_disable(ARRAY_SIZE(wm8996->supplies), wm8996->supplies);
3248-
err_cpvdd:
3249-
regulator_put(wm8996->cpvdd);
32503229
err_get:
32513230
regulator_bulk_free(ARRAY_SIZE(wm8996->supplies), wm8996->supplies);
32523231
err_gpio:
@@ -3263,7 +3242,6 @@ static __devexit int wm8996_i2c_remove(struct i2c_client *client)
32633242

32643243
snd_soc_unregister_codec(&client->dev);
32653244
wm8996_free_gpio(wm8996);
3266-
regulator_put(wm8996->cpvdd);
32673245
regulator_bulk_free(ARRAY_SIZE(wm8996->supplies), wm8996->supplies);
32683246
regmap_exit(wm8996->regmap);
32693247
if (wm8996->pdata.ldo_ena > 0) {

0 commit comments

Comments
 (0)