patch-2.1.101 linux/drivers/acorn/net/ether3.c

Next file: linux/drivers/acorn/net/etherh.c
Previous file: linux/drivers/acorn/char/serial-dualsp.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.100/linux/drivers/acorn/net/ether3.c linux/drivers/acorn/net/ether3.c
@@ -340,6 +340,23 @@
 	outw(priv->regs.command | CMD_RXON, REG_COMMAND);
 }
 
+static inline int
+ether3_probe_bus_8(struct device *dev, int val)
+{
+	outb(val & 255, REG_RECVPTR);
+	outb(val >> 8, REG_RECVPTR + 1);
+
+	return inb(REG_RECVPTR) == (val & 255) && inb(REG_RECVPTR + 1) == (val >> 8);
+}
+
+static inline int
+ether3_probe_bus_16(struct device *dev, int val)
+{
+	outw(val, REG_RECVPTR);
+
+	return inw(REG_RECVPTR) == val;
+}
+
 /*
  * This is the real probe routine.
  */
@@ -373,15 +390,14 @@
 	/* Test using Receive Pointer (16-bit register) to find out
 	 * how the ether3 is connected to the bus...
 	 */
-	outb(0, REG_RECVPTR);
-	outb(1, REG_RECVPTR + 1);
-
-	if (inb(REG_RECVPTR + 1) == 1) {
-		if (inb(REG_RECVPTR) == 0)
-			bus_type = BUS_8;
-		else if (inw(REG_RECVPTR) == 0x101)
-			bus_type = BUS_16;
-	}
+	if (ether3_probe_bus_8(dev, 0x100) &&
+	    ether3_probe_bus_8(dev, 0x201))
+		bus_type = BUS_8;
+
+	if (bus_type == BUS_UNKNOWN &&
+	    ether3_probe_bus_16(dev, 0x101) &&
+	    ether3_probe_bus_16(dev, 0x201))
+		bus_type = BUS_16;
 
 	switch (bus_type) {
 	case BUS_UNKNOWN:

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov