patch-1.3.17 linux/drivers/net/ne.c

Next file: linux/drivers/net/plip.c
Previous file: linux/drivers/net/ibmtr.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v1.3.16/linux/drivers/net/ne.c linux/drivers/net/ne.c
@@ -29,6 +29,12 @@
 static const char *version =
     "ne.c:v1.10 9/23/94 Donald Becker (becker@cesdis.gsfc.nasa.gov)\n";
 
+
+#ifdef MODULE
+#include <linux/module.h>
+#include <linux/version.h>
+#endif
+
 #include <linux/kernel.h>
 #include <linux/sched.h>
 #include <linux/errno.h>
@@ -45,9 +51,19 @@
 
 /* Do we perform extra sanity checks on stuff ? */
 /* #define CONFIG_NE_SANITY */
+#ifdef CONFIG_NE_SANITY
+static int config_ne_sanity = 1;
+#else
+static int config_ne_sanity = 0;
+#endif
 
 /* Do we implement the read before write bugfix ? */
 /* #define CONFIG_NE_RW_BUGFIX */
+#ifdef CONFIG_NE_RW_BUGFIX
+static int ne8390_rw_bugfix = 1;
+#else
+static int ne8390_rw_bugfix = 0;
+#endif
 
 /* ---- No user-serviceable parts below ---- */
 
@@ -371,10 +387,9 @@
 static int
 ne_block_input(struct device *dev, int count, char *buf, int ring_offset)
 {
-#ifdef CONFIG_NE_SANITY
-    int xfer_count = count;
-#endif
     int nic_base = dev->base_addr;
+    /* CONFIG_NE_SANITY */
+    int xfer_count = count;
 
     /* This *shouldn't* happen. If it does, it's the last thing you'll see */
     if (ei_status.dmaing) {
@@ -396,9 +411,8 @@
       insw(NE_BASE + NE_DATAPORT,buf,count>>1);
       if (count & 0x01) {
 	buf[count-1] = inb(NE_BASE + NE_DATAPORT);
-#ifdef CONFIG_NE_SANITY
+	/* CONFIG_NE_SANITY */
 	xfer_count++;
-#endif
       }
     } else {
 	insb(NE_BASE + NE_DATAPORT, buf, count);
@@ -408,8 +422,8 @@
        been encountering problems so it is still here.  If you see
        this message you either 1) have a slightly incompatible clone
        or 2) have noise/speed problems with your bus. */
-#ifdef CONFIG_NE_SANITY
-    if (ei_debug > 1) {		/* DMA termination address check... */
+    if (config_ne_sanity &&
+	ei_debug > 1) {		/* DMA termination address check... */
 	int addr, tries = 20;
 	do {
 	    /* DON'T check for 'inb_p(EN0_ISR) & ENISR_RDC' here
@@ -425,7 +439,6 @@
 		   "%#4.4x (expected) vs. %#4.4x (actual).\n",
 		   dev->name, ring_offset + xfer_count, addr);
     }
-#endif
     outb_p(ENISR_RDC, nic_base + EN0_ISR);	/* Ack intr. */
     ei_status.dmaing &= ~0x01;
     return ring_offset + count;
@@ -435,11 +448,10 @@
 ne_block_output(struct device *dev, int count,
 		const unsigned char *buf, const int start_page)
 {
-#ifdef CONFIG_NE_SANITY
-    int retries = 0;
-#endif
     int nic_base = NE_BASE;
     unsigned long dma_start;
+    /* CONFIG_NE_SANITY */
+    int retries = 0;
 
     /* Round the count up for word writes.  Do we need to do this?
        What effect will an odd byte count have on the 8390?
@@ -460,25 +472,23 @@
     /* We should already be in page 0, but to be safe... */
     outb_p(E8390_PAGE0+E8390_START+E8390_NODMA, nic_base + NE_CMD);
 
-#ifdef CONFIG_NE_SANITY
  retry:
-#endif
 
-#ifdef CONFIG_NE_RW_BUGFIX 
-    /* Handle the read-before-write bug the same way as the
-       Crynwr packet driver -- the NatSemi method doesn't work.
-       Actually this doesn't always work either, but if you have
-       problems with your NEx000 this is better than nothing! */
-    outb_p(0x42, nic_base + EN0_RCNTLO);
-    outb_p(0x00,   nic_base + EN0_RCNTHI);
-    outb_p(0x42, nic_base + EN0_RSARLO);
-    outb_p(0x00, nic_base + EN0_RSARHI);
-    outb_p(E8390_RREAD+E8390_START, nic_base + NE_CMD);
-    /* Make certain that the dummy read has occurred. */
-    SLOW_DOWN_IO;
-    SLOW_DOWN_IO;
-    SLOW_DOWN_IO;
-#endif  /* rw_bugfix */
+    if (ne8390_rw_bugfix) { 
+	/* Handle the read-before-write bug the same way as the
+	   Crynwr packet driver -- the NatSemi method doesn't work.
+	   Actually this doesn't always work either, but if you have
+	   problems with your NEx000 this is better than nothing! */
+	outb_p(0x42, nic_base + EN0_RCNTLO);
+	outb_p(0x00,   nic_base + EN0_RCNTHI);
+	outb_p(0x42, nic_base + EN0_RSARLO);
+	outb_p(0x00, nic_base + EN0_RSARHI);
+	outb_p(E8390_RREAD+E8390_START, nic_base + NE_CMD);
+	/* Make certain that the dummy read has occurred. */
+	SLOW_DOWN_IO;
+	SLOW_DOWN_IO;
+	SLOW_DOWN_IO;
+    }
 
     outb_p(ENISR_RDC, nic_base + EN0_ISR);
 
@@ -497,10 +507,10 @@
 
     dma_start = jiffies;
 
-#ifdef CONFIG_NE_SANITY
     /* This was for the ALPHA version only, but enough people have
        been encountering problems so it is still here. */
-    if (ei_debug > 1) {		/* DMA termination address check... */
+    if (config_ne_sanity &&
+	ei_debug > 1) {		/* DMA termination address check... */
 	int addr, tries = 20;
 	do {
 	    int high = inb_p(nic_base + EN0_RSARHI);
@@ -517,7 +527,6 @@
 		goto retry;
 	}
     }
-#endif
 
     while ((inb_p(nic_base + EN0_ISR) & ENISR_RDC) == 0)
 	if (jiffies - dma_start > 2*HZ/100) {		/* 20ms */
@@ -532,6 +541,34 @@
     return;
 }
 
+#ifdef MODULE
+char kernel_version[] = UTS_RELEASE;
+static struct device dev_ne2000 = {
+	"        " /*"ne2000"*/, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, ne_probe };
+
+int io = 0;
+int irq = 0;
+
+int init_module(void)
+{
+	dev_ne2000.base_addr = io;
+	dev_ne2000.irq       = irq;
+	if (register_netdev(&dev_ne2000) != 0)
+		return -EIO;
+	return 0;
+}
+
+void
+cleanup_module(void)
+{
+	if (MOD_IN_USE)
+		printk("ne2000: device busy, remove delayed\n");
+	else
+	{
+		unregister_netdev(&dev_ne2000);
+	}
+}
+#endif /* MODULE */
 
 /*
  * Local variables:

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov with Sam's (original) version
of this