Multiple 3c509 card patch

Tom Zerucha (root@mars.ceddec.com)
Wed, 1 May 1996 13:47:54 -0400 (EDT)


The following patch will support up to 3 3c509 cards. DO NOT use it in
addition to kernel 3c509 support, i.e. don't use it to add additional
cards after the kernel comes up.

You also need to use the software that comes with the card to set the IRQ
and ports to different values for each card

It is ugly, but works.

#
#
#
diff -bBur l1397/drivers/net/3c509.c linux-1.3.97/drivers/net/3c509.c
--- l1397/drivers/net/3c509.c Tue Apr 30 17:34:09 1996
+++ linux-1.3.97/drivers/net/3c509.c Tue Apr 30 12:01:46 1996
@@ -265,6 +267,10 @@

/* Free the interrupt so that some other card can use it. */
outw(0x0f00, ioaddr + WN0_IRQ);
+
+ if( check_region(ioaddr, EL3_IO_EXTENT) )
+ return -ENODEV;
+
found:
dev->base_addr = ioaddr;
dev->irq = irq;
@@ -758,25 +764,31 @@
}

#ifdef MODULE
-static char devicename[9] = { 0, };
-static struct device dev_3c509 = {
- devicename, /* device name is inserted by linux/drivers/net/net_init.c */
- 0, 0, 0, 0,
- 0, 0,
- 0, 0, 0, NULL, el3_probe };

-static int io = 0;
-static int irq = 0;
+#define MAXCARDS 3
+
+ /* device name is inserted by linux/drivers/net/net_init.c */
+static char devicename[MAXCARDS][9];
+
+static struct device dev_3c509[MAXCARDS] = {
+ { devicename[0], 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, el3_probe },
+ { devicename[1], 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, el3_probe },
+ { devicename[2], 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, el3_probe },
+};
+
+static int cardno = 0;

int
init_module(void)
{
- dev_3c509.base_addr = io;
- dev_3c509.irq = irq;
- if (!EISA_bus && !io) {
+ if (!EISA_bus) {
printk("3c509: WARNING! Module load-time probing works reliably only for EISA bus!!\n");
}
- if (register_netdev(&dev_3c509) != 0)
+ for( cardno = 0 ; cardno < MAXCARDS ; cardno++ )
+ if (register_netdev(&dev_3c509[cardno]) != 0)
+ break;
+
+ if (cardno == 0)
return -EIO;
return 0;
}
@@ -787,12 +799,12 @@
if (MOD_IN_USE)
printk("3c509: device busy, remove delayed\n");
else
- {
- unregister_netdev(&dev_3c509);
- kfree_s(dev_3c509.priv,sizeof(struct el3_private));
- dev_3c509.priv=NULL;
+ while( cardno-- ) {
+ unregister_netdev(&dev_3c509[cardno]);
+ kfree_s(dev_3c509[cardno].priv,sizeof(struct el3_private));
+ dev_3c509[cardno].priv=NULL;
/* If we don't do this, we can't re-insmod it later. */
- release_region(dev_3c509.base_addr, EL3_IO_EXTENT);
+ release_region(dev_3c509[cardno].base_addr, EL3_IO_EXTENT);
}
}
#endif /* MODULE */