[ALSA] Nest sound devices
authorClemens Ladisch <clemens@ladisch.de>
Wed, 7 Dec 2005 08:11:05 +0000 (09:11 +0100)
committerJaroslav Kysela <perex@suse.cz>
Tue, 3 Jan 2006 11:30:36 +0000 (12:30 +0100)
Modules: ALSA Core

Make the control device parent of all other ALSA devices of a card.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
include/sound/core.h
sound/core/device.c
sound/core/sound.c

index 90ac6132ea3bced84ced0246e9af8a274313036e..dbe7a2c302723f06a34bcf393fedb71d15eba59b 100644 (file)
@@ -134,6 +134,7 @@ struct snd_card {
        wait_queue_head_t shutdown_sleep;
        struct work_struct free_workq;  /* for free in workqueue */
        struct device *dev;
+       struct class_device *parent_device;
 
 #ifdef CONFIG_PM
        unsigned int power_state;       /* power state */
index b1cf6ec567848bd4620e22c8224adbf687489b84..478264cab67e4dea95ea9abad17561fc9756699f 100644 (file)
@@ -193,7 +193,7 @@ int snd_device_register_all(struct snd_card *card)
        int err;
        
        snd_assert(card != NULL, return -ENXIO);
-       list_for_each(list, &card->devices) {
+       list_for_each_prev(list, &card->devices) {
                dev = snd_device(list);
                if (dev->state == SNDRV_DEV_BUILD && dev->ops->dev_register) {
                        if ((err = dev->ops->dev_register(dev)) < 0)
index a8eda02bcf1c0fe886b922ac0b628f7152a52921..2f6108deb2116e434d1c55f6f8308706c91b0ac0 100644 (file)
@@ -245,6 +245,7 @@ int snd_register_device(int type, struct snd_card *card, int dev,
        int minor;
        struct snd_minor *preg;
        struct device *device = NULL;
+       struct class_device *class_device = NULL;
 
        snd_assert(name, return -EINVAL);
        preg = kmalloc(sizeof(struct snd_minor) + strlen(name) + 1, GFP_KERNEL);
@@ -272,9 +273,15 @@ int snd_register_device(int type, struct snd_card *card, int dev,
        snd_minors[minor] = preg;
        if (type != SNDRV_DEVICE_TYPE_CONTROL || preg->card >= cards_limit)
                devfs_mk_cdev(MKDEV(major, minor), S_IFCHR | device_mode, "snd/%s", name);
-       if (card)
+       if (card) {
                device = card->dev;
-       class_device_create(sound_class, NULL, MKDEV(major, minor), device, "%s", name);
+               class_device = card->parent_device;
+       }
+       class_device = class_device_create(sound_class, class_device,
+                                          MKDEV(major, minor), device,
+                                          "%s", name);
+       if (type == SNDRV_DEVICE_TYPE_CONTROL)
+               card->parent_device = class_device;
 
        up(&sound_mutex);
        return 0;