[alsa-devel] [PATCH 16/25] ASoC: soc-component: add snd_soc_component_suspend()
Kuninori Morimoto
kuninori.morimoto.gx at renesas.com
Wed Jul 24 03:52:34 CEST 2019
From: Kuninori Morimoto <kuninori.morimoto.gx at renesas.com>
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 at renesas.com>
---
include/sound/soc-component.h | 1 +
sound/soc/soc-component.c | 7 +++++++
sound/soc/soc-core.c | 4 +---
3 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h
index 96ea44e..cf41ba4 100644
--- a/include/sound/soc-component.h
+++ b/include/sound/soc-component.h
@@ -356,5 +356,6 @@ int snd_soc_component_pcm_new(struct snd_soc_component *component,
struct snd_soc_pcm_runtime *rtd);
void snd_soc_component_pcm_free(struct snd_soc_component *component,
struct snd_pcm *pcm);
+void snd_soc_component_suspend(struct snd_soc_component *component);
#endif /* __SOC_COMPONENT_H */
diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c
index 4473f55..165d111 100644
--- a/sound/soc/soc-component.c
+++ b/sound/soc/soc-component.c
@@ -419,3 +419,10 @@ void snd_soc_component_pcm_free(struct snd_soc_component *component,
if (component->driver->pcm_free)
component->driver->pcm_free(pcm);
}
+
+void snd_soc_component_suspend(struct snd_soc_component *component)
+{
+ if (component->driver->suspend)
+ component->driver->suspend(component);
+ component->suspended = 1;
+}
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 83b04d9..39b5a64 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -561,9 +561,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 */
--
2.7.4
More information about the Alsa-devel
mailing list