ASoC: soc-core: add soc_cleanup_component()
We need to cleanup component when soc_probe_component() was failed, or when soc_remove_component() was called. But they are cleanuping component on each way. (And soc_probe_component() doesn't call snd_soc_dapm_free(), but it should). Same code in many places makes code un-understandable. This patch adds new soc_cleanup_component() and call it from snd_probe_component() and snd_remove_component(). Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
52293596f5
commit
22d1423187
@ -937,21 +937,24 @@ _err_defer:
|
|||||||
return -EPROBE_DEFER;
|
return -EPROBE_DEFER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void soc_cleanup_component(struct snd_soc_component *component)
|
||||||
|
{
|
||||||
|
list_del(&component->card_list);
|
||||||
|
snd_soc_dapm_free(snd_soc_component_get_dapm(component));
|
||||||
|
soc_cleanup_component_debugfs(component);
|
||||||
|
component->card = NULL;
|
||||||
|
module_put(component->dev->driver->owner);
|
||||||
|
}
|
||||||
|
|
||||||
static void soc_remove_component(struct snd_soc_component *component)
|
static void soc_remove_component(struct snd_soc_component *component)
|
||||||
{
|
{
|
||||||
if (!component->card)
|
if (!component->card)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
list_del(&component->card_list);
|
|
||||||
|
|
||||||
if (component->driver->remove)
|
if (component->driver->remove)
|
||||||
component->driver->remove(component);
|
component->driver->remove(component);
|
||||||
|
|
||||||
snd_soc_dapm_free(snd_soc_component_get_dapm(component));
|
soc_cleanup_component(component);
|
||||||
|
|
||||||
soc_cleanup_component_debugfs(component);
|
|
||||||
component->card = NULL;
|
|
||||||
module_put(component->dev->driver->owner);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void soc_remove_dai(struct snd_soc_dai *dai, int order)
|
static void soc_remove_dai(struct snd_soc_dai *dai, int order)
|
||||||
@ -1360,6 +1363,8 @@ static int soc_probe_component(struct snd_soc_card *card,
|
|||||||
|
|
||||||
component->card = card;
|
component->card = card;
|
||||||
dapm->card = card;
|
dapm->card = card;
|
||||||
|
INIT_LIST_HEAD(&component->card_list);
|
||||||
|
INIT_LIST_HEAD(&dapm->list);
|
||||||
soc_set_name_prefix(card, component);
|
soc_set_name_prefix(card, component);
|
||||||
|
|
||||||
soc_init_component_debugfs(component);
|
soc_init_component_debugfs(component);
|
||||||
@ -1422,12 +1427,9 @@ static int soc_probe_component(struct snd_soc_card *card,
|
|||||||
/* see for_each_card_components */
|
/* see for_each_card_components */
|
||||||
list_add(&component->card_list, &card->component_dev_list);
|
list_add(&component->card_list, &card->component_dev_list);
|
||||||
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
err_probe:
|
err_probe:
|
||||||
soc_cleanup_component_debugfs(component);
|
if (ret < 0)
|
||||||
component->card = NULL;
|
soc_cleanup_component(component);
|
||||||
module_put(component->dev->driver->owner);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user