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: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Link: https://lore.kernel.org/r/87ftmt5rnx.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
4a81e8f30d
commit
ae2f484928
@ -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,
|
|||||||
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,
|
|||||||
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",
|
||||||
|
Loading…
Reference in New Issue
Block a user