]> git.neil.brown.name Git - history.git/commitdiff
e1000 6/10:
authorJeb J. Cramer <jeb.j.cramer@intel.com>
Fri, 18 Oct 2002 14:01:46 +0000 (10:01 -0400)
committerJeff Garzik <jgarzik@redhat.com>
Fri, 18 Oct 2002 14:01:46 +0000 (10:01 -0400)
* Adding notifier to track ifname change for /proc info

drivers/net/e1000/e1000.h
drivers/net/e1000/e1000_main.c
drivers/net/e1000/e1000_proc.c

index 47cdd3afd26d3ec28373ba9ea06a2133367b93d3..b3136f036ba2ef5c9ec4ea645318537c00c5e797 100644 (file)
@@ -203,5 +203,6 @@ struct e1000_adapter {
 
 
        uint32_t pci_state[16];
+       char ifname[IFNAMSIZ];
 };
 #endif /* _E1000_H_ */
index 6fcd0b679d36a4e76a386d6d1a97278915f6449e..4a828d502dec3a5a3faf8ee9fe8fb4fbb44e55cc 100644 (file)
@@ -182,17 +182,24 @@ static void e1000_vlan_rx_add_vid(struct net_device *netdev, uint16_t vid);
 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);
@@ -233,8 +240,10 @@ e1000_init_module(void)
        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;
 }
 
@@ -250,7 +259,8 @@ module_init(e1000_init_module);
 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);
 }
 
@@ -478,6 +488,8 @@ e1000_probe(struct pci_dev *pdev,
                (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 */
 
@@ -2397,6 +2409,29 @@ e1000_notify_reboot(struct notifier_block *nb, unsigned long event, void *p)
        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;
+}
+
 static int
 e1000_suspend(struct pci_dev *pdev, uint32_t state)
 {
index 9ba00033943eb6561417f64d8dc1fa95816e36a6..55883b22c690551d2f7999ef1fefe6b3fa24fe47 100644 (file)
@@ -132,7 +132,7 @@ e1000_proc_single_read(char *page, char **start, off_t off,
        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 @@ e1000_proc_dirs_free(char *name, struct list_head *proc_list_head)
 }
 
 
-static int __devinit
+static int
 e1000_proc_singles_create(struct proc_dir_entry *parent,
                           struct list_head *proc_list_head)
 {
@@ -215,7 +215,7 @@ e1000_proc_singles_create(struct proc_dir_entry *parent,
        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 @@ e1000_proc_dirs_create(void *data, char *name,
        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 @@ e1000_proc_list_add(struct list_head *proc_list_head, char *tag,
        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 @@ e1000_proc_rx_status(void *data, size_t len, char *buf)
 #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 @@ e1000_proc_list_setup(struct e1000_adapter *adapter)
        }
 
        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",
@@ -670,13 +670,13 @@ e1000_proc_list_setup(struct e1000_adapter *adapter)
  * @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);
 }
 
@@ -685,18 +685,18 @@ e1000_proc_dev_setup(struct e1000_adapter *adapter)
  * @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 */