Commit 486c7978 authored by Kuninori Morimoto's avatar Kuninori Morimoto Committed by Mark Brown

ASoC: soc-core: add snd_soc_del_component_unlocked()

It is easy to read code if it is cleanly using paired function/naming,
like start <-> stop, register <-> unregister, etc, etc.
But, current ALSA SoC code is very random, unbalance, not paired, etc.
It is easy to create bug at the such code, and is difficult to debug.

Now ALSA SoC has snd_soc_add_component(), but there is no paired
snd_soc_del_component(). Thus, snd_soc_unregister_component() is
calling cleanup function randomly. it is difficult to read.
This patch adds missing snd_soc_del_component_unlocked() and
balance up code.
Signed-off-by: default avatarKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: default avatarRanjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/8736f23jn4.wl-kuninori.morimoto.gx@renesas.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 5bd7e08b
...@@ -2764,12 +2764,7 @@ static void snd_soc_component_add(struct snd_soc_component *component) ...@@ -2764,12 +2764,7 @@ static void snd_soc_component_add(struct snd_soc_component *component)
mutex_unlock(&client_mutex); mutex_unlock(&client_mutex);
} }
static void snd_soc_component_cleanup(struct snd_soc_component *component) static void snd_soc_component_del(struct snd_soc_component *component)
{
snd_soc_unregister_dais(component);
}
static void snd_soc_component_del_unlocked(struct snd_soc_component *component)
{ {
struct snd_soc_card *card = component->card; struct snd_soc_card *card = component->card;
...@@ -2823,6 +2818,12 @@ static void snd_soc_try_rebind_card(void) ...@@ -2823,6 +2818,12 @@ static void snd_soc_try_rebind_card(void)
list_del(&card->list); list_del(&card->list);
} }
static void snd_soc_del_component_unlocked(struct snd_soc_component *component)
{
snd_soc_unregister_dais(component);
snd_soc_component_del(component);
}
int snd_soc_add_component(struct device *dev, int snd_soc_add_component(struct device *dev,
struct snd_soc_component *component, struct snd_soc_component *component,
const struct snd_soc_component_driver *component_driver, const struct snd_soc_component_driver *component_driver,
...@@ -2855,7 +2856,7 @@ int snd_soc_add_component(struct device *dev, ...@@ -2855,7 +2856,7 @@ int snd_soc_add_component(struct device *dev,
return 0; return 0;
err_cleanup: err_cleanup:
snd_soc_component_cleanup(component); snd_soc_del_component_unlocked(component);
err_free: err_free:
return ret; return ret;
} }
...@@ -2893,15 +2894,12 @@ static int __snd_soc_unregister_component(struct device *dev) ...@@ -2893,15 +2894,12 @@ static int __snd_soc_unregister_component(struct device *dev)
if (dev != component->dev) if (dev != component->dev)
continue; continue;
snd_soc_component_del_unlocked(component); snd_soc_del_component_unlocked(component);
found = 1; found = 1;
break; break;
} }
mutex_unlock(&client_mutex); mutex_unlock(&client_mutex);
if (found)
snd_soc_component_cleanup(component);
return found; return found;
} }
......
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