ASoC: soc-core: remove duplicate mutex_unlock from snd_soc_unregister_component()
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Mon, 7 Aug 2017 02:06:40 +0000 (02:06 +0000)
committerMark Brown <broonie@kernel.org>
Mon, 7 Aug 2017 15:49:36 +0000 (16:49 +0100)
Current snd_soc_unregister_component() is using multiple mutex_unlock()
for found/non-found cases. But it is unreadable and confusable code.
This patch tidyup current code to be readable.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/soc-core.c

index b214889721986c11b10e8328dee7efabc9a4397d..3bb8c63564cfba66e3f0f6de4caf9db2c45347d1 100644 (file)
@@ -3328,21 +3328,25 @@ EXPORT_SYMBOL_GPL(snd_soc_register_component);
 void snd_soc_unregister_component(struct device *dev)
 {
        struct snd_soc_component *component;
+       int found = 0;
 
        mutex_lock(&client_mutex);
        list_for_each_entry(component, &component_list, list) {
-               if (dev == component->dev && component->registered_as_component)
-                       goto found;
+               if (dev != component->dev ||
+                   !component->registered_as_component)
+                       continue;
+
+               snd_soc_tplg_component_remove(component, SND_SOC_TPLG_INDEX_ALL);
+               snd_soc_component_del_unlocked(component);
+               found = 1;
+               break;
        }
        mutex_unlock(&client_mutex);
-       return;
 
-found:
-       snd_soc_tplg_component_remove(component, SND_SOC_TPLG_INDEX_ALL);
-       snd_soc_component_del_unlocked(component);
-       mutex_unlock(&client_mutex);
-       snd_soc_component_cleanup(component);
-       kfree(component);
+       if (found) {
+               snd_soc_component_cleanup(component);
+               kfree(component);
+       }
 }
 EXPORT_SYMBOL_GPL(snd_soc_unregister_component);