patch-1.3.19 linux/drivers/net/hp.c

Next file: linux/drivers/net/hp100.c
Previous file: linux/drivers/net/hp-plus.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v1.3.18/linux/drivers/net/hp.c linux/drivers/net/hp.c
@@ -35,11 +35,9 @@
 #include <asm/io.h>
 
 #include <linux/netdevice.h>
+#include <linux/etherdevice.h>
 #include "8390.h"
 
-extern struct device *init_etherdev(struct device *dev, int sizeof_private,
-									unsigned long *mem_startp);
-
 /* A zero-terminated list of I/O addresses to be probed. */
 static unsigned int hppclan_portlist[] =
 { 0x300, 0x320, 0x340, 0x280, 0x2C0, 0x200, 0x240, 0};
@@ -130,9 +128,6 @@
 	if (dev == NULL)
 		dev = init_etherdev(0, sizeof(struct ei_device), 0);
 
-	/* Grab the region so we can find another board if something fails. */
-	request_region(ioaddr, HP_IO_EXTENT,"hp");
-
 	printk("%s: %s (ID %02x) at %#3x,", dev->name, name, board_id, ioaddr);
 
 	for(i = 0; i < ETHER_ADDR_LEN; i++)
@@ -171,6 +166,9 @@
 		}
 	}
 
+	/* Grab the region so we can find another board if something fails. */
+	request_region(ioaddr, HP_IO_EXTENT,"hp");
+
 	if (ei_debug > 1)
 		printk(version);
 
@@ -327,8 +325,12 @@
 
 #ifdef MODULE
 char kernel_version[] = UTS_RELEASE;
+static char devicename[9] = { 0, };
 static struct device dev_hp = {
-	"        " /*"hp"*/, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, hp_probe };
+	devicename, /* device name is inserted by linux/drivers/net/net_init.c */
+	0, 0, 0, 0,
+	0, 0,
+	0, 0, 0, NULL, hp_probe };
 
 int io = 300;
 int irq = 0;
@@ -336,7 +338,7 @@
 int init_module(void)
 {
 	if (io == 0)
-	  printk("hp: You should not use auto-probing with insmod!\n");
+		printk("hp: You should not use auto-probing with insmod!\n");
 	dev_hp.base_addr = io;
 	dev_hp.irq       = irq;
 	if (register_netdev(&dev_hp) != 0) {
@@ -353,7 +355,13 @@
 		printk("hp: device busy, remove delayed\n");
 	else
 	{
+		int ioaddr = dev_hp.base_addr - NIC_OFFSET;
+
 		unregister_netdev(&dev_hp);
+
+		/* If we don't do this, we can't re-insmod it later. */
+		free_irq(dev_hp.irq);
+		release_region(ioaddr, HP_IO_EXTENT);
 	}
 }
 #endif /* MODULE */

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