netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] eth: fbnic: Replace kzalloc/fbnic_fw_init_cmpl with fbnic_fw_alloc_cmpl
@ 2025-05-16 16:46 Lee Trager
  2025-05-16 21:03 ` Keller, Jacob E
  2025-05-21  3:06 ` Jakub Kicinski
  0 siblings, 2 replies; 3+ messages in thread
From: Lee Trager @ 2025-05-16 16:46 UTC (permalink / raw)
  To: Alexander Duyck, Jakub Kicinski, kernel-team, Andrew Lunn,
	David S. Miller, Eric Dumazet, Paolo Abeni, Lee Trager,
	Jacob Keller, Al Viro, Simon Horman, Sanman Pradhan, Su Hui,
	Mohsin Bashir
  Cc: netdev, linux-kernel

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>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
 drivers/net/ethernet/meta/fbnic/fbnic_devlink.c |  6 ++----
 drivers/net/ethernet/meta/fbnic/fbnic_fw.c      | 17 ++++++++++++-----
 drivers/net/ethernet/meta/fbnic/fbnic_fw.h      |  3 +--
 drivers/net/ethernet/meta/fbnic/fbnic_mac.c     |  5 +----
 4 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_devlink.c b/drivers/net/ethernet/meta/fbnic/fbnic_devlink.c
index 71d9461a0d1b..4c4938eedd7b 100644
--- a/drivers/net/ethernet/meta/fbnic/fbnic_devlink.c
+++ b/drivers/net/ethernet/meta/fbnic/fbnic_devlink.c
@@ -166,11 +166,10 @@ fbnic_flash_start(struct fbnic_dev *fbd, struct pldmfw_component *component)
 	struct fbnic_fw_completion *cmpl;
 	int err;

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

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

-	fbnic_fw_init_cmpl(cmpl, FBNIC_TLV_MSG_ID_FW_WRITE_CHUNK_REQ);
 	err = fbnic_mbx_set_cmpl(fbd, cmpl);
 	if (err)
 		goto cmpl_free;
diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_fw.c b/drivers/net/ethernet/meta/fbnic/fbnic_fw.c
index 6a803a59dc25..e2368075ab8c 100644
--- a/drivers/net/ethernet/meta/fbnic/fbnic_fw.c
+++ b/drivers/net/ethernet/meta/fbnic/fbnic_fw.c
@@ -1232,12 +1232,19 @@ void fbnic_get_fw_ver_commit_str(struct fbnic_dev *fbd, char *fw_version,
 				 fw_version, str_sz);
 }

-void fbnic_fw_init_cmpl(struct fbnic_fw_completion *fw_cmpl,
-			u32 msg_type)
+struct fbnic_fw_completion *fbnic_fw_alloc_cmpl(u32 msg_type)
 {
-	fw_cmpl->msg_type = msg_type;
-	init_completion(&fw_cmpl->done);
-	kref_init(&fw_cmpl->ref_count);
+	struct fbnic_fw_completion *cmpl;
+
+	cmpl = kzalloc(sizeof(*cmpl), GFP_KERNEL);
+	if (!cmpl)
+		return NULL;
+
+	cmpl->msg_type = msg_type;
+	init_completion(&cmpl->done);
+	kref_init(&cmpl->ref_count);
+
+	return cmpl;
 }

 void fbnic_fw_clear_cmpl(struct fbnic_dev *fbd,
diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_fw.h b/drivers/net/ethernet/meta/fbnic/fbnic_fw.h
index 6baac10fd688..08bc4b918de7 100644
--- a/drivers/net/ethernet/meta/fbnic/fbnic_fw.h
+++ b/drivers/net/ethernet/meta/fbnic/fbnic_fw.h
@@ -80,8 +80,7 @@ int fbnic_fw_xmit_fw_write_chunk(struct fbnic_dev *fbd,
 				 int cancel_error);
 int fbnic_fw_xmit_tsene_read_msg(struct fbnic_dev *fbd,
 				 struct fbnic_fw_completion *cmpl_data);
-void fbnic_fw_init_cmpl(struct fbnic_fw_completion *cmpl_data,
-			u32 msg_type);
+struct fbnic_fw_completion *fbnic_fw_alloc_cmpl(u32 msg_type);
 void fbnic_fw_clear_cmpl(struct fbnic_dev *fbd,
 			 struct fbnic_fw_completion *cmpl_data);
 void fbnic_fw_put_cmpl(struct fbnic_fw_completion *cmpl_data);
diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_mac.c b/drivers/net/ethernet/meta/fbnic/fbnic_mac.c
index 4ba6f8d10775..10e108c1fcd0 100644
--- a/drivers/net/ethernet/meta/fbnic/fbnic_mac.c
+++ b/drivers/net/ethernet/meta/fbnic/fbnic_mac.c
@@ -687,13 +687,10 @@ static int fbnic_mac_get_sensor_asic(struct fbnic_dev *fbd, int id,
 	int err = 0, retries = 5;
 	s32 *sensor;

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

-	/* Initialize completion and queue it for FW to process */
-	fbnic_fw_init_cmpl(fw_cmpl, FBNIC_TLV_MSG_ID_TSENE_READ_RESP);
-
 	switch (id) {
 	case FBNIC_SENSOR_TEMP:
 		sensor = &fw_cmpl->u.tsene.millidegrees;
--
2.47.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* RE: [PATCH net-next] eth: fbnic: Replace kzalloc/fbnic_fw_init_cmpl with fbnic_fw_alloc_cmpl
  2025-05-16 16:46 [PATCH net-next] eth: fbnic: Replace kzalloc/fbnic_fw_init_cmpl with fbnic_fw_alloc_cmpl Lee Trager
@ 2025-05-16 21:03 ` Keller, Jacob E
  2025-05-21  3:06 ` Jakub Kicinski
  1 sibling, 0 replies; 3+ messages in thread
From: Keller, Jacob E @ 2025-05-16 21:03 UTC (permalink / raw)
  To: Lee Trager, Alexander Duyck, Jakub Kicinski, kernel-team@meta.com,
	Andrew Lunn, David S. Miller, Eric Dumazet, Paolo Abeni, Al Viro,
	Simon Horman, Sanman Pradhan, Su Hui, Mohsin Bashir
  Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org



> -----Original Message-----
> From: Lee Trager <lee@trager.us>
> Sent: Friday, May 16, 2025 9:47 AM
> To: Alexander Duyck <alexanderduyck@fb.com>; Jakub Kicinski
> <kuba@kernel.org>; kernel-team@meta.com; Andrew Lunn
> <andrew+netdev@lunn.ch>; David S. Miller <davem@davemloft.net>; Eric
> Dumazet <edumazet@google.com>; Paolo Abeni <pabeni@redhat.com>; Lee
> Trager <lee@trager.us>; Keller, Jacob E <jacob.e.keller@intel.com>; Al Viro
> <viro@zeniv.linux.org.uk>; Simon Horman <horms@kernel.org>; Sanman
> Pradhan <sanmanpradhan@meta.com>; Su Hui <suhui@nfschina.com>; Mohsin
> Bashir <mohsin.bashr@gmail.com>
> Cc: netdev@vger.kernel.org; linux-kernel@vger.kernel.org
> Subject: [PATCH net-next] 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>
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> ---

Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] eth: fbnic: Replace kzalloc/fbnic_fw_init_cmpl with fbnic_fw_alloc_cmpl
  2025-05-16 16:46 [PATCH net-next] eth: fbnic: Replace kzalloc/fbnic_fw_init_cmpl with fbnic_fw_alloc_cmpl Lee Trager
  2025-05-16 21:03 ` Keller, Jacob E
@ 2025-05-21  3:06 ` Jakub Kicinski
  1 sibling, 0 replies; 3+ messages in thread
From: Jakub Kicinski @ 2025-05-21  3:06 UTC (permalink / raw)
  To: Lee Trager
  Cc: Alexander Duyck, kernel-team, Andrew Lunn, David S. Miller,
	Eric Dumazet, Paolo Abeni, Jacob Keller, Al Viro, Simon Horman,
	Sanman Pradhan, Su Hui, Mohsin Bashir, netdev, linux-kernel

On Fri, 16 May 2025 09:46:41 -0700 Lee Trager wrote:
> 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>

Applied, thanks!

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-05-21  3:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-16 16:46 [PATCH net-next] eth: fbnic: Replace kzalloc/fbnic_fw_init_cmpl with fbnic_fw_alloc_cmpl Lee Trager
2025-05-16 21:03 ` Keller, Jacob E
2025-05-21  3:06 ` Jakub Kicinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).