patch-2.3.25 linux/drivers/char/radio-typhoon.c

Next file: linux/drivers/char/radio-zoltrix.c
Previous file: linux/drivers/char/radio-trust.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.24/linux/drivers/char/radio-typhoon.c linux/drivers/char/radio-typhoon.c
@@ -72,15 +72,8 @@
 static int typhoon_open(struct video_device *dev, int flags);
 static void typhoon_close(struct video_device *dev);
 #ifdef CONFIG_RADIO_TYPHOON_PROC_FS
-static int typhoon_read_proc(char *buf, char **start, off_t offset, int len,
-	                     int unused);
-#endif
-#ifdef MODULE
-int init_module(void);
-void cleanup_module(void);
-int typhoon_init(struct video_init *v);
-#else
-int typhoon_init(struct video_init *v) __init;
+static int typhoon_get_info(char *buf, char **start, off_t offset, int len,
+	                    int unused);
 #endif
 
 static void typhoon_setvol_generic(struct typhoon_device *dev, int vol)
@@ -306,8 +299,8 @@
 
 #ifdef CONFIG_RADIO_TYPHOON_PROC_FS
 
-static int typhoon_read_proc(char *buf, char **start, off_t offset, int len,
-	              int unused)
+static int typhoon_get_info(char *buf, char **start, off_t offset, int len,
+	              	    int unused)
 {
 	#ifdef MODULE
 	    #define MODULEPROCSTRING "Driver loaded as a module"
@@ -337,53 +330,8 @@
 	return len;
 }
 
-static struct proc_dir_entry typhoon_proc_entry = {
-	0,			/* low_ino: inode is dynamic */
-	13, "radio-typhoon",	/* length of name and name */
-	S_IFREG | S_IRUGO,	/* mode */
-	1, 0, 0,		/* nlinks, owner, group */
-	0,			/* size -- not used */
-	NULL,			/* operations -- use default */
-	&typhoon_read_proc,	/* function used to read data */
-	/* nothing more */
-};
-
 #endif /* CONFIG_RADIO_TYPHOON_PROC_FS */
 
-int typhoon_init(struct video_init *v)
-{
-	printk(KERN_INFO BANNER);
-	if (check_region(typhoon_unit.iobase, 8)) {
-		printk(KERN_ERR "radio-typhoon: port 0x%x already in use\n",
-		       typhoon_unit.iobase);
-		return -EBUSY;
-	}
-
-	typhoon_radio.priv = &typhoon_unit;
-	if (video_register_device(&typhoon_radio, VFL_TYPE_RADIO) == -1)
-		return -EINVAL;
-
-	request_region(typhoon_unit.iobase, 8, "typhoon");
-	printk(KERN_INFO "radio-typhoon: port 0x%x.\n", typhoon_unit.iobase);
-	printk(KERN_INFO "radio-typhoon: mute frequency is %lu kHz.\n",
-	       typhoon_unit.mutefreq);
-	typhoon_unit.mutefreq <<= 4;
-
-	/* mute card - prevents noisy bootups */
-	typhoon_mute(&typhoon_unit);
-
-#ifdef CONFIG_RADIO_TYPHOON_PROC_FS
-	
-	if (proc_register(&proc_root, &typhoon_proc_entry))
-	    	printk(KERN_ERR "radio-typhoon: registering /proc/radio-typhoon failed\n");
-
-#endif
-
-	return 0;
-}
-
-#ifdef MODULE
-
 MODULE_AUTHOR("Dr. Henrik Seidel");
 MODULE_DESCRIPTION("A driver for the Typhoon radio card (a.k.a. EcoRadio).");
 MODULE_PARM(io, "i");
@@ -394,10 +342,14 @@
 EXPORT_NO_SYMBOLS;
 
 static int io = -1;
+
+#ifdef MODULE
 static unsigned long mutefreq = 0;
+#endif
 
-int init_module(void)
+static int __init typhoon_init(void)
 {
+#ifdef MODULE
 	if (io == -1) {
 		printk(KERN_ERR "radio-typhoon: You must set an I/O address with io=0x316 or io=0x336\n");
 		return -EINVAL;
@@ -410,24 +362,49 @@
 		return -EINVAL;
 	}
 	typhoon_unit.mutefreq = mutefreq;
+#endif /* MODULE */
 
-	return typhoon_init(NULL);
-}
+	printk(KERN_INFO BANNER);
+	io = typhoon_unit.iobase;
+	if (check_region(io, 8)) {
+		printk(KERN_ERR "radio-typhoon: port 0x%x already in use\n",
+		       typhoon_unit.iobase);
+		return -EBUSY;
+	}
 
-void cleanup_module(void)
-{
+	typhoon_radio.priv = &typhoon_unit;
+	if (video_register_device(&typhoon_radio, VFL_TYPE_RADIO) == -1)
+		return -EINVAL;
+
+	request_region(typhoon_unit.iobase, 8, "typhoon");
+	printk(KERN_INFO "radio-typhoon: port 0x%x.\n", typhoon_unit.iobase);
+	printk(KERN_INFO "radio-typhoon: mute frequency is %lu kHz.\n",
+	       typhoon_unit.mutefreq);
+	typhoon_unit.mutefreq <<= 4;
+
+	/* mute card - prevents noisy bootups */
+	typhoon_mute(&typhoon_unit);
 
 #ifdef CONFIG_RADIO_TYPHOON_PROC_FS
+	if (!create_proc_info_entry("driver/radio-typhoon", 0, NULL,
+				    typhoon_get_info)) 
+	    	printk(KERN_ERR "radio-typhoon: registering /proc/driver/radio-typhoon failed\n");
+#endif
+
+	return 0;
+}
 
-	if (proc_unregister(&proc_root, typhoon_proc_entry.low_ino))
-	    	printk(KERN_ERR "radio-typhoon: unregistering /proc/radio-typhoon failed\n");
+static void __exit typhoon_cleanup_module(void)
+{
 
+#ifdef CONFIG_RADIO_TYPHOON_PROC_FS
+	remove_proc_entry("driver/radio-typhoon", NULL);
 #endif
 
 	video_unregister_device(&typhoon_radio);
 	release_region(io, 8);
 }
 
-#endif
-
+module_init(typhoon_init);
+module_exit(typhoon_cleanup_module);
 

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