# --------------------------------------------
# 02/10/18	jeb.j.cramer@intel.com	1.742.1.8
# e1000 6/11:
# * Adding notifier to track ifname change for /proc info 
# 
# --------------------------------------------
#
diff -Nru a/drivers/net/e1000/e1000.h b/drivers/net/e1000/e1000.h
--- a/drivers/net/e1000/e1000.h	Wed Oct 23 21:16:19 2002
+++ b/drivers/net/e1000/e1000.h	Wed Oct 23 21:16:19 2002
@@ -202,5 +202,6 @@
 
 
 	uint32_t pci_state[16];
+	char ifname[IFNAMSIZ];
 };
 #endif /* _E1000_H_ */
diff -Nru a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
--- a/drivers/net/e1000/e1000_main.c	Wed Oct 23 21:16:19 2002
+++ b/drivers/net/e1000/e1000_main.c	Wed Oct 23 21:16:19 2002
@@ -175,17 +175,24 @@
 static void e1000_vlan_rx_kill_vid(struct net_device *netdev, uint16_t vid);
 
 static int e1000_notify_reboot(struct notifier_block *, unsigned long event, void *ptr);
+static int e1000_notify_netdev(struct notifier_block *, unsigned long event, void *ptr);
 static int e1000_suspend(struct pci_dev *pdev, uint32_t state);
 #ifdef CONFIG_PM
 static int e1000_resume(struct pci_dev *pdev);
 #endif
 
-struct notifier_block e1000_notifier = {
+struct notifier_block e1000_notifier_reboot = {
 	notifier_call:	e1000_notify_reboot,
 	next:		NULL,
 	priority:	0
 };
 
+struct notifier_block e1000_notifier_netdev = {
+	notifier_call:	e1000_notify_netdev,
+	next:		NULL,
+	priority:	0
+};
+
 /* Exported from other modules */
 
 extern void e1000_check_options(struct e1000_adapter *adapter);
@@ -226,8 +233,10 @@
 	printk(KERN_INFO "%s\n", e1000_copyright);
 
 	ret = pci_module_init(&e1000_driver);
-	if(ret >= 0)
-		register_reboot_notifier(&e1000_notifier);
+	if(ret >= 0) {
+		register_reboot_notifier(&e1000_notifier_reboot);
+		register_netdevice_notifier(&e1000_notifier_netdev);
+	}
 	return ret;
 }
 
@@ -243,7 +252,8 @@
 static void __exit
 e1000_exit_module(void)
 {
-	unregister_reboot_notifier(&e1000_notifier);
+	unregister_reboot_notifier(&e1000_notifier_reboot);
+	unregister_netdevice_notifier(&e1000_notifier_netdev);
 	pci_unregister_driver(&e1000_driver);
 }
 
@@ -462,6 +472,8 @@
 		(void (*)(void *))e1000_tx_timeout_task, netdev);
 
 	register_netdev(netdev);
+	memcpy(adapter->ifname, netdev->name, IFNAMSIZ);
+	adapter->ifname[IFNAMSIZ-1] = 0;
 
 	/* we're going to reset, so assume we have no link for now */
 
@@ -2143,6 +2155,29 @@
 			if(pci_dev_driver(pdev) == &e1000_driver)
 				e1000_suspend(pdev, 3);
 		}
+	}
+	return NOTIFY_DONE;
+}
+
+static int
+e1000_notify_netdev(struct notifier_block *nb, unsigned long event, void *p)
+{
+	struct e1000_adapter *adapter;
+	struct net_device *netdev = p;
+	if(netdev == NULL)
+		return NOTIFY_DONE;
+
+	switch(event) {
+	case NETDEV_CHANGENAME:
+		if(netdev->open == e1000_open) {
+			adapter = netdev->priv;
+			/* rename the proc nodes the easy way */
+			e1000_proc_dev_free(adapter);
+			memcpy(adapter->ifname, netdev->name, IFNAMSIZ);
+			adapter->ifname[IFNAMSIZ-1] = 0;
+			e1000_proc_dev_setup(adapter);
+		}
+		break;
 	}
 	return NOTIFY_DONE;
 }
