diff options
author | Dimitris Michailidis <dm@chelsio.com> | 2010-07-11 12:01:16 +0000 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-07-11 17:07:45 -0700 |
commit | 065463915c3a2a2ce142f64ed3ed591d72ad88b1 (patch) | |
tree | 79b66e4ea1f7b78993055ddfa1c7a2fe930b01c2 /drivers/net/cxgb4 | |
parent | f7cabcdd51480282b58c09e5fe1c4835aaf98a66 (diff) | |
download | linux-065463915c3a2a2ce142f64ed3ed591d72ad88b1.tar.bz2 |
cxgb4: avoid duplicating some resource freeing code
Currently there are two copies of some resource freeing code, turn it into
a function and call it.
Signed-off-by: Dimitris Michailidis <dm@chelsio.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/cxgb4')
-rw-r--r-- | drivers/net/cxgb4/cxgb4_main.c | 42 |
1 files changed, 25 insertions, 17 deletions
diff --git a/drivers/net/cxgb4/cxgb4_main.c b/drivers/net/cxgb4/cxgb4_main.c index 743dc6faec56..653bb546edd3 100644 --- a/drivers/net/cxgb4/cxgb4_main.c +++ b/drivers/net/cxgb4/cxgb4_main.c @@ -3364,6 +3364,29 @@ static void __devinit print_port_info(struct adapter *adap) } } +/* + * Free the following resources: + * - memory used for tables + * - MSI/MSI-X + * - net devices + * - resources FW is holding for us + */ +static void free_some_resources(struct adapter *adapter) +{ + unsigned int i; + + t4_free_mem(adapter->l2t); + t4_free_mem(adapter->tids.tid_tab); + disable_msi(adapter); + + for_each_port(adapter, i) + if (adapter->port[i]) + free_netdev(adapter->port[i]); + + if (adapter->flags & FW_OK) + t4_fw_bye(adapter, 0); +} + #define VLAN_FEAT (NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_TSO | NETIF_F_TSO6 |\ NETIF_F_IPV6_CSUM | NETIF_F_HIGHDMA) @@ -3564,14 +3587,7 @@ sriov: return 0; out_free_dev: - t4_free_mem(adapter->tids.tid_tab); - t4_free_mem(adapter->l2t); - for_each_port(adapter, i) - if (adapter->port[i]) - free_netdev(adapter->port[i]); - if (adapter->flags & FW_OK) - t4_fw_bye(adapter, 0); - disable_msi(adapter); + free_some_resources(adapter); out_unmap_bar: iounmap(adapter->regs); out_free_adapter: @@ -3606,16 +3622,8 @@ static void __devexit remove_one(struct pci_dev *pdev) if (adapter->flags & FULL_INIT_DONE) cxgb_down(adapter); - t4_free_mem(adapter->l2t); - t4_free_mem(adapter->tids.tid_tab); - disable_msi(adapter); - - for_each_port(adapter, i) - if (adapter->port[i]) - free_netdev(adapter->port[i]); - if (adapter->flags & FW_OK) - t4_fw_bye(adapter, 0); + free_some_resources(adapter); iounmap(adapter->regs); kfree(adapter); pci_disable_pcie_error_reporting(pdev); |