]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
greybus: audio: Reduce codec->lock granularity
authorVaibhav Agarwal <vaibhav.agarwal@linaro.org>
Wed, 4 May 2016 10:59:23 +0000 (16:29 +0530)
committerGreg Kroah-Hartman <gregkh@google.com>
Wed, 4 May 2016 18:30:20 +0000 (11:30 -0700)
Earlier codec->lock protects almost complete register/unregister
module function. This can be reduced to specific operations.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
drivers/staging/greybus/audio_codec.c

index dbcff218badd4a8e9e4b67eb8d45fd32ea1bb307..23dde708c76f8c4a3904781a9f1a46d08cf5dd15 100644 (file)
@@ -933,20 +933,17 @@ int gbaudio_register_module(struct gbaudio_module_info *module)
        card = codec->card->snd_card;
 
        down_write(&card->controls_rwsem);
-       mutex_lock(&gbcodec->lock);
 
        if (module->num_dais) {
                dev_err(gbcodec->dev,
                        "%d:DAIs not supported via gbcodec driver\n",
                        module->num_dais);
-               mutex_unlock(&gbcodec->lock);
                up_write(&card->controls_rwsem);
                return -EINVAL;
        }
 
        ret = gbaudio_init_jack(module, codec);
        if (ret) {
-               mutex_unlock(&gbcodec->lock);
                up_write(&card->controls_rwsem);
                return ret;
        }
@@ -976,12 +973,14 @@ int gbaudio_register_module(struct gbaudio_module_info *module)
 #endif
        }
 
+       mutex_lock(&gbcodec->lock);
        list_add(&module->list, &gbcodec->module_list);
+       mutex_unlock(&gbcodec->lock);
+
        if (codec->card->instantiated)
                ret = snd_soc_dapm_new_widgets(&codec->dapm);
        dev_dbg(codec->dev, "Registered %s module\n", module->name);
 
-       mutex_unlock(&gbcodec->lock);
        up_write(&card->controls_rwsem);
        return ret;
 }
@@ -1065,6 +1064,7 @@ void gbaudio_unregister_module(struct gbaudio_module_info *module)
        gbaudio_codec_cleanup(module);
        list_del(&module->list);
        dev_dbg(codec->dev, "Process Unregister %s module\n", module->name);
+       mutex_unlock(&gbcodec->lock);
 
 #ifdef CONFIG_SND_JACK
        /* free jack devices for this module from codec->jack_list */
@@ -1098,7 +1098,6 @@ void gbaudio_unregister_module(struct gbaudio_module_info *module)
 
        dev_dbg(codec->dev, "Unregistered %s module\n", module->name);
 
-       mutex_unlock(&gbcodec->lock);
        up_write(&card->controls_rwsem);
 }
 EXPORT_SYMBOL(gbaudio_unregister_module);