diff -Nru a/drivers/net/e1000/e1000_proc.c b/drivers/net/e1000/e1000_proc.c
--- a/drivers/net/e1000/e1000_proc.c	Wed Oct 23 21:16:19 2002
+++ b/drivers/net/e1000/e1000_proc.c	Wed Oct 23 21:16:19 2002
@@ -132,7 +132,7 @@
 	return e1000_proc_read(page, start, off, count, eof);
 }
 
-static void __devexit
+static void
 e1000_proc_dirs_free(char *name, struct list_head *proc_list_head)
 {
 	struct proc_dir_entry *intel_proc_dir, *proc_dir;
@@ -188,7 +188,7 @@
 }
 
 
-static int __devinit
+static int
 e1000_proc_singles_create(struct proc_dir_entry *parent,
                           struct list_head *proc_list_head)
 {
@@ -215,7 +215,7 @@
 	return 1;
 }
 
-static void __devinit
+static void
 e1000_proc_dirs_create(void *data, char *name, 
                        struct list_head *proc_list_head)
 {
@@ -255,7 +255,7 @@
 	info_entry->data = proc_list_head;
 }
 
-static void __devinit
+static void
 e1000_proc_list_add(struct list_head *proc_list_head, char *tag,
                     void *data, size_t len, 
 		    char *(*func)(void *, size_t, char *))
@@ -274,7 +274,7 @@
 	list_add_tail(&new->list, proc_list_head);
 }
 
-static void __devexit
+static void
 e1000_proc_list_free(struct list_head *proc_list_head)
 {
 	struct proc_list *elem;
@@ -542,7 +542,7 @@
 #define LIST_ADD_H(T,D) LIST_ADD_F((T), (D), e1000_proc_hex)
 #define LIST_ADD_U(T,D) LIST_ADD_F((T), (D), e1000_proc_unsigned)
 
-static void __devinit
+static void
 e1000_proc_list_setup(struct e1000_adapter *adapter)
 {
 	struct e1000_hw *hw = &adapter->hw;
@@ -572,7 +572,7 @@
 	}
 
 	LIST_ADD_U("IRQ", &adapter->pdev->irq);
-	LIST_ADD_S("System_Device_Name", adapter->netdev->name);
+	LIST_ADD_S("System_Device_Name", adapter->ifname);
 	LIST_ADD_F("Current_HWaddr",
 	            adapter->netdev->dev_addr, e1000_proc_hwaddr);
 	LIST_ADD_F("Permanent_HWaddr",
@@ -667,13 +667,13 @@
  * @adapter: board private structure
  */
 
-void __devinit
+void
 e1000_proc_dev_setup(struct e1000_adapter *adapter)
 {
 	e1000_proc_list_setup(adapter);
 
 	e1000_proc_dirs_create(adapter, 
-	                       adapter->netdev->name,
+	                       adapter->ifname,
 	                       &adapter->proc_list_head);
 }
 
@@ -682,18 +682,18 @@
  * @adapter: board private structure
  */
 
-void __devexit
+void
 e1000_proc_dev_free(struct e1000_adapter *adapter)
 {
-	e1000_proc_dirs_free(adapter->netdev->name, &adapter->proc_list_head);
+	e1000_proc_dirs_free(adapter->ifname, &adapter->proc_list_head);
 
 	e1000_proc_list_free(&adapter->proc_list_head);
 }
 
 #else /* CONFIG_PROC_FS */
 
-void __devinit e1000_proc_dev_setup(struct e1000_adapter *adapter) {}
-void __devexit e1000_proc_dev_free(struct e1000_adapter *adapter) {}
+void e1000_proc_dev_setup(struct e1000_adapter *adapter) {}
+void e1000_proc_dev_free(struct e1000_adapter *adapter) {}
 
 #endif /* CONFIG_PROC_FS */
 
