Commit 2927d6ee authored by Mark Brown's avatar Mark Brown Committed by Takashi Iwai

ALSA: ASoC: Refactor DAPM event handler

The DAPM event callback code has many layers of indentation, taking it
over 80 columns. Refactor the code to give less indentation in order to
avoid checkpatch issues on further changes and exploding indentation.
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 462dba28
...@@ -586,45 +586,48 @@ static int dapm_power_widgets(struct snd_soc_codec *codec, int event) ...@@ -586,45 +586,48 @@ static int dapm_power_widgets(struct snd_soc_codec *codec, int event)
power_change = (w->power == power) ? 0: 1; power_change = (w->power == power) ? 0: 1;
w->power = power; w->power = power;
if (!power_change)
continue;
/* call any power change event handlers */ /* call any power change event handlers */
if (power_change) { if (w->event)
if (w->event) { pr_debug("power %s event for %s flags %x\n",
pr_debug("power %s event for %s flags %x\n", w->power ? "on" : "off",
w->power ? "on" : "off", w->name, w->event_flags); w->name, w->event_flags);
if (power) {
/* power up event */ /* power up pre event */
if (w->event_flags & SND_SOC_DAPM_PRE_PMU) { if (power && w->event &&
ret = w->event(w, (w->event_flags & SND_SOC_DAPM_PRE_PMU)) {
NULL, SND_SOC_DAPM_PRE_PMU); ret = w->event(w, NULL, SND_SOC_DAPM_PRE_PMU);
if (ret < 0) if (ret < 0)
return ret; return ret;
} }
dapm_update_bits(w);
if (w->event_flags & SND_SOC_DAPM_POST_PMU){ /* power down pre event */
ret = w->event(w, if (!power && w->event &&
NULL, SND_SOC_DAPM_POST_PMU); (w->event_flags & SND_SOC_DAPM_PRE_PMD)) {
if (ret < 0) ret = w->event(w, NULL, SND_SOC_DAPM_PRE_PMD);
return ret; if (ret < 0)
} return ret;
} else { }
/* power down event */
if (w->event_flags & SND_SOC_DAPM_PRE_PMD) { dapm_update_bits(w);
ret = w->event(w,
NULL, SND_SOC_DAPM_PRE_PMD); /* power up post event */
if (ret < 0) if (power && w->event &&
return ret; (w->event_flags & SND_SOC_DAPM_POST_PMU)) {
} ret = w->event(w,
dapm_update_bits(w); NULL, SND_SOC_DAPM_POST_PMU);
if (w->event_flags & SND_SOC_DAPM_POST_PMD) { if (ret < 0)
ret = w->event(w, return ret;
NULL, SND_SOC_DAPM_POST_PMD); }
if (ret < 0)
return ret; /* power down post event */
} if (!power && w->event &&
} (w->event_flags & SND_SOC_DAPM_POST_PMD)) {
} else ret = w->event(w, NULL, SND_SOC_DAPM_POST_PMD);
/* no event handler */ if (ret < 0)
dapm_update_bits(w); return ret;
} }
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment