Commit c1889bfe authored by Alexander Duyck's avatar Alexander Duyck Committed by David S. Miller

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: default avatarAlexander Duyck <alexander.h.duyck@intel.com>
Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 4d6b725e
...@@ -62,17 +62,12 @@ static bool igb_sgmii_active_82575(struct e1000_hw *); ...@@ -62,17 +62,12 @@ static bool igb_sgmii_active_82575(struct e1000_hw *);
static s32 igb_reset_init_script_82575(struct e1000_hw *); static s32 igb_reset_init_script_82575(struct e1000_hw *);
static s32 igb_read_mac_addr_82575(struct e1000_hw *); static s32 igb_read_mac_addr_82575(struct e1000_hw *);
struct e1000_dev_spec_82575 {
bool sgmii_active;
};
static s32 igb_get_invariants_82575(struct e1000_hw *hw) static s32 igb_get_invariants_82575(struct e1000_hw *hw)
{ {
struct e1000_phy_info *phy = &hw->phy; struct e1000_phy_info *phy = &hw->phy;
struct e1000_nvm_info *nvm = &hw->nvm; struct e1000_nvm_info *nvm = &hw->nvm;
struct e1000_mac_info *mac = &hw->mac; struct e1000_mac_info *mac = &hw->mac;
struct e1000_dev_spec_82575 *dev_spec; struct e1000_dev_spec_82575 * dev_spec = &hw->dev_spec._82575;
u32 eecd; u32 eecd;
s32 ret_val; s32 ret_val;
u16 size; u16 size;
...@@ -94,17 +89,6 @@ static s32 igb_get_invariants_82575(struct e1000_hw *hw) ...@@ -94,17 +89,6 @@ static s32 igb_get_invariants_82575(struct e1000_hw *hw)
break; break;
} }
/* MAC initialization */
hw->dev_spec_size = sizeof(struct e1000_dev_spec_82575);
/* Device-specific structure allocation */
hw->dev_spec = kzalloc(hw->dev_spec_size, GFP_KERNEL);
if (!hw->dev_spec)
return -ENOMEM;
dev_spec = (struct e1000_dev_spec_82575 *)hw->dev_spec;
/* Set media type */ /* Set media type */
/* /*
* The 82575 uses bits 22:23 for link mode. The mode can be changed * The 82575 uses bits 22:23 for link mode. The mode can be changed
...@@ -1234,20 +1218,12 @@ out: ...@@ -1234,20 +1218,12 @@ out:
**/ **/
static bool igb_sgmii_active_82575(struct e1000_hw *hw) static bool igb_sgmii_active_82575(struct e1000_hw *hw)
{ {
struct e1000_dev_spec_82575 *dev_spec; struct e1000_dev_spec_82575 *dev_spec = &hw->dev_spec._82575;
bool ret_val;
if (hw->mac.type != e1000_82575) { if (hw->mac.type != e1000_82575 && hw->mac.type != e1000_82576)
ret_val = false; return false;
goto out;
}
dev_spec = (struct e1000_dev_spec_82575 *)hw->dev_spec;
ret_val = dev_spec->sgmii_active; return dev_spec->sgmii_active;
out:
return ret_val;
} }
/** /**
......
...@@ -565,9 +565,12 @@ struct e1000_fc_info { ...@@ -565,9 +565,12 @@ struct e1000_fc_info {
enum e1000_fc_type original_type; enum e1000_fc_type original_type;
}; };
struct e1000_dev_spec_82575 {
bool sgmii_active;
};
struct e1000_hw { struct e1000_hw {
void *back; void *back;
void *dev_spec;
u8 __iomem *hw_addr; u8 __iomem *hw_addr;
u8 __iomem *flash_address; u8 __iomem *flash_address;
...@@ -580,7 +583,9 @@ struct e1000_hw { ...@@ -580,7 +583,9 @@ struct e1000_hw {
struct e1000_bus_info bus; struct e1000_bus_info bus;
struct e1000_host_mng_dhcp_cookie mng_cookie; struct e1000_host_mng_dhcp_cookie mng_cookie;
u32 dev_spec_size; union {
struct e1000_dev_spec_82575 _82575;
} dev_spec;
u16 device_id; u16 device_id;
u16 subsystem_vendor_id; u16 subsystem_vendor_id;
......
...@@ -37,19 +37,6 @@ ...@@ -37,19 +37,6 @@
static s32 igb_set_default_fc(struct e1000_hw *hw); static s32 igb_set_default_fc(struct e1000_hw *hw);
static s32 igb_set_fc_watermarks(struct e1000_hw *hw); static s32 igb_set_fc_watermarks(struct e1000_hw *hw);
/**
* igb_remove_device - Free device specific structure
* @hw: pointer to the HW structure
*
* If a device specific structure was allocated, this function will
* free it.
**/
void igb_remove_device(struct e1000_hw *hw)
{
/* Freeing the dev_spec member of e1000_hw structure */
kfree(hw->dev_spec);
}
static s32 igb_read_pcie_cap_reg(struct e1000_hw *hw, u32 reg, u16 *value) static s32 igb_read_pcie_cap_reg(struct e1000_hw *hw, u32 reg, u16 *value)
{ {
struct igb_adapter *adapter = hw->back; struct igb_adapter *adapter = hw->back;
......
...@@ -63,7 +63,6 @@ void igb_mta_set(struct e1000_hw *hw, u32 hash_value); ...@@ -63,7 +63,6 @@ void igb_mta_set(struct e1000_hw *hw, u32 hash_value);
void igb_put_hw_semaphore(struct e1000_hw *hw); void igb_put_hw_semaphore(struct e1000_hw *hw);
void igb_rar_set(struct e1000_hw *hw, u8 *addr, u32 index); void igb_rar_set(struct e1000_hw *hw, u8 *addr, u32 index);
s32 igb_check_alt_mac_addr(struct e1000_hw *hw); s32 igb_check_alt_mac_addr(struct e1000_hw *hw);
void igb_remove_device(struct e1000_hw *hw);
void igb_reset_adaptive(struct e1000_hw *hw); void igb_reset_adaptive(struct e1000_hw *hw);
void igb_update_adaptive(struct e1000_hw *hw); void igb_update_adaptive(struct e1000_hw *hw);
void igb_write_vfta(struct e1000_hw *hw, u32 offset, u32 value); void igb_write_vfta(struct e1000_hw *hw, u32 offset, u32 value);
......
...@@ -1329,7 +1329,6 @@ err_eeprom: ...@@ -1329,7 +1329,6 @@ err_eeprom:
if (hw->flash_address) if (hw->flash_address)
iounmap(hw->flash_address); iounmap(hw->flash_address);
igb_remove_device(hw);
igb_free_queues(adapter); igb_free_queues(adapter);
err_sw_init: err_sw_init:
err_hw_init: err_hw_init:
...@@ -1389,7 +1388,6 @@ static void __devexit igb_remove(struct pci_dev *pdev) ...@@ -1389,7 +1388,6 @@ static void __devexit igb_remove(struct pci_dev *pdev)
if (!igb_check_reset_block(&adapter->hw)) if (!igb_check_reset_block(&adapter->hw))
igb_reset_phy(&adapter->hw); igb_reset_phy(&adapter->hw);
igb_remove_device(&adapter->hw);
igb_reset_interrupt_capability(adapter); igb_reset_interrupt_capability(adapter);
igb_free_queues(adapter); igb_free_queues(adapter);
......
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