greybus: audio: Reorganize sequence in GB audio bundle & codec driver
authorVaibhav Agarwal <vaibhav.agarwal@linaro.org>
Wed, 4 May 2016 10:59:22 +0000 (16:29 +0530)
committerGreg Kroah-Hartman <gregkh@google.com>
Wed, 4 May 2016 18:30:20 +0000 (11:30 -0700)
Modify sequence of register_module & unregister_module in bundle
driver. This would affect the uevent generated for above user
space. Accordingly, we need to modify snd_soc_xxx sequence in
register_module() in codec driver.

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

index c50720ee30fe3156c91f32b7e63fd7b81fe6d691..dbcff218badd4a8e9e4b67eb8d45fd32ea1bb307 100644 (file)
@@ -963,27 +963,27 @@ int gbaudio_register_module(struct gbaudio_module_info *module)
 
        /* card already instantiated, create widgets here only */
        if (codec->card->instantiated) {
-               ret = snd_soc_dapm_new_widgets(&codec->dapm);
-               if (!ret)
-                       snd_soc_dapm_link_component_dai_widgets(codec->card,
-                                                               &codec->dapm);
-       }
-
+               snd_soc_dapm_link_component_dai_widgets(codec->card,
+                                                       &codec->dapm);
 #ifdef CONFIG_SND_JACK
-       /* register jack devices for this module from codec->jack_list */
-       list_for_each_entry(jack, &codec->jack_list, list) {
-               if ((jack == &module->headset_jack)
-                   || (jack == &module->button_jack))
-                       snd_device_register(codec->card->snd_card, jack->jack);
-       }
+               /* register jack devices for this module from codec->jack_list */
+               list_for_each_entry(jack, &codec->jack_list, list) {
+                       if ((jack == &module->headset_jack)
+                           || (jack == &module->button_jack))
+                               snd_device_register(codec->card->snd_card,
+                                                   jack->jack);
+               }
 #endif
+       }
 
        list_add(&module->list, &gbcodec->module_list);
+       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 0;
+       return ret;
 }
 EXPORT_SYMBOL(gbaudio_register_module);
 
@@ -1060,11 +1060,10 @@ void gbaudio_unregister_module(struct gbaudio_module_info *module)
 
        dev_dbg(codec->dev, "Unregister %s module\n", module->name);
 
-       /* complete widget processing, if ongoing */
-       snd_soc_dapm_sync(&codec->dapm);
-
        down_write(&card->controls_rwsem);
        mutex_lock(&gbcodec->lock);
+       gbaudio_codec_cleanup(module);
+       list_del(&module->list);
        dev_dbg(codec->dev, "Process Unregister %s module\n", module->name);
 
 #ifdef CONFIG_SND_JACK
@@ -1078,8 +1077,6 @@ void gbaudio_unregister_module(struct gbaudio_module_info *module)
        }
 #endif
 
-       gbaudio_codec_cleanup(module);
-
        if (module->dapm_routes) {
                dev_dbg(codec->dev, "Removing %d routes\n",
                        module->num_dapm_routes);
@@ -1099,7 +1096,6 @@ void gbaudio_unregister_module(struct gbaudio_module_info *module)
                                           module->num_dapm_widgets);
        }
 
-       list_del(&module->list);
        dev_dbg(codec->dev, "Unregistered %s module\n", module->name);
 
        mutex_unlock(&gbcodec->lock);
index 3b763710ddf6b1566a6dfe278f8aafe9b3bb187c..27e5ff19dca6521cb03b0cd003e2cf09d0cd81d4 100644 (file)
@@ -308,18 +308,22 @@ static int gb_audio_probe(struct gb_bundle *bundle,
        }
        gbmodule->topology = topology;
 
-       /* register module with gbcodec */
-       ret = gbaudio_register_module(gbmodule);
-       if (ret)
-               goto release_topology;
-
        /* Initialize data connections */
        list_for_each_entry(dai, &gbmodule->data_list, list) {
                ret = gb_connection_enable(dai->connection);
-               if (ret)
+               if (ret) {
+                       dev_err(dev,
+                               "%d:Error while enabling %d:data connection\n",
+                               ret, dai->data_cport);
                        goto disable_data_connection;
+               }
        }
 
+       /* register module with gbcodec */
+       ret = gbaudio_register_module(gbmodule);
+       if (ret)
+               goto disable_data_connection;
+
        /* inform above layer for uevent */
        dev_dbg(dev, "Inform set_event:%d to above layer\n", 1);
        /* prepare for the audio manager */
@@ -339,9 +343,6 @@ static int gb_audio_probe(struct gb_bundle *bundle,
 disable_data_connection:
        list_for_each_entry_safe(dai, _dai, &gbmodule->data_list, list)
                gb_connection_disable(dai->connection);
-       gbaudio_unregister_module(gbmodule);
-
-release_topology:
        gbaudio_tplg_release(gbmodule);
        gbmodule->topology = NULL;
 
@@ -371,11 +372,11 @@ static void gb_audio_disconnect(struct gb_bundle *bundle)
        struct gbaudio_module_info *gbmodule = greybus_get_drvdata(bundle);
        struct gbaudio_data_connection *dai, *_dai;
 
-       gbaudio_unregister_module(gbmodule);
 
        /* inform uevent to above layers */
        gb_audio_manager_remove(gbmodule->manager_id);
 
+       gbaudio_unregister_module(gbmodule);
        gbaudio_tplg_release(gbmodule);
        gbmodule->topology = NULL;
        kfree(gbmodule->topology);