Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

eth: fbnic: Replace kzalloc/fbnic_fw_init_cmpl with fbnic_fw_alloc_cmpl

Replace the pattern of calling and validating kzalloc then
fbnic_fw_init_cmpl with a single function, fbnic_fw_alloc_cmpl.

Signed-off-by: Lee Trager <lee@trager.us>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Link: https://patch.msgid.link/20250516164804.741348-1-lee@trager.us
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Lee Trager and committed by
Jakub Kicinski
fa919a30 d65a74d6

+16 -15
+2 -4
drivers/net/ethernet/meta/fbnic/fbnic_devlink.c
··· 166 166 struct fbnic_fw_completion *cmpl; 167 167 int err; 168 168 169 - cmpl = kzalloc(sizeof(*cmpl), GFP_KERNEL); 169 + cmpl = fbnic_fw_alloc_cmpl(FBNIC_TLV_MSG_ID_FW_START_UPGRADE_REQ); 170 170 if (!cmpl) 171 171 return -ENOMEM; 172 172 173 - fbnic_fw_init_cmpl(cmpl, FBNIC_TLV_MSG_ID_FW_START_UPGRADE_REQ); 174 173 err = fbnic_fw_xmit_fw_start_upgrade(fbd, cmpl, 175 174 component->identifier, 176 175 component->component_size); ··· 236 237 * Setup completions for write before issuing the start message so 237 238 * the driver can catch both messages. 238 239 */ 239 - cmpl = kzalloc(sizeof(*cmpl), GFP_KERNEL); 240 + cmpl = fbnic_fw_alloc_cmpl(FBNIC_TLV_MSG_ID_FW_WRITE_CHUNK_REQ); 240 241 if (!cmpl) 241 242 return -ENOMEM; 242 243 243 - fbnic_fw_init_cmpl(cmpl, FBNIC_TLV_MSG_ID_FW_WRITE_CHUNK_REQ); 244 244 err = fbnic_mbx_set_cmpl(fbd, cmpl); 245 245 if (err) 246 246 goto cmpl_free;
+12 -5
drivers/net/ethernet/meta/fbnic/fbnic_fw.c
··· 1232 1232 fw_version, str_sz); 1233 1233 } 1234 1234 1235 - void fbnic_fw_init_cmpl(struct fbnic_fw_completion *fw_cmpl, 1236 - u32 msg_type) 1235 + struct fbnic_fw_completion *fbnic_fw_alloc_cmpl(u32 msg_type) 1237 1236 { 1238 - fw_cmpl->msg_type = msg_type; 1239 - init_completion(&fw_cmpl->done); 1240 - kref_init(&fw_cmpl->ref_count); 1237 + struct fbnic_fw_completion *cmpl; 1238 + 1239 + cmpl = kzalloc(sizeof(*cmpl), GFP_KERNEL); 1240 + if (!cmpl) 1241 + return NULL; 1242 + 1243 + cmpl->msg_type = msg_type; 1244 + init_completion(&cmpl->done); 1245 + kref_init(&cmpl->ref_count); 1246 + 1247 + return cmpl; 1241 1248 } 1242 1249 1243 1250 void fbnic_fw_clear_cmpl(struct fbnic_dev *fbd,
+1 -2
drivers/net/ethernet/meta/fbnic/fbnic_fw.h
··· 80 80 int cancel_error); 81 81 int fbnic_fw_xmit_tsene_read_msg(struct fbnic_dev *fbd, 82 82 struct fbnic_fw_completion *cmpl_data); 83 - void fbnic_fw_init_cmpl(struct fbnic_fw_completion *cmpl_data, 84 - u32 msg_type); 83 + struct fbnic_fw_completion *fbnic_fw_alloc_cmpl(u32 msg_type); 85 84 void fbnic_fw_clear_cmpl(struct fbnic_dev *fbd, 86 85 struct fbnic_fw_completion *cmpl_data); 87 86 void fbnic_fw_put_cmpl(struct fbnic_fw_completion *cmpl_data);
+1 -4
drivers/net/ethernet/meta/fbnic/fbnic_mac.c
··· 687 687 int err = 0, retries = 5; 688 688 s32 *sensor; 689 689 690 - fw_cmpl = kzalloc(sizeof(*fw_cmpl), GFP_KERNEL); 690 + fw_cmpl = fbnic_fw_alloc_cmpl(FBNIC_TLV_MSG_ID_TSENE_READ_RESP); 691 691 if (!fw_cmpl) 692 692 return -ENOMEM; 693 - 694 - /* Initialize completion and queue it for FW to process */ 695 - fbnic_fw_init_cmpl(fw_cmpl, FBNIC_TLV_MSG_ID_TSENE_READ_RESP); 696 693 697 694 switch (id) { 698 695 case FBNIC_SENSOR_TEMP: