ASoC: soc-component: add snd_soc_component_suspend()
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Fri, 26 Jul 2019 04:50:34 +0000 (13:50 +0900)
committerMark Brown <broonie@kernel.org>
Mon, 5 Aug 2019 15:20:16 +0000 (16:20 +0100)
Current ALSA SoC is directly using component->driver->xxx,
thus, it is deep nested, and makes code difficult to read,
and is not good for encapsulation.
This patch adds new snd_soc_component_suspend() and use it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/877e855rn0.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
include/sound/soc-component.h
sound/soc/soc-component.c
sound/soc/soc-core.c

index 302e27a89d4718d460e8ca48b1bf6e11af60509d..cdb014f41fd1844734ba23685d3168eafc4f6fc1 100644 (file)
@@ -353,5 +353,6 @@ int snd_soc_component_hw_free(struct snd_soc_component *component,
 int snd_soc_component_trigger(struct snd_soc_component *component,
                              struct snd_pcm_substream *substream,
                              int cmd);
+void snd_soc_component_suspend(struct snd_soc_component *component);
 
 #endif /* __SOC_COMPONENT_H */
index cf0d20a877e617536c6d6189af42cf5204ed6250..f0e63cd991c85c5b22592ac95a48f91a00c18542 100644 (file)
@@ -347,3 +347,10 @@ int snd_soc_component_trigger(struct snd_soc_component *component,
 
        return 0;
 }
+
+void snd_soc_component_suspend(struct snd_soc_component *component)
+{
+       if (component->driver->suspend)
+               component->driver->suspend(component);
+       component->suspended = 1;
+}
index 9ba19efcc56c9904190ac4b39d8e6f13337bc707..855b19abc1d20799271e71881055dd25dbb7afd4 100644 (file)
@@ -520,9 +520,7 @@ int snd_soc_suspend(struct device *dev)
                                /* fall through */
 
                        case SND_SOC_BIAS_OFF:
-                               if (component->driver->suspend)
-                                       component->driver->suspend(component);
-                               component->suspended = 1;
+                               snd_soc_component_suspend(component);
                                if (component->regmap)
                                        regcache_mark_dirty(component->regmap);
                                /* deactivate pins to sleep state */