patch-2.4.0-test9 linux/drivers/sound/soundcard.c

Next file: linux/drivers/sound/trident.c
Previous file: linux/drivers/sound/sound_timer.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.0-test8/linux/drivers/sound/soundcard.c linux/drivers/sound/soundcard.c
@@ -25,6 +25,7 @@
 #include <linux/config.h>
 
 #include "sound_config.h"
+#include <linux/init.h>
 #include <linux/types.h>
 #include <linux/errno.h>
 #include <linux/signal.h>
@@ -51,8 +52,6 @@
 #define valid_dma(n) ((n) >= 0 && (n) < MAX_DMA_CHANNELS && (n) != 4)
 #endif
 
-static int      chrdev_registered = 0;
-
 /*
  * Table for permanently allocated memory (used when unloading the module)
  */
@@ -267,6 +266,7 @@
 	DEB(printk("sound_release(dev=%d)\n", dev));
 	switch (dev & 0x0f) {
 	case SND_DEV_CTL:
+		dev >>= 4;
 		if (mixer_devs[dev]->owner)
 			__MOD_DEC_USE_COUNT (mixer_devs[dev]->owner);
 		break;
@@ -582,34 +582,6 @@
 	}
 }
 
-#ifdef MODULE
-static void
-#else
-void
-#endif
-soundcard_init(void)
-{
-	/* drag in sound_syms.o */
-	{
-		extern char sound_syms_symbol;
-		sound_syms_symbol = 0;
-	}
-
-#ifndef MODULE
-	create_special_devices();
-	chrdev_registered = 1;
-#endif
-
-	soundcard_register_devfs(1); /* register after we know # of devices */
-}
-
-#ifdef MODULE
-
-static void destroy_special_devices(void)
-{
-	unregister_sound_special(1);
-	unregister_sound_special(8);
-}
 
 static int dmabuf = 0;
 static int dmabug = 0;
@@ -617,14 +589,21 @@
 MODULE_PARM(dmabuf, "i");
 MODULE_PARM(dmabug, "i");
 
-int init_module(void)
+static int __init oss_init(void)
 {
 	int             err;
+	
+	/* drag in sound_syms.o */
+	{
+		extern char sound_syms_symbol;
+		sound_syms_symbol = 0;
+	}
 
 #ifdef CONFIG_PCI
 	if(dmabug)
 		isa_dma_bridge_buggy = dmabug;
 #endif
+
 	err = create_special_devices();
 	if (err) {
 		printk(KERN_ERR "sound: driver already loaded/included in kernel\n");
@@ -634,8 +613,7 @@
 	/* Protecting the innocent */
 	sound_dmap_flag = (dmabuf > 0 ? 1 : 0);
 
-	chrdev_registered = 1;
-	soundcard_init();
+	soundcard_register_devfs(1);
 
 	if (sound_nblocks >= 1024)
 		printk(KERN_ERR "Sound warning: Deallocation table was too small.\n");
@@ -643,7 +621,7 @@
 	return 0;
 }
 
-void cleanup_module(void)
+static void __exit oss_cleanup(void)
 {
 	int i;
 
@@ -651,8 +629,9 @@
 		return;
 
 	soundcard_register_devfs (0);
-	if (chrdev_registered)
-		destroy_special_devices();
+	
+	unregister_sound_special(1);
+	unregister_sound_special(8);
 
 	sound_stop_timer();
 
@@ -668,7 +647,10 @@
 		vfree(sound_mem_blocks[i]);
 
 }
-#endif
+
+module_init(oss_init);
+module_exit(oss_cleanup);
+
 
 int sound_alloc_dma(int chn, char *deviceID)
 {

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)