]> git.proxmox.com Git - mirror_ubuntu-disco-kernel.git/commitdiff
ALSA: hda - Create AFG sysfs node at last
authorTakashi Iwai <tiwai@suse.de>
Wed, 8 Apr 2015 09:41:59 +0000 (11:41 +0200)
committerTakashi Iwai <tiwai@suse.de>
Wed, 8 Apr 2015 09:41:59 +0000 (11:41 +0200)
... so that user-space can know that the whole nodes have been
created.  Unfortunately, this can't be implemented easily in race-free
way, so it's a kind of compromise.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/hda/hdac_sysfs.c

index b358d515780238e0ed7367c9b6c9b6b46e3266d3..18aea43d230d9f873e477fd716eb85abd3970464 100644 (file)
@@ -313,12 +313,12 @@ static void widget_tree_free(struct hdac_device *codec)
 
        if (!tree)
                return;
+       free_widget_node(tree->afg, &widget_afg_group);
        if (tree->nodes) {
                for (p = tree->nodes; *p; p++)
                        free_widget_node(*p, &widget_node_group);
                kfree(tree->nodes);
        }
-       free_widget_node(tree->afg, &widget_afg_group);
        if (tree->root)
                kobject_put(tree->root);
        kfree(tree);
@@ -362,13 +362,6 @@ static int widget_tree_create(struct hdac_device *codec)
        if (!tree->root)
                return -ENOMEM;
 
-       if (codec->afg) {
-               err = add_widget_node(tree->root, codec->afg,
-                                     &widget_afg_group, &tree->afg);
-               if (err < 0)
-                       return err;
-       }
-
        tree->nodes = kcalloc(codec->num_nodes + 1, sizeof(*tree->nodes),
                              GFP_KERNEL);
        if (!tree->nodes)
@@ -381,6 +374,13 @@ static int widget_tree_create(struct hdac_device *codec)
                        return err;
        }
 
+       if (codec->afg) {
+               err = add_widget_node(tree->root, codec->afg,
+                                     &widget_afg_group, &tree->afg);
+               if (err < 0)
+                       return err;
+       }
+
        kobject_uevent(tree->root, KOBJ_CHANGE);
        return 0;
 }