[alsa-devel] [PATCH 18/21] ASoC: soc-core: use mutex_lock() at snd_soc_add_component()
Kuninori Morimoto
kuninori.morimoto.gx at renesas.com
Wed Oct 9 06:31:10 CEST 2019
From: Kuninori Morimoto <kuninori.morimoto.gx at renesas.com>
snd_soc_component_add() is using mutex_lock(),
but it should be used at snd_soc_add_component().
This patch tidyup it.
This is prepare for snd_soc_register_dais() cleanup
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx at renesas.com>
---
sound/soc/soc-core.c | 26 +++++++++++++++-----------
1 file changed, 15 insertions(+), 11 deletions(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 5d96ffa..d4f80c8 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -2748,8 +2748,6 @@ EXPORT_SYMBOL_GPL(snd_soc_component_exit_regmap);
static void snd_soc_component_add(struct snd_soc_component *component)
{
- mutex_lock(&client_mutex);
-
if (!component->driver->write && !component->driver->read) {
if (!component->regmap)
component->regmap = dev_get_regmap(component->dev,
@@ -2760,8 +2758,6 @@ static void snd_soc_component_add(struct snd_soc_component *component)
/* see for_each_component */
list_add(&component->list, &component_list);
-
- mutex_unlock(&client_mutex);
}
static void snd_soc_component_del(struct snd_soc_component *component)
@@ -2835,9 +2831,11 @@ int snd_soc_add_component(struct device *dev,
int ret;
int i;
+ mutex_lock(&client_mutex);
+
ret = snd_soc_component_initialize(component, component_driver, dev);
if (ret)
- goto err_free;
+ goto err_del;
if (component_driver->endianness) {
for (i = 0; i < num_dai; i++) {
@@ -2849,17 +2847,23 @@ int snd_soc_add_component(struct device *dev,
ret = snd_soc_register_dais(component, dai_drv, num_dai);
if (ret < 0) {
dev_err(dev, "ASoC: Failed to register DAIs: %d\n", ret);
- goto err_cleanup;
+ goto err_del;
}
snd_soc_component_add(component);
- snd_soc_try_rebind_card();
- return 0;
+err_del:
+ mutex_unlock(&client_mutex);
+
+ /*
+ * these should be called without
+ * mutex_unlock(client_mutex)
+ */
+ if (ret < 0)
+ snd_soc_del_component(component);
+ else
+ snd_soc_try_rebind_card();
-err_cleanup:
- snd_soc_del_component(component);
-err_free:
return ret;
}
EXPORT_SYMBOL_GPL(snd_soc_add_component);
--
2.7.4
More information about the Alsa-devel
mailing list