From: Qi Zhang Date: Wed, 26 Aug 2020 06:34:04 +0000 (+0800) Subject: net/ice/base: clean code wrapping X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=465f3809a61b9791e54059a8248ef6ebaa5cb9b5;p=dpdk.git net/ice/base: clean code wrapping To make the wrapping a little cleaner, move the variables only applicable to ICE_FC_AUTO into that case. Also move caching of the value to only occur on success. Signed-off-by: Tony Nguyen Signed-off-by: Qi Zhang Acked-by: Qiming Yang --- diff --git a/drivers/net/ice/base/ice_common.c b/drivers/net/ice/base/ice_common.c index 4be3630477..92b2df741b 100644 --- a/drivers/net/ice/base/ice_common.c +++ b/drivers/net/ice/base/ice_common.c @@ -2754,36 +2754,39 @@ static enum ice_status ice_cfg_phy_fc(struct ice_port_info *pi, struct ice_aqc_set_phy_cfg_data *cfg, enum ice_fc_mode req_mode) { - struct ice_aqc_get_phy_caps_data *pcaps = NULL; struct ice_phy_cache_mode_data cache_data; - enum ice_status status = ICE_SUCCESS; u8 pause_mask = 0x0; if (!pi || !cfg) return ICE_ERR_BAD_PTR; - pcaps = (struct ice_aqc_get_phy_caps_data *) - ice_malloc(pi->hw, sizeof(*pcaps)); - if (!pcaps) - return ICE_ERR_NO_MEMORY; - - /* Cache user FC request */ - cache_data.data.curr_user_fc_req = req_mode; - ice_cache_phy_user_req(pi, cache_data, ICE_FC_MODE); - switch (req_mode) { case ICE_FC_AUTO: + { + struct ice_aqc_get_phy_caps_data *pcaps; + enum ice_status status; + + pcaps = (struct ice_aqc_get_phy_caps_data *) + ice_malloc(pi->hw, sizeof(*pcaps)); + if (!pcaps) + return ICE_ERR_NO_MEMORY; + /* Query the value of FC that both the NIC and attached media * can do. */ status = ice_aq_get_phy_caps(pi, false, ICE_AQC_REPORT_TOPO_CAP, pcaps, NULL); - if (status) - goto out; + if (status) { + ice_free(pi->hw, pcaps); + return status; + } pause_mask |= pcaps->caps & ICE_AQC_PHY_EN_TX_LINK_PAUSE; pause_mask |= pcaps->caps & ICE_AQC_PHY_EN_RX_LINK_PAUSE; + + ice_free(pi->hw, pcaps); break; + } case ICE_FC_FULL: pause_mask |= ICE_AQC_PHY_EN_TX_LINK_PAUSE; pause_mask |= ICE_AQC_PHY_EN_RX_LINK_PAUSE; @@ -2805,9 +2808,11 @@ ice_cfg_phy_fc(struct ice_port_info *pi, struct ice_aqc_set_phy_cfg_data *cfg, /* set the new capabilities */ cfg->caps |= pause_mask; -out: - ice_free(pi->hw, pcaps); - return status; + /* Cache user FC request */ + cache_data.data.curr_user_fc_req = req_mode; + ice_cache_phy_user_req(pi, cache_data, ICE_FC_MODE); + + return ICE_SUCCESS; } /**