Skip to content

Commit fa919a3

Browse files
ltragerkuba-moo
authored andcommitted
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 <[email protected]> Reviewed-by: Jacob Keller <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent d65a74d commit fa919a3

File tree

4 files changed

+16
-15
lines changed

4 files changed

+16
-15
lines changed

drivers/net/ethernet/meta/fbnic/fbnic_devlink.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,10 @@ fbnic_flash_start(struct fbnic_dev *fbd, struct pldmfw_component *component)
166166
struct fbnic_fw_completion *cmpl;
167167
int err;
168168

169-
cmpl = kzalloc(sizeof(*cmpl), GFP_KERNEL);
169+
cmpl = fbnic_fw_alloc_cmpl(FBNIC_TLV_MSG_ID_FW_START_UPGRADE_REQ);
170170
if (!cmpl)
171171
return -ENOMEM;
172172

173-
fbnic_fw_init_cmpl(cmpl, FBNIC_TLV_MSG_ID_FW_START_UPGRADE_REQ);
174173
err = fbnic_fw_xmit_fw_start_upgrade(fbd, cmpl,
175174
component->identifier,
176175
component->component_size);
@@ -237,11 +236,10 @@ fbnic_flash_component(struct pldmfw *context,
237236
* Setup completions for write before issuing the start message so
238237
* the driver can catch both messages.
239238
*/
240-
cmpl = kzalloc(sizeof(*cmpl), GFP_KERNEL);
239+
cmpl = fbnic_fw_alloc_cmpl(FBNIC_TLV_MSG_ID_FW_WRITE_CHUNK_REQ);
241240
if (!cmpl)
242241
return -ENOMEM;
243242

244-
fbnic_fw_init_cmpl(cmpl, FBNIC_TLV_MSG_ID_FW_WRITE_CHUNK_REQ);
245243
err = fbnic_mbx_set_cmpl(fbd, cmpl);
246244
if (err)
247245
goto cmpl_free;

drivers/net/ethernet/meta/fbnic/fbnic_fw.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1232,12 +1232,19 @@ void fbnic_get_fw_ver_commit_str(struct fbnic_dev *fbd, char *fw_version,
12321232
fw_version, str_sz);
12331233
}
12341234

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)
12371236
{
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;
12411248
}
12421249

12431250
void fbnic_fw_clear_cmpl(struct fbnic_dev *fbd,

drivers/net/ethernet/meta/fbnic/fbnic_fw.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@ int fbnic_fw_xmit_fw_write_chunk(struct fbnic_dev *fbd,
8080
int cancel_error);
8181
int fbnic_fw_xmit_tsene_read_msg(struct fbnic_dev *fbd,
8282
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);
8584
void fbnic_fw_clear_cmpl(struct fbnic_dev *fbd,
8685
struct fbnic_fw_completion *cmpl_data);
8786
void fbnic_fw_put_cmpl(struct fbnic_fw_completion *cmpl_data);

drivers/net/ethernet/meta/fbnic/fbnic_mac.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -687,13 +687,10 @@ static int fbnic_mac_get_sensor_asic(struct fbnic_dev *fbd, int id,
687687
int err = 0, retries = 5;
688688
s32 *sensor;
689689

690-
fw_cmpl = kzalloc(sizeof(*fw_cmpl), GFP_KERNEL);
690+
fw_cmpl = fbnic_fw_alloc_cmpl(FBNIC_TLV_MSG_ID_TSENE_READ_RESP);
691691
if (!fw_cmpl)
692692
return -ENOMEM;
693693

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-
697694
switch (id) {
698695
case FBNIC_SENSOR_TEMP:
699696
sensor = &fw_cmpl->u.tsene.millidegrees;

0 commit comments

Comments
 (0)