From 66c51573b89d0a5c1089139a2f0dd029a755c37d Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Fri, 26 Jul 2019 13:50:34 +0900 Subject: [PATCH] ASoC: soc-component: add snd_soc_component_suspend() 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 Link: https://lore.kernel.org/r/877e855rn0.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- 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 302e27a89d47..cdb014f41fd1 100644 --- a/include/sound/soc-component.h +++ b/include/sound/soc-component.h @@ -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 */ diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c index cf0d20a877e6..f0e63cd991c8 100644 --- a/sound/soc/soc-component.c +++ b/sound/soc/soc-component.c @@ -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; +} diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 9ba19efcc56c..855b19abc1d2 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -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 */