summaryrefslogtreecommitdiff
path: root/sound/soc/soc-dapm.c
diff options
context:
space:
mode:
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>2022-10-19 00:36:51 +0000
committerMark Brown <broonie@kernel.org>2022-10-19 13:05:30 +0100
commit9941ba4baed0a4388028e2ce3ff769d50324068a (patch)
tree6a1edb1b1c85e0c20f04d89830a512485402af97 /sound/soc/soc-dapm.c
parent2e3fafbb14300212d056d1ad2163bb38453be069 (diff)
downloadlwn-9941ba4baed0a4388028e2ce3ff769d50324068a.tar.gz
lwn-9941ba4baed0a4388028e2ce3ff769d50324068a.zip
ASoC: soc-dapm.c: merge dapm_power_one_widget() and dapm_widget_set_power()
dapm_widget_set_power() (= X) is called only from dapm_power_one_widget() (= Y), and total purpose of these functions are calling dapm_seq_insert() (= a) accordingly for each widget. (X) static void dapm_widget_set_power(...) { ... if (power) (a) dapm_seq_insert(w, up_list, true); else (a) dapm_seq_insert(w, down_list, false); } (Y) static void dapm_power_one_widget(...) { .. switch (w->id) { case snd_soc_dapm_pre: (a) dapm_seq_insert(w, down_list, false); break; case snd_soc_dapm_post: (a) dapm_seq_insert(w, up_list, true); break; default: power = dapm_widget_power_check(w); (X) dapm_widget_set_power(w, power, up_list, down_list); break; } } It should be more simple, but the code is unnecessarily complicated, and difficult to read/understand. This patch merge these into one. Link: https://lore.kernel.org/all/87tu42owdd.wl-kuninori.morimoto.gx@renesas.com/ Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Reviewed-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com> Link: https://lore.kernel.org/r/8735bktzrx.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/soc-dapm.c')
-rw-r--r--sound/soc/soc-dapm.c40
1 files changed, 16 insertions, 24 deletions
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index d4281e776e44..7a170e16d34e 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -1873,11 +1873,25 @@ static void dapm_widget_set_peer_power(struct snd_soc_dapm_widget *peer,
dapm_mark_dirty(peer, "peer state change");
}
-static void dapm_widget_set_power(struct snd_soc_dapm_widget *w, bool power,
+static void dapm_power_one_widget(struct snd_soc_dapm_widget *w,
struct list_head *up_list,
struct list_head *down_list)
{
struct snd_soc_dapm_path *path;
+ int power;
+
+ switch (w->id) {
+ case snd_soc_dapm_pre:
+ power = 0;
+ goto end;
+ case snd_soc_dapm_post:
+ power = 1;
+ goto end;
+ default:
+ break;
+ }
+
+ power = dapm_widget_power_check(w);
if (w->power == power)
return;
@@ -1897,35 +1911,13 @@ static void dapm_widget_set_power(struct snd_soc_dapm_widget *w, bool power,
if (!w->is_supply)
snd_soc_dapm_widget_for_each_sink_path(w, path)
dapm_widget_set_peer_power(path->sink, power, path->connect);
-
+end:
if (power)
dapm_seq_insert(w, up_list, true);
else
dapm_seq_insert(w, down_list, false);
}
-static void dapm_power_one_widget(struct snd_soc_dapm_widget *w,
- struct list_head *up_list,
- struct list_head *down_list)
-{
- int power;
-
- switch (w->id) {
- case snd_soc_dapm_pre:
- dapm_seq_insert(w, down_list, false);
- break;
- case snd_soc_dapm_post:
- dapm_seq_insert(w, up_list, true);
- break;
-
- default:
- power = dapm_widget_power_check(w);
-
- dapm_widget_set_power(w, power, up_list, down_list);
- break;
- }
-}
-
static bool dapm_idle_bias_off(struct snd_soc_dapm_context *dapm)
{
if (dapm->idle_bias_off)