Commit 90f821d7 authored by Maciej Fijalkowski's avatar Maciej Fijalkowski Committed by Tony Nguyen

ice: avoid unnecessary devm_ usage

1. pcaps are free'd right after AQ routines are done, no need for
   devm_'s
2. a test frame for loopback test in ethtool -t is destroyed at the end
   of the test so we don't need devm_ here either.
Signed-off-by: default avatarMaciej Fijalkowski <maciej.fijalkowski@intel.com>
Reviewed-by: default avatarPrzemek Kitszel <przemyslaw.kitszel@intel.com>
Tested-by: Pucha Himasekhar Reddy <himasekharx.reddy.pucha@intel.com> (A Contingent worker at Intel)
Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
parent d5926e01
...@@ -1002,9 +1002,9 @@ static void ice_get_itr_intrl_gran(struct ice_hw *hw) ...@@ -1002,9 +1002,9 @@ static void ice_get_itr_intrl_gran(struct ice_hw *hw)
*/ */
int ice_init_hw(struct ice_hw *hw) int ice_init_hw(struct ice_hw *hw)
{ {
struct ice_aqc_get_phy_caps_data *pcaps; struct ice_aqc_get_phy_caps_data *pcaps __free(kfree);
void *mac_buf __free(kfree);
u16 mac_buf_len; u16 mac_buf_len;
void *mac_buf;
int status; int status;
/* Set MAC type based on DeviceID */ /* Set MAC type based on DeviceID */
...@@ -1082,7 +1082,7 @@ int ice_init_hw(struct ice_hw *hw) ...@@ -1082,7 +1082,7 @@ int ice_init_hw(struct ice_hw *hw)
if (status) if (status)
goto err_unroll_sched; goto err_unroll_sched;
pcaps = devm_kzalloc(ice_hw_to_dev(hw), sizeof(*pcaps), GFP_KERNEL); pcaps = kzalloc(sizeof(*pcaps), GFP_KERNEL);
if (!pcaps) { if (!pcaps) {
status = -ENOMEM; status = -ENOMEM;
goto err_unroll_sched; goto err_unroll_sched;
...@@ -1092,7 +1092,6 @@ int ice_init_hw(struct ice_hw *hw) ...@@ -1092,7 +1092,6 @@ int ice_init_hw(struct ice_hw *hw)
status = ice_aq_get_phy_caps(hw->port_info, false, status = ice_aq_get_phy_caps(hw->port_info, false,
ICE_AQC_REPORT_TOPO_CAP_MEDIA, pcaps, ICE_AQC_REPORT_TOPO_CAP_MEDIA, pcaps,
NULL); NULL);
devm_kfree(ice_hw_to_dev(hw), pcaps);
if (status) if (status)
dev_warn(ice_hw_to_dev(hw), "Get PHY capabilities failed status = %d, continuing anyway\n", dev_warn(ice_hw_to_dev(hw), "Get PHY capabilities failed status = %d, continuing anyway\n",
status); status);
...@@ -1119,18 +1118,15 @@ int ice_init_hw(struct ice_hw *hw) ...@@ -1119,18 +1118,15 @@ int ice_init_hw(struct ice_hw *hw)
/* Get MAC information */ /* Get MAC information */
/* A single port can report up to two (LAN and WoL) addresses */ /* A single port can report up to two (LAN and WoL) addresses */
mac_buf = devm_kcalloc(ice_hw_to_dev(hw), 2, mac_buf = kcalloc(2, sizeof(struct ice_aqc_manage_mac_read_resp),
sizeof(struct ice_aqc_manage_mac_read_resp), GFP_KERNEL);
GFP_KERNEL);
mac_buf_len = 2 * sizeof(struct ice_aqc_manage_mac_read_resp);
if (!mac_buf) { if (!mac_buf) {
status = -ENOMEM; status = -ENOMEM;
goto err_unroll_fltr_mgmt_struct; goto err_unroll_fltr_mgmt_struct;
} }
mac_buf_len = 2 * sizeof(struct ice_aqc_manage_mac_read_resp);
status = ice_aq_manage_mac_read(hw, mac_buf, mac_buf_len, NULL); status = ice_aq_manage_mac_read(hw, mac_buf, mac_buf_len, NULL);
devm_kfree(ice_hw_to_dev(hw), mac_buf);
if (status) if (status)
goto err_unroll_fltr_mgmt_struct; goto err_unroll_fltr_mgmt_struct;
...@@ -3276,19 +3272,14 @@ int ice_update_link_info(struct ice_port_info *pi) ...@@ -3276,19 +3272,14 @@ int ice_update_link_info(struct ice_port_info *pi)
return status; return status;
if (li->link_info & ICE_AQ_MEDIA_AVAILABLE) { if (li->link_info & ICE_AQ_MEDIA_AVAILABLE) {
struct ice_aqc_get_phy_caps_data *pcaps; struct ice_aqc_get_phy_caps_data *pcaps __free(kfree);
struct ice_hw *hw;
hw = pi->hw; pcaps = kzalloc(sizeof(*pcaps), GFP_KERNEL);
pcaps = devm_kzalloc(ice_hw_to_dev(hw), sizeof(*pcaps),
GFP_KERNEL);
if (!pcaps) if (!pcaps)
return -ENOMEM; return -ENOMEM;
status = ice_aq_get_phy_caps(pi, false, ICE_AQC_REPORT_TOPO_CAP_MEDIA, status = ice_aq_get_phy_caps(pi, false, ICE_AQC_REPORT_TOPO_CAP_MEDIA,
pcaps, NULL); pcaps, NULL);
devm_kfree(ice_hw_to_dev(hw), pcaps);
} }
return status; return status;
...@@ -3429,8 +3420,8 @@ ice_cfg_phy_fc(struct ice_port_info *pi, struct ice_aqc_set_phy_cfg_data *cfg, ...@@ -3429,8 +3420,8 @@ ice_cfg_phy_fc(struct ice_port_info *pi, struct ice_aqc_set_phy_cfg_data *cfg,
int int
ice_set_fc(struct ice_port_info *pi, u8 *aq_failures, bool ena_auto_link_update) ice_set_fc(struct ice_port_info *pi, u8 *aq_failures, bool ena_auto_link_update)
{ {
struct ice_aqc_get_phy_caps_data *pcaps __free(kfree);
struct ice_aqc_set_phy_cfg_data cfg = { 0 }; struct ice_aqc_set_phy_cfg_data cfg = { 0 };
struct ice_aqc_get_phy_caps_data *pcaps;
struct ice_hw *hw; struct ice_hw *hw;
int status; int status;
...@@ -3440,7 +3431,7 @@ ice_set_fc(struct ice_port_info *pi, u8 *aq_failures, bool ena_auto_link_update) ...@@ -3440,7 +3431,7 @@ ice_set_fc(struct ice_port_info *pi, u8 *aq_failures, bool ena_auto_link_update)
*aq_failures = 0; *aq_failures = 0;
hw = pi->hw; hw = pi->hw;
pcaps = devm_kzalloc(ice_hw_to_dev(hw), sizeof(*pcaps), GFP_KERNEL); pcaps = kzalloc(sizeof(*pcaps), GFP_KERNEL);
if (!pcaps) if (!pcaps)
return -ENOMEM; return -ENOMEM;
...@@ -3492,7 +3483,6 @@ ice_set_fc(struct ice_port_info *pi, u8 *aq_failures, bool ena_auto_link_update) ...@@ -3492,7 +3483,6 @@ ice_set_fc(struct ice_port_info *pi, u8 *aq_failures, bool ena_auto_link_update)
} }
out: out:
devm_kfree(ice_hw_to_dev(hw), pcaps);
return status; return status;
} }
...@@ -3571,7 +3561,7 @@ int ...@@ -3571,7 +3561,7 @@ int
ice_cfg_phy_fec(struct ice_port_info *pi, struct ice_aqc_set_phy_cfg_data *cfg, ice_cfg_phy_fec(struct ice_port_info *pi, struct ice_aqc_set_phy_cfg_data *cfg,
enum ice_fec_mode fec) enum ice_fec_mode fec)
{ {
struct ice_aqc_get_phy_caps_data *pcaps; struct ice_aqc_get_phy_caps_data *pcaps __free(kfree);
struct ice_hw *hw; struct ice_hw *hw;
int status; int status;
...@@ -3640,8 +3630,6 @@ ice_cfg_phy_fec(struct ice_port_info *pi, struct ice_aqc_set_phy_cfg_data *cfg, ...@@ -3640,8 +3630,6 @@ ice_cfg_phy_fec(struct ice_port_info *pi, struct ice_aqc_set_phy_cfg_data *cfg,
} }
out: out:
kfree(pcaps);
return status; return status;
} }
......
...@@ -802,7 +802,7 @@ static int ice_lbtest_create_frame(struct ice_pf *pf, u8 **ret_data, u16 size) ...@@ -802,7 +802,7 @@ static int ice_lbtest_create_frame(struct ice_pf *pf, u8 **ret_data, u16 size)
if (!pf) if (!pf)
return -EINVAL; return -EINVAL;
data = devm_kzalloc(ice_pf_to_dev(pf), size, GFP_KERNEL); data = kzalloc(size, GFP_KERNEL);
if (!data) if (!data)
return -ENOMEM; return -ENOMEM;
...@@ -945,11 +945,9 @@ static u64 ice_loopback_test(struct net_device *netdev) ...@@ -945,11 +945,9 @@ static u64 ice_loopback_test(struct net_device *netdev)
int num_frames, valid_frames; int num_frames, valid_frames;
struct ice_tx_ring *tx_ring; struct ice_tx_ring *tx_ring;
struct ice_rx_ring *rx_ring; struct ice_rx_ring *rx_ring;
struct device *dev; u8 *tx_frame __free(kfree);
u8 *tx_frame;
int i; int i;
dev = ice_pf_to_dev(pf);
netdev_info(netdev, "loopback test\n"); netdev_info(netdev, "loopback test\n");
test_vsi = ice_lb_vsi_setup(pf, pf->hw.port_info); test_vsi = ice_lb_vsi_setup(pf, pf->hw.port_info);
...@@ -994,7 +992,7 @@ static u64 ice_loopback_test(struct net_device *netdev) ...@@ -994,7 +992,7 @@ static u64 ice_loopback_test(struct net_device *netdev)
for (i = 0; i < num_frames; i++) { for (i = 0; i < num_frames; i++) {
if (ice_diag_send(tx_ring, tx_frame, ICE_LB_FRAME_SIZE)) { if (ice_diag_send(tx_ring, tx_frame, ICE_LB_FRAME_SIZE)) {
ret = 8; ret = 8;
goto lbtest_free_frame; goto remove_mac_filters;
} }
} }
...@@ -1004,8 +1002,6 @@ static u64 ice_loopback_test(struct net_device *netdev) ...@@ -1004,8 +1002,6 @@ static u64 ice_loopback_test(struct net_device *netdev)
else if (valid_frames != num_frames) else if (valid_frames != num_frames)
ret = 10; ret = 10;
lbtest_free_frame:
devm_kfree(dev, tx_frame);
remove_mac_filters: remove_mac_filters:
if (ice_fltr_remove_mac(test_vsi, broadcast, ICE_FWD_TO_VSI)) if (ice_fltr_remove_mac(test_vsi, broadcast, ICE_FWD_TO_VSI))
netdev_err(netdev, "Could not remove MAC filter for the test VSI\n"); netdev_err(netdev, "Could not remove MAC filter for the test VSI\n");
......
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