Commit ae2f4849 authored by Kuninori Morimoto's avatar Kuninori Morimoto Committed by Mark Brown

ASoC: soc-component: add snd_soc_component_open()

Current ALSA SoC is directly using component->driver->ops->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_open() and use it.
Signed-off-by: default avatarKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87ftmt5rnx.wl-kuninori.morimoto.gx@renesas.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 4a81e8f3
...@@ -338,4 +338,8 @@ int snd_soc_component_force_enable_pin_unlocked( ...@@ -338,4 +338,8 @@ int snd_soc_component_force_enable_pin_unlocked(
struct snd_soc_component *component, struct snd_soc_component *component,
const char *pin); const char *pin);
/* component driver ops */
int snd_soc_component_open(struct snd_soc_component *component,
struct snd_pcm_substream *substream);
#endif /* __SOC_COMPONENT_H */ #endif /* __SOC_COMPONENT_H */
...@@ -285,3 +285,13 @@ void snd_soc_component_module_put(struct snd_soc_component *component, ...@@ -285,3 +285,13 @@ void snd_soc_component_module_put(struct snd_soc_component *component,
if (component->driver->module_get_upon_open == !!upon_open) if (component->driver->module_get_upon_open == !!upon_open)
module_put(component->dev->driver->owner); module_put(component->dev->driver->owner);
} }
int snd_soc_component_open(struct snd_soc_component *component,
struct snd_pcm_substream *substream)
{
if (component->driver->ops &&
component->driver->ops->open)
return component->driver->ops->open(substream);
return 0;
}
...@@ -447,11 +447,7 @@ static int soc_pcm_components_open(struct snd_pcm_substream *substream, ...@@ -447,11 +447,7 @@ static int soc_pcm_components_open(struct snd_pcm_substream *substream,
return ret; return ret;
} }
if (!component->driver->ops || ret = snd_soc_component_open(component, substream);
!component->driver->ops->open)
continue;
ret = component->driver->ops->open(substream);
if (ret < 0) { if (ret < 0) {
dev_err(component->dev, dev_err(component->dev,
"ASoC: can't open component %s: %d\n", "ASoC: can't open component %s: %d\n",
......
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