Commit 408d3faf authored by Jeb J. Cramer's avatar Jeb J. Cramer Committed by Jeff Garzik

e1000 6/10:

* Adding notifier to track ifname change for /proc info 
parent 29c4409a
...@@ -203,5 +203,6 @@ struct e1000_adapter { ...@@ -203,5 +203,6 @@ struct e1000_adapter {
uint32_t pci_state[16]; uint32_t pci_state[16];
char ifname[IFNAMSIZ];
}; };
#endif /* _E1000_H_ */ #endif /* _E1000_H_ */
...@@ -182,17 +182,24 @@ static void e1000_vlan_rx_add_vid(struct net_device *netdev, uint16_t vid); ...@@ -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 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_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); static int e1000_suspend(struct pci_dev *pdev, uint32_t state);
#ifdef CONFIG_PM #ifdef CONFIG_PM
static int e1000_resume(struct pci_dev *pdev); static int e1000_resume(struct pci_dev *pdev);
#endif #endif
struct notifier_block e1000_notifier = { struct notifier_block e1000_notifier_reboot = {
.notifier_call = e1000_notify_reboot, .notifier_call = e1000_notify_reboot,
.next = NULL, .next = NULL,
.priority = 0 .priority = 0
}; };
struct notifier_block e1000_notifier_netdev = {
.notifier_call = e1000_notify_netdev,
.next = NULL,
.priority = 0
};
/* Exported from other modules */ /* Exported from other modules */
extern void e1000_check_options(struct e1000_adapter *adapter); extern void e1000_check_options(struct e1000_adapter *adapter);
...@@ -233,8 +240,10 @@ e1000_init_module(void) ...@@ -233,8 +240,10 @@ e1000_init_module(void)
printk(KERN_INFO "%s\n", e1000_copyright); printk(KERN_INFO "%s\n", e1000_copyright);
ret = pci_module_init(&e1000_driver); ret = pci_module_init(&e1000_driver);
if(ret >= 0) if(ret >= 0) {
register_reboot_notifier(&e1000_notifier); register_reboot_notifier(&e1000_notifier_reboot);
register_netdevice_notifier(&e1000_notifier_netdev);
}
return ret; return ret;
} }
...@@ -250,7 +259,8 @@ module_init(e1000_init_module); ...@@ -250,7 +259,8 @@ module_init(e1000_init_module);
static void __exit static void __exit
e1000_exit_module(void) 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); pci_unregister_driver(&e1000_driver);
} }
...@@ -478,6 +488,8 @@ e1000_probe(struct pci_dev *pdev, ...@@ -478,6 +488,8 @@ e1000_probe(struct pci_dev *pdev,
(void (*)(void *))e1000_tx_timeout_task, netdev); (void (*)(void *))e1000_tx_timeout_task, netdev);
register_netdev(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 */ /* 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) ...@@ -2397,6 +2409,29 @@ e1000_notify_reboot(struct notifier_block *nb, unsigned long event, void *p)
return NOTIFY_DONE; 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 static int
e1000_suspend(struct pci_dev *pdev, uint32_t state) e1000_suspend(struct pci_dev *pdev, uint32_t state)
{ {
......
...@@ -132,7 +132,7 @@ e1000_proc_single_read(char *page, char **start, off_t off, ...@@ -132,7 +132,7 @@ e1000_proc_single_read(char *page, char **start, off_t off,
return e1000_proc_read(page, start, off, count, eof); 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) e1000_proc_dirs_free(char *name, struct list_head *proc_list_head)
{ {
struct proc_dir_entry *intel_proc_dir, *proc_dir; 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) ...@@ -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, e1000_proc_singles_create(struct proc_dir_entry *parent,
struct list_head *proc_list_head) struct list_head *proc_list_head)
{ {
...@@ -215,7 +215,7 @@ e1000_proc_singles_create(struct proc_dir_entry *parent, ...@@ -215,7 +215,7 @@ e1000_proc_singles_create(struct proc_dir_entry *parent,
return 1; return 1;
} }
static void __devinit static void
e1000_proc_dirs_create(void *data, char *name, e1000_proc_dirs_create(void *data, char *name,
struct list_head *proc_list_head) struct list_head *proc_list_head)
{ {
...@@ -255,7 +255,7 @@ e1000_proc_dirs_create(void *data, char *name, ...@@ -255,7 +255,7 @@ e1000_proc_dirs_create(void *data, char *name,
info_entry->data = proc_list_head; info_entry->data = proc_list_head;
} }
static void __devinit static void
e1000_proc_list_add(struct list_head *proc_list_head, char *tag, e1000_proc_list_add(struct list_head *proc_list_head, char *tag,
void *data, size_t len, void *data, size_t len,
char *(*func)(void *, size_t, char *)) char *(*func)(void *, size_t, char *))
...@@ -274,7 +274,7 @@ e1000_proc_list_add(struct list_head *proc_list_head, char *tag, ...@@ -274,7 +274,7 @@ e1000_proc_list_add(struct list_head *proc_list_head, char *tag,
list_add_tail(&new->list, proc_list_head); list_add_tail(&new->list, proc_list_head);
} }
static void __devexit static void
e1000_proc_list_free(struct list_head *proc_list_head) e1000_proc_list_free(struct list_head *proc_list_head)
{ {
struct proc_list *elem; struct proc_list *elem;
...@@ -542,7 +542,7 @@ e1000_proc_rx_status(void *data, size_t len, char *buf) ...@@ -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_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) #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) e1000_proc_list_setup(struct e1000_adapter *adapter)
{ {
struct e1000_hw *hw = &adapter->hw; struct e1000_hw *hw = &adapter->hw;
...@@ -572,7 +572,7 @@ e1000_proc_list_setup(struct e1000_adapter *adapter) ...@@ -572,7 +572,7 @@ e1000_proc_list_setup(struct e1000_adapter *adapter)
} }
LIST_ADD_U("IRQ", &adapter->pdev->irq); 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", LIST_ADD_F("Current_HWaddr",
adapter->netdev->dev_addr, e1000_proc_hwaddr); adapter->netdev->dev_addr, e1000_proc_hwaddr);
LIST_ADD_F("Permanent_HWaddr", LIST_ADD_F("Permanent_HWaddr",
...@@ -670,13 +670,13 @@ e1000_proc_list_setup(struct e1000_adapter *adapter) ...@@ -670,13 +670,13 @@ e1000_proc_list_setup(struct e1000_adapter *adapter)
* @adapter: board private structure * @adapter: board private structure
*/ */
void __devinit void
e1000_proc_dev_setup(struct e1000_adapter *adapter) e1000_proc_dev_setup(struct e1000_adapter *adapter)
{ {
e1000_proc_list_setup(adapter); e1000_proc_list_setup(adapter);
e1000_proc_dirs_create(adapter, e1000_proc_dirs_create(adapter,
adapter->netdev->name, adapter->ifname,
&adapter->proc_list_head); &adapter->proc_list_head);
} }
...@@ -685,18 +685,18 @@ e1000_proc_dev_setup(struct e1000_adapter *adapter) ...@@ -685,18 +685,18 @@ e1000_proc_dev_setup(struct e1000_adapter *adapter)
* @adapter: board private structure * @adapter: board private structure
*/ */
void __devexit void
e1000_proc_dev_free(struct e1000_adapter *adapter) 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); e1000_proc_list_free(&adapter->proc_list_head);
} }
#else /* CONFIG_PROC_FS */ #else /* CONFIG_PROC_FS */
void __devinit e1000_proc_dev_setup(struct e1000_adapter *adapter) {} void e1000_proc_dev_setup(struct e1000_adapter *adapter) {}
void __devexit e1000_proc_dev_free(struct e1000_adapter *adapter) {} void e1000_proc_dev_free(struct e1000_adapter *adapter) {}
#endif /* CONFIG_PROC_FS */ #endif /* CONFIG_PROC_FS */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment