Commit 230064ba authored by Przemek Kitszel's avatar Przemek Kitszel Committed by Jakub Kicinski

ice: make use of DEFINE_FLEX() in ice_ddp.c

Use DEFINE_FLEX() macro for constant-num-of-elems (4)
flex array members of ice_ddp.c
Signed-off-by: default avatarPrzemek Kitszel <przemyslaw.kitszel@intel.com>
Link: https://lore.kernel.org/r/20230912115937.1645707-5-przemyslaw.kitszel@intel.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent a034fcdb
...@@ -1560,21 +1560,14 @@ static enum ice_ddp_state ice_init_pkg_info(struct ice_hw *hw, ...@@ -1560,21 +1560,14 @@ static enum ice_ddp_state ice_init_pkg_info(struct ice_hw *hw,
*/ */
static enum ice_ddp_state ice_get_pkg_info(struct ice_hw *hw) static enum ice_ddp_state ice_get_pkg_info(struct ice_hw *hw)
{ {
enum ice_ddp_state state = ICE_DDP_PKG_SUCCESS; DEFINE_FLEX(struct ice_aqc_get_pkg_info_resp, pkg_info, pkg_info,
struct ice_aqc_get_pkg_info_resp *pkg_info; ICE_PKG_CNT);
u16 size; u16 size = __struct_size(pkg_info);
u32 i; u32 i;
size = struct_size(pkg_info, pkg_info, ICE_PKG_CNT); if (ice_aq_get_pkg_info_list(hw, pkg_info, size, NULL))
pkg_info = kzalloc(size, GFP_KERNEL);
if (!pkg_info)
return ICE_DDP_PKG_ERR; return ICE_DDP_PKG_ERR;
if (ice_aq_get_pkg_info_list(hw, pkg_info, size, NULL)) {
state = ICE_DDP_PKG_ERR;
goto init_pkg_free_alloc;
}
for (i = 0; i < le32_to_cpu(pkg_info->count); i++) { for (i = 0; i < le32_to_cpu(pkg_info->count); i++) {
#define ICE_PKG_FLAG_COUNT 4 #define ICE_PKG_FLAG_COUNT 4
char flags[ICE_PKG_FLAG_COUNT + 1] = { 0 }; char flags[ICE_PKG_FLAG_COUNT + 1] = { 0 };
...@@ -1604,10 +1597,7 @@ static enum ice_ddp_state ice_get_pkg_info(struct ice_hw *hw) ...@@ -1604,10 +1597,7 @@ static enum ice_ddp_state ice_get_pkg_info(struct ice_hw *hw)
pkg_info->pkg_info[i].name, flags); pkg_info->pkg_info[i].name, flags);
} }
init_pkg_free_alloc: return ICE_DDP_PKG_SUCCESS;
kfree(pkg_info);
return state;
} }
/** /**
...@@ -1622,9 +1612,10 @@ static enum ice_ddp_state ice_chk_pkg_compat(struct ice_hw *hw, ...@@ -1622,9 +1612,10 @@ static enum ice_ddp_state ice_chk_pkg_compat(struct ice_hw *hw,
struct ice_pkg_hdr *ospkg, struct ice_pkg_hdr *ospkg,
struct ice_seg **seg) struct ice_seg **seg)
{ {
struct ice_aqc_get_pkg_info_resp *pkg; DEFINE_FLEX(struct ice_aqc_get_pkg_info_resp, pkg, pkg_info,
ICE_PKG_CNT);
u16 size = __struct_size(pkg);
enum ice_ddp_state state; enum ice_ddp_state state;
u16 size;
u32 i; u32 i;
/* Check package version compatibility */ /* Check package version compatibility */
...@@ -1643,15 +1634,8 @@ static enum ice_ddp_state ice_chk_pkg_compat(struct ice_hw *hw, ...@@ -1643,15 +1634,8 @@ static enum ice_ddp_state ice_chk_pkg_compat(struct ice_hw *hw,
} }
/* Check if FW is compatible with the OS package */ /* Check if FW is compatible with the OS package */
size = struct_size(pkg, pkg_info, ICE_PKG_CNT); if (ice_aq_get_pkg_info_list(hw, pkg, size, NULL))
pkg = kzalloc(size, GFP_KERNEL); return ICE_DDP_PKG_LOAD_ERROR;
if (!pkg)
return ICE_DDP_PKG_ERR;
if (ice_aq_get_pkg_info_list(hw, pkg, size, NULL)) {
state = ICE_DDP_PKG_LOAD_ERROR;
goto fw_ddp_compat_free_alloc;
}
for (i = 0; i < le32_to_cpu(pkg->count); i++) { for (i = 0; i < le32_to_cpu(pkg->count); i++) {
/* loop till we find the NVM package */ /* loop till we find the NVM package */
...@@ -1668,8 +1652,7 @@ static enum ice_ddp_state ice_chk_pkg_compat(struct ice_hw *hw, ...@@ -1668,8 +1652,7 @@ static enum ice_ddp_state ice_chk_pkg_compat(struct ice_hw *hw,
/* done processing NVM package so break */ /* done processing NVM package so break */
break; break;
} }
fw_ddp_compat_free_alloc:
kfree(pkg);
return state; return state;
} }
......
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