patch-2.3.13 linux/drivers/net/hamradio/baycom_ser_fdx.c

Next file: linux/drivers/net/hamradio/baycom_ser_hdx.c
Previous file: linux/drivers/net/hamradio/baycom_par.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.12/linux/drivers/net/hamradio/baycom_ser_fdx.c linux/drivers/net/hamradio/baycom_ser_fdx.c
@@ -3,7 +3,7 @@
 /*
  *	baycom_ser_fdx.c  -- baycom ser12 fullduplex radio modem driver.
  *
- *	Copyright (C) 1997-1998  Thomas Sailer (sailer@ife.ee.ethz.ch)
+ *	Copyright (C) 1996-1999  Thomas Sailer (sailer@ife.ee.ethz.ch)
  *
  *	This program is free software; you can redistribute it and/or modify
  *	it under the terms of the GNU General Public License as published by
@@ -60,30 +60,20 @@
  *   0.6  24.01.98  Thorsten Kranzkowski, dl8bcu and Thomas Sailer:
  *                  reduced interrupt load in transmit case
  *                  reworked receiver
+ *   0.7  03.08.99  adapt to Linus' new __setup/__initcall
  */
 
 /*****************************************************************************/
 
+#include <linux/version.h>
 #include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/types.h>
-#include <linux/fcntl.h>
-#include <linux/interrupt.h>
 #include <linux/ioport.h>
-#include <linux/in.h>
 #include <linux/string.h>
 #include <linux/init.h>
-#include <linux/bitops.h>
 #include <asm/uaccess.h>
-#include <asm/system.h>
 #include <asm/io.h>
-#include <linux/delay.h>
-#include <linux/errno.h>
-#include <linux/netdevice.h>
 #include <linux/hdlcdrv.h>
 #include <linux/baycom.h>
-#include <linux/version.h>
 
 /* --------------------------------------------------------------------- */
 
@@ -97,8 +87,8 @@
 /* --------------------------------------------------------------------- */
 
 static const char bc_drvname[] = "baycom_ser_fdx";
-static const char bc_drvinfo[] = KERN_INFO "baycom_ser_fdx: (C) 1997-1998 Thomas Sailer, HB9JNX/AE4WA\n"
-KERN_INFO "baycom_ser_fdx: version 0.6 compiled " __TIME__ " " __DATE__ "\n";
+static const char bc_drvinfo[] = KERN_INFO "baycom_ser_fdx: (C) 1996-1999 Thomas Sailer, HB9JNX/AE4WA\n"
+KERN_INFO "baycom_ser_fdx: version 0.7 compiled " __TIME__ " " __DATE__ "\n";
 
 /* --------------------------------------------------------------------- */
 
@@ -106,11 +96,6 @@
 
 static struct device baycom_device[NR_PORTS];
 
-static struct {
-	char *mode;
-	int iobase, irq, baud;
-} baycom_ports[NR_PORTS] = { { NULL, 0, 0 }, };
-
 /* --------------------------------------------------------------------- */
 
 #define RBR(iobase) (iobase+0)
@@ -605,7 +590,20 @@
 
 /* --------------------------------------------------------------------- */
 
