From 14fa11f485909da8f1219c9474149e8091db6df6 Mon Sep 17 00:00:00 2001 From: Qi Zhang Date: Wed, 26 Aug 2020 21:06:56 +0800 Subject: [PATCH] net/ice/base: change misc ACL style This is a collection of minor ACL style changes including: - When there is nothing to unroll, return a value directly. - Return ICE_SUCCESS(0) in cases where an error was previously checked so ICE_SUCCESS is the only possible return. - Remove unnecessary parentheses and newlines - Move unroll of allocation to end of function and use goto on errors to free. - Fix function header comment style - Remove 'else' from an 'if else' condition where both conditions return a value to reduce indentation. Signed-off-by: Tony Nguyen Signed-off-by: Qi Zhang Acked-by: Qiming Yang --- drivers/net/ice/base/ice_acl_ctrl.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/drivers/net/ice/base/ice_acl_ctrl.c b/drivers/net/ice/base/ice_acl_ctrl.c index 02a1dd34f1..bd09e9d776 100644 --- a/drivers/net/ice/base/ice_acl_ctrl.c +++ b/drivers/net/ice/base/ice_acl_ctrl.c @@ -149,10 +149,8 @@ static enum ice_status ice_acl_init_tbl(struct ice_hw *hw) u16 idx; tbl = hw->acl_tbl; - if (!tbl) { - status = ICE_ERR_CFG; - return status; - } + if (!tbl) + return ICE_ERR_CFG; ice_memset(&buf, 0, sizeof(buf), ICE_NONDMA_MEM); ice_memset(&act_buf, 0, sizeof(act_buf), ICE_NONDMA_MEM); @@ -526,7 +524,7 @@ ice_acl_alloc_partition(struct ice_hw *hw, struct ice_acl_scen *req) break; } - row = (dir > 0) ? (row + width) : (row - width); + row = dir > 0 ? row + width : row - width; if (row > hw->acl_tbl->last_tcam || row < hw->acl_tbl->first_tcam) { /* All rows have been checked. Increment 'off' that @@ -668,8 +666,7 @@ static void ice_acl_assign_act_mem_for_scen(struct ice_acl_tbl *tbl, struct ice_acl_scen *scen, struct ice_aqc_acl_scen *scen_buf, - u8 current_tcam_idx, - u8 target_tcam_idx) + u8 current_tcam_idx, u8 target_tcam_idx) { u8 i; @@ -761,10 +758,8 @@ ice_acl_create_scen(struct ice_hw *hw, u16 match_width, u16 num_entries, scen->num_entry = num_entries; status = ice_acl_alloc_partition(hw, scen); - if (status) { - ice_free(hw, scen); - return status; - } + if (status) + goto out; ice_memset(&scen_buf, 0, sizeof(scen_buf), ICE_NONDMA_MEM); @@ -829,8 +824,7 @@ ice_acl_create_scen(struct ice_hw *hw, u16 match_width, u16 num_entries, if (status) { ice_debug(hw, ICE_DBG_ACL, "AQ allocation of ACL scenario failed. status: %d\n", status); - ice_free(hw, scen); - return status; + goto out; } scen->id = *scen_id; @@ -838,6 +832,10 @@ ice_acl_create_scen(struct ice_hw *hw, u16 match_width, u16 num_entries, ice_acl_init_entry(scen); LIST_ADD(&scen->list_entry, &hw->acl_tbl->scens); +out: + if (status) + ice_free(hw, scen); + return status; } -- 2.20.1