aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/igb
diff options
context:
space:
mode:
authorAlexander Duyck <alexander.h.duyck@intel.com>2009-02-06 18:16:45 -0500
committerDavid S. Miller <davem@davemloft.net>2009-02-07 05:43:04 -0500
commitc1889bfe687c22f74d1333913ffe8f8da173d601 (patch)
treedff3d16c38181e79437c6d6c82817a127b4de686 /drivers/net/igb
parent4d6b725e4d8e499fad012a25381c8d9bf53fbf4b (diff)
igb: make dev_spec a union and remove dynamic allocation
This patch makes dev_spec a union and simplifies it so that it does not require dynamic allocation and freeing in the driver. Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/igb')
-rw-r--r--drivers/net/igb/e1000_82575.c34
-rw-r--r--drivers/net/igb/e1000_hw.h9
-rw-r--r--drivers/net/igb/e1000_mac.c13
-rw-r--r--drivers/net/igb/e1000_mac.h1
-rw-r--r--drivers/net/igb/igb_main.c2
5 files changed, 12 insertions, 47 deletions
diff --git a/drivers/net/igb/e1000_82575.c b/drivers/net/igb/e1000_82575.c
index f5e4cad7971a..ed9e8c0333a3 100644
--- a/drivers/net/igb/e1000_82575.c
+++ b/drivers/net/igb/e1000_82575.c
@@ -62,17 +62,12 @@ static bool igb_sgmii_active_82575(struct e1000_hw *);
62static s32 igb_reset_init_script_82575(struct e1000_hw *); 62static s32 igb_reset_init_script_82575(struct e1000_hw *);
63static s32 igb_read_mac_addr_82575(struct e1000_hw *); 63static s32 igb_read_mac_addr_82575(struct e1000_hw *);
64 64
65
66struct e1000_dev_spec_82575 {
67 bool sgmii_active;
68};
69
70static s32 igb_get_invariants_82575(struct e1000_hw *hw) 65static s32 igb_get_invariants_82575(struct e1000_hw *hw)
71{ 66{
72 struct e1000_phy_info *phy = &hw->phy; 67 struct e1000_phy_info *phy = &hw->phy;
73 struct e1000_nvm_info *nvm = &hw->nvm; 68 struct e1000_nvm_info *nvm = &hw->nvm;
74 struct e1000_mac_info *mac = &hw->mac; 69 struct e1000_mac_info *mac = &hw->mac;
75 struct e1000_dev_spec_82575 *dev_spec; 70 struct e1000_dev_spec_82575 * dev_spec = &hw->dev_spec._82575;
76 u32 eecd; 71 u32 eecd;
77 s32 ret_val; 72 s32 ret_val;
78 u16 size; 73 u16 size;
@@ -94,17 +89,6 @@ static s32 igb_get_invariants_82575(struct e1000_hw *hw)
94 break; 89 break;
95 } 90 }
96 91
97 /* MAC initialization */
98 hw->dev_spec_size = sizeof(struct e1000_dev_spec_82575);
99
100 /* Device-specific structure allocation */
101 hw->dev_spec = kzalloc(hw->dev_spec_size, GFP_KERNEL);
102
103 if (!hw->dev_spec)
104 return -ENOMEM;
105
106 dev_spec = (struct e1000_dev_spec_82575 *)hw->dev_spec;
107
108 /* Set media type */ 92 /* Set media type */
109 /* 93 /*
110 * The 82575 uses bits 22:23 for link mode. The mode can be changed 94 * The 82575 uses bits 22:23 for link mode. The mode can be changed
@@ -1234,20 +1218,12 @@ out:
1234 **/ 1218 **/
1235static bool igb_sgmii_active_82575(struct e1000_hw *hw) 1219static bool igb_sgmii_active_82575(struct e1000_hw *hw)
1236{ 1220{
1237 struct e1000_dev_spec_82575 *dev_spec; 1221 struct e1000_dev_spec_82575 *dev_spec = &hw->dev_spec._82575;
1238 bool ret_val;
1239 1222
1240 if (hw->mac.type != e1000_82575) { 1223 if (hw->mac.type != e1000_82575 && hw->mac.type != e1000_82576)
1241 ret_val = false; 1224 return false;
1242 goto out;
1243 }
1244
1245 dev_spec = (struct e1000_dev_spec_82575 *)hw->dev_spec;
1246 1225
1247 ret_val = dev_spec->sgmii_active; 1226 return dev_spec->sgmii_active;
1248
1249out:
1250 return ret_val;
1251} 1227}
1252 1228
1253/** 1229/**
diff --git a/drivers/net/igb/e1000_hw.h b/drivers/net/igb/e1000_hw.h
index 99504a600a80..06f72ae6a2c2 100644
--- a/drivers/net/igb/e1000_hw.h
+++ b/drivers/net/igb/e1000_hw.h
@@ -565,9 +565,12 @@ struct e1000_fc_info {
565 enum e1000_fc_type original_type; 565 enum e1000_fc_type original_type;
566}; 566};
567 567
568struct e1000_dev_spec_82575 {
569 bool sgmii_active;
570};
571
568struct e1000_hw { 572struct e1000_hw {
569 void *back; 573 void *back;
570 void *dev_spec;
571 574
572 u8 __iomem *hw_addr; 575 u8 __iomem *hw_addr;
573 u8 __iomem *flash_address; 576 u8 __iomem *flash_address;
@@ -580,7 +583,9 @@ struct e1000_hw {
580 struct e1000_bus_info bus; 583 struct e1000_bus_info bus;
581 struct e1000_host_mng_dhcp_cookie mng_cookie; 584 struct e1000_host_mng_dhcp_cookie mng_cookie;
582 585
583 u32 dev_spec_size; 586 union {
587 struct e1000_dev_spec_82575 _82575;
588 } dev_spec;
584 589
585 u16 device_id; 590 u16 device_id;
586 u16 subsystem_vendor_id; 591 u16 subsystem_vendor_id;
diff --git a/drivers/net/igb/e1000_mac.c b/drivers/net/igb/e1000_mac.c
index 97f0049a5d6b..16fa0833368c 100644
--- a/drivers/net/igb/e1000_mac.c
+++ b/drivers/net/igb/e1000_mac.c
@@ -37,19 +37,6 @@
37static s32 igb_set_default_fc(struct e1000_hw *hw); 37static s32 igb_set_default_fc(struct e1000_hw *hw);
38static s32 igb_set_fc_watermarks(struct e1000_hw *hw); 38static s32 igb_set_fc_watermarks(struct e1000_hw *hw);
39 39
40/**
41 * igb_remove_device - Free device specific structure
42 * @hw: pointer to the HW structure
43 *
44 * If a device specific structure was allocated, this function will
45 * free it.
46 **/
47void igb_remove_device(struct e1000_hw *hw)
48{
49 /* Freeing the dev_spec member of e1000_hw structure */
50 kfree(hw->dev_spec);
51}
52
53static s32 igb_read_pcie_cap_reg(struct e1000_hw *hw, u32 reg, u16 *value) 40static s32 igb_read_pcie_cap_reg(struct e1000_hw *hw, u32 reg, u16 *value)
54{ 41{
55 struct igb_adapter *adapter = hw->back; 42 struct igb_adapter *adapter = hw->back;
diff --git a/drivers/net/igb/e1000_mac.h b/drivers/net/igb/e1000_mac.h
index cbee6af7d912..4ef40d5629d5 100644
--- a/drivers/net/igb/e1000_mac.h
+++ b/drivers/net/igb/e1000_mac.h
@@ -63,7 +63,6 @@ void igb_mta_set(struct e1000_hw *hw, u32 hash_value);
63void igb_put_hw_semaphore(struct e1000_hw *hw); 63void igb_put_hw_semaphore(struct e1000_hw *hw);
64void igb_rar_set(struct e1000_hw *hw, u8 *addr, u32 index); 64void igb_rar_set(struct e1000_hw *hw, u8 *addr, u32 index);
65s32 igb_check_alt_mac_addr(struct e1000_hw *hw); 65s32 igb_check_alt_mac_addr(struct e1000_hw *hw);
66void igb_remove_device(struct e1000_hw *hw);
67void igb_reset_adaptive(struct e1000_hw *hw); 66void igb_reset_adaptive(struct e1000_hw *hw);
68void igb_update_adaptive(struct e1000_hw *hw); 67void igb_update_adaptive(struct e1000_hw *hw);
69void igb_write_vfta(struct e1000_hw *hw, u32 offset, u32 value); 68void igb_write_vfta(struct e1000_hw *hw, u32 offset, u32 value);
diff --git a/drivers/net/igb/igb_main.c b/drivers/net/igb/igb_main.c
index b59088eace1d..cb3ac349f3b3 100644
--- a/drivers/net/igb/igb_main.c
+++ b/drivers/net/igb/igb_main.c
@@ -1329,7 +1329,6 @@ err_eeprom:
1329 if (hw->flash_address) 1329 if (hw->flash_address)
1330 iounmap(hw->flash_address); 1330 iounmap(hw->flash_address);
1331 1331
1332 igb_remove_device(hw);
1333 igb_free_queues(adapter); 1332 igb_free_queues(adapter);
1334err_sw_init: 1333err_sw_init:
1335err_hw_init: 1334err_hw_init:
@@ -1389,7 +1388,6 @@ static void __devexit igb_remove(struct pci_dev *pdev)
1389 if (!igb_check_reset_block(&adapter->hw)) 1388 if (!igb_check_reset_block(&adapter->hw))
1390 igb_reset_phy(&adapter->hw); 1389 igb_reset_phy(&adapter->hw);
1391 1390
1392 igb_remove_device(&adapter->hw);
1393 igb_reset_interrupt_capability(adapter); 1391 igb_reset_interrupt_capability(adapter);
1394 1392
1395 igb_free_queues(adapter); 1393 igb_free_queues(adapter);