-int __init baycom_ser_fdx_init(void)
+/*
+ * command line settable parameters
+ */
+static char *mode[NR_PORTS] = { "ser12*", };
+static int iobase[NR_PORTS] = { 0x3f8, };
+static int irq[NR_PORTS] = { 4, };
+static int baud[NR_PORTS] = { [0 ... NR_PORTS-1] = 1200 };
+
+/* --------------------------------------------------------------------- */
+
+#ifndef MODULE
+static
+#endif
+int __init init_module(void)
 {
 	int i, j, found = 0;
 	char set_hw = 1;
@@ -621,19 +619,17 @@
 		struct device *dev = baycom_device+i;
 		sprintf(ifname, "bcsf%d", i);
 
-		if (!baycom_ports[i].mode)
+		if (!mode[i])
 			set_hw = 0;
 		if (!set_hw)
-			baycom_ports[i].iobase = baycom_ports[i].irq = 0;
-		j = hdlcdrv_register_hdlcdrv(dev, &ser12_ops,
-					     sizeof(struct baycom_state),
-					     ifname, baycom_ports[i].iobase,
-					     baycom_ports[i].irq, 0);
+			iobase[i] = irq[i] = 0;
+		j = hdlcdrv_register_hdlcdrv(dev, &ser12_ops, sizeof(struct baycom_state),
+					     ifname, iobase[i], irq[i], 0);
 		if (!j) {
 			bc = (struct baycom_state *)dev->priv;
-			if (set_hw && baycom_setmode(bc, baycom_ports[i].mode))
+			if (set_hw && baycom_setmode(bc, mode[i]))
 				set_hw = 0;
-			bc->baud = baycom_ports[i].baud;
+			bc->baud = baud[i];
 			found++;
 		} else {
 			printk(KERN_WARNING "%s: cannot register net device\n",
@@ -649,16 +645,6 @@
 
 #ifdef MODULE
 
-/*
- * command line settable parameters
- */
-static char *mode[NR_PORTS] = { "ser12*", };
-static int iobase[NR_PORTS] = { 0x3f8, };
-static int irq[NR_PORTS] = { 4, };
-static int baud[NR_PORTS] = { [0 ... NR_PORTS-1] = 1200 };
-
-#if LINUX_VERSION_CODE >= 0x20115
-
 MODULE_PARM(mode, "1-" __MODULE_STRING(NR_PORTS) "s");
 MODULE_PARM_DESC(mode, "baycom operating mode; * for software DCD");
 MODULE_PARM(iobase, "1-" __MODULE_STRING(NR_PORTS) "i");
@@ -671,25 +657,6 @@
 MODULE_AUTHOR("Thomas M. Sailer, sailer@ife.ee.ethz.ch, hb9jnx@hb9w.che.eu");
 MODULE_DESCRIPTION("Baycom ser12 full duplex amateur radio modem driver");
 
-#endif
-
-int __init init_module(void)
-{
-	int i;
-
-	for (i = 0; (i < NR_PORTS) && (mode[i]); i++) {
-		baycom_ports[i].mode = mode[i];
-		baycom_ports[i].iobase = iobase[i];
-		baycom_ports[i].irq = irq[i];
-		baycom_ports[i].baud = baud[i];
-	}
-	if (i < NR_PORTS-1)
-		baycom_ports[i+1].mode = NULL;
-	return baycom_ser_fdx_init();
-}
-
-/* --------------------------------------------------------------------- */
-
 void cleanup_module(void)
 {
 	int i;
@@ -709,33 +676,34 @@
 }
 
 #else /* MODULE */
-/* --------------------------------------------------------------------- */
+
 /*
  * format: baycom_ser_fdx=io,irq,mode
  * mode: [*]
  * * indicates sofware DCD
  */
 
-void __init baycom_ser_fdx_setup(char *str, int *ints)
+static int __init baycom_ser_fdx_setup(char *str)
 {
-	int i;
+        static unsigned __initdata nr_dev = 0;
+        int ints[11];
 
-	for (i = 0; (i < NR_PORTS) && (baycom_ports[i].mode); i++);
-	if ((i >= NR_PORTS) || (ints[0] < 2)) {
-		printk(KERN_INFO "%s: too many or invalid interface "
-		       "specifications\n", bc_drvname);
-		return;
-	}
-	baycom_ports[i].mode = str;
-	baycom_ports[i].iobase = ints[1];
-	baycom_ports[i].irq = ints[2];
+        if (nr_dev >= NR_PORTS)
+                return 0;
+        str = get_options(str, ints);
+        if (ints[0] < 2)
+                return 0;
+        mode[nr_dev] = str;
+        iobase[nr_dev] = ints[1];
+        irq[nr_dev] = ints[2];
 	if (ints[0] >= 3)
-		baycom_ports[i].baud = ints[3];
-	else
-		baycom_ports[i].baud = 1200;
-	if (i < NR_PORTS-1)
-		baycom_ports[i+1].mode = NULL;
+		baud[nr_dev] = ints[3];
+	nr_dev++;
+	return 1;
 }
+
+__setup("baycom_ser_fdx=", baycom_ser_fdx_setup);
+__initcall(init_module);
 
 #endif /* MODULE */
 /* --------------------------------------------------------------------- */

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