]> git.hungrycats.org Git - linux/commitdiff
[PATCH] OSS: add sysfs class support for OSS sound devices
authorGreg Kroah-Hartman <greg@kroah.com>
Mon, 19 Jan 2004 08:45:11 +0000 (00:45 -0800)
committerGreg Kroah-Hartman <greg@kroah.com>
Mon, 19 Jan 2004 08:45:11 +0000 (00:45 -0800)
This patch adds support for all OSS sound devices.

This patch is based on a work originally written by
Leann Ogasawara <ogasawara@osdl.org>

sound/oss/soundcard.c
sound/sound_core.c

index 3b023a9212d8f7843c2009845b55d806f0e3d613..a1170a7487c0c678e7cb782625d057d4fa5f0931 100644 (file)
@@ -73,6 +73,7 @@ static char     dma_alloc_map[MAX_DMA_CHANNELS];
 
 
 unsigned long seq_time = 0;    /* Time for /dev/sequencer */
+extern struct class_simple *sound_class;
 
 /*
  * Table for configurable mixer volume handling
@@ -569,6 +570,9 @@ static int __init oss_init(void)
                devfs_mk_cdev(MKDEV(SOUND_MAJOR, dev_list[i].minor),
                                S_IFCHR | dev_list[i].mode,
                                "sound/%s", dev_list[i].name);
+               class_simple_device_add(sound_class, 
+                                       MKDEV(SOUND_MAJOR, dev_list[i].minor),
+                                       NULL, "%s", dev_list[i].name);
 
                if (!dev_list[i].num)
                        continue;
@@ -578,6 +582,10 @@ static int __init oss_init(void)
                                                dev_list[i].minor + (j*0x10)),
                                        S_IFCHR | dev_list[i].mode,
                                        "sound/%s%d", dev_list[i].name, j);
+                       class_simple_device_add(sound_class,
+                                       MKDEV(SOUND_MAJOR, dev_list[i].minor + (j*0x10)),
+                                       NULL,
+                                       "%s%d", dev_list[i].name, j);
                }
        }
 
@@ -593,10 +601,13 @@ static void __exit oss_cleanup(void)
 
        for (i = 0; i < sizeof (dev_list) / sizeof *dev_list; i++) {
                devfs_remove("sound/%s", dev_list[i].name);
+               class_simple_device_remove(MKDEV(SOUND_MAJOR, dev_list[i].minor));
                if (!dev_list[i].num)
                        continue;
-               for (j = 1; j < *dev_list[i].num; j++)
+               for (j = 1; j < *dev_list[i].num; j++) {
                        devfs_remove("sound/%s%d", dev_list[i].name, j);
+                       class_simple_device_remove(MKDEV(SOUND_MAJOR, dev_list[i].minor + (j*0x10)));
+               }
        }
        
        unregister_sound_special(1);
index 09fb8ff48a1c7a00754da5f5514aa294f797d897..e8d5b2edcfd8313bea2b753293028422bf1ff8d2 100644 (file)
@@ -65,6 +65,9 @@ extern int msnd_classic_init(void);
 extern int msnd_pinnacle_init(void);
 #endif
 
+struct class_simple *sound_class;
+EXPORT_SYMBOL(sound_class);
+
 /*
  *     Low level list operator. Scan the ordered list, find a hole and
  *     join into it. Called with the lock asserted
@@ -171,6 +174,8 @@ static int sound_insert_unit(struct sound_unit **list, struct file_operations *f
 
        devfs_mk_cdev(MKDEV(SOUND_MAJOR, s->unit_minor),
                        S_IFCHR | mode, s->name);
+       class_simple_device_add(sound_class, MKDEV(SOUND_MAJOR, s->unit_minor),
+                               NULL, s->name+6);
        return r;
 
  fail:
@@ -193,6 +198,7 @@ static void sound_remove_unit(struct sound_unit **list, int unit)
        spin_unlock(&sound_loader_lock);
        if (p) {
                devfs_remove(p->name);
+               class_simple_device_remove(MKDEV(SOUND_MAJOR, p->unit_minor));
                kfree(p);
        }
 }
@@ -556,6 +562,7 @@ static void __exit cleanup_soundcore(void)
           empty */
        unregister_chrdev(SOUND_MAJOR, "sound");
        devfs_remove("sound");
+       class_simple_destroy(sound_class);
 }
 
 static int __init init_soundcore(void)
@@ -565,6 +572,9 @@ static int __init init_soundcore(void)
                return -EBUSY;
        }
        devfs_mk_dir ("sound");
+       sound_class = class_simple_create(THIS_MODULE, "sound");
+       if (IS_ERR(sound_class))
+               return PTR_ERR(sound_class);
 
        return 0;
 }