Commit 257c4dac authored by Kuninori Morimoto's avatar Kuninori Morimoto Committed by Mark Brown

ASoC: soc-component: add snd_soc_component_init()

we wantn't to directly access to component related parameter
as much as possible to keep encapsulation.
This patch adds snd_soc_component_init() for it.
Signed-off-by: default avatarKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-by: default avatarRanjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/87img7w8x2.wl-kuninori.morimoto.gx@renesas.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 32fd1204
...@@ -327,6 +327,9 @@ static inline int snd_soc_component_cache_sync( ...@@ -327,6 +327,9 @@ static inline int snd_soc_component_cache_sync(
int snd_soc_component_initialize(struct snd_soc_component *component, int snd_soc_component_initialize(struct snd_soc_component *component,
const struct snd_soc_component_driver *driver, const struct snd_soc_component_driver *driver,
struct device *dev, const char *name); struct device *dev, const char *name);
void snd_soc_component_set_aux(struct snd_soc_component *component,
struct snd_soc_aux_dev *aux);
int snd_soc_component_init(struct snd_soc_component *component);
/* component IO */ /* component IO */
int snd_soc_component_read(struct snd_soc_component *component, int snd_soc_component_read(struct snd_soc_component *component,
......
...@@ -46,6 +46,22 @@ int snd_soc_component_initialize(struct snd_soc_component *component, ...@@ -46,6 +46,22 @@ int snd_soc_component_initialize(struct snd_soc_component *component,
return 0; return 0;
} }
void snd_soc_component_set_aux(struct snd_soc_component *component,
struct snd_soc_aux_dev *aux)
{
component->init = (aux) ? aux->init : NULL;
}
int snd_soc_component_init(struct snd_soc_component *component)
{
int ret = 0;
if (component->init)
ret = component->init(component);
return soc_component_ret(component, ret);
}
/** /**
* snd_soc_component_set_sysclk - configure COMPONENT system or master clock. * snd_soc_component_set_sysclk - configure COMPONENT system or master clock.
* @component: COMPONENT * @component: COMPONENT
......
...@@ -1208,15 +1208,14 @@ static int soc_probe_component(struct snd_soc_card *card, ...@@ -1208,15 +1208,14 @@ static int soc_probe_component(struct snd_soc_card *card,
component->name); component->name);
probed = 1; probed = 1;
/* machine specific init */ /*
if (component->init) { * machine specific init
ret = component->init(component); * see
if (ret < 0) { * snd_soc_component_set_aux()
dev_err(component->dev, */
"Failed to do machine specific init %d\n", ret); ret = snd_soc_component_init(component);
goto err_probe; if (ret < 0)
} goto err_probe;
}
ret = snd_soc_add_component_controls(component, ret = snd_soc_add_component_controls(component,
component->driver->controls, component->driver->controls,
...@@ -1330,7 +1329,8 @@ static void soc_unbind_aux_dev(struct snd_soc_card *card) ...@@ -1330,7 +1329,8 @@ static void soc_unbind_aux_dev(struct snd_soc_card *card)
struct snd_soc_component *component, *_component; struct snd_soc_component *component, *_component;
for_each_card_auxs_safe(card, component, _component) { for_each_card_auxs_safe(card, component, _component) {
component->init = NULL; /* for snd_soc_component_init() */
snd_soc_component_set_aux(component, NULL);
list_del(&component->card_aux_list); list_del(&component->card_aux_list);
} }
} }
...@@ -1347,7 +1347,8 @@ static int soc_bind_aux_dev(struct snd_soc_card *card) ...@@ -1347,7 +1347,8 @@ static int soc_bind_aux_dev(struct snd_soc_card *card)
if (!component) if (!component)
return -EPROBE_DEFER; return -EPROBE_DEFER;
component->init = aux->init; /* for snd_soc_component_init() */
snd_soc_component_set_aux(component, aux);
/* see for_each_card_auxs */ /* see for_each_card_auxs */
list_add(&component->card_aux_list, &card->aux_comp_list); list_add(&component->card_aux_list, &card->aux_comp_list);
} }
......
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