idpf: remove unreachable code from setting mailbox
Subsystems (3)
PATCH 1/1 idpf: remove unreachable code from setting mailbox
Remove code that isn't reached. There is no need to check for adapter->req_vec_chunks, because if it isn't set idpf_set_mb_vec_id() won't be called.
Only one path when idpf_set_mb_vec_id() is called:idpf_intr_req()
-> idpf_send_alloc_vectors_msg() -> adapter->req_vec_chunk is allocated here, otherwise an error is returned and idpf_intr_req() exits with an error.
The idpf_set_mb_vec_id() becomes one-linear and it is called only once. Remove it and set mailbox vector index directly.
--- drivers/net/ethernet/intel/idpf/idpf_lib.c | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-)
drivers/net/ethernet/intel/idpf/idpf_lib.c +1 -17
@@ -143,22 +143,6 @@ static int idpf_mb_intr_req_irq(struct idpf_adapter *adapter)return 0 ; } -/** -* idpf_set_mb_vec_id - Set vector index for mailbox -* @adapter: adapter structure to access the vector chunks -* -* The first vector id in the requested vector chunks from the CP is for -* the mailbox -*/ -static void idpf_set_mb_vec_id (struct idpf_adapter *adapter) -{ -if (adapter->req_vec_chunks) - adapter->mb_vector.v_idx = -le16_to_cpu (adapter->caps.mailbox_vector_id); -else - adapter->mb_vector.v_idx =0 ; -} -/** * idpf_mb_intr_init - Initialize the mailbox interrupt * @adapter: adapter structure to store the mailbox vector
@@ -349,7 +333,7 @@ int idpf_intr_req(struct idpf_adapter *adapter) goto free_irq; } -idpf_set_mb_vec_id (adapter); + adapter->mb_vector.v_idx =le16_to_cpu (adapter->caps.mailbox_vector_id); vecids =kcalloc (total_vecs,sizeof (u16),GFP_KERNEL );if (!vecids) {
Signature · 1 line
2.42.0
Quoted 9 lines · Michal Swiatkowski
Remove code that isn't reached. There is no need to check for
adapter->req_vec_chunks, because if it isn't setidpf_set_mb_vec_id()won't be called.Only one path when
idpf_set_mb_vec_id()is called:idpf_intr_req()
->idpf_send_alloc_vectors_msg()->adapter->req_vec_chunkis allocated here, otherwise an error is returned andidpf_intr_req()exits with an error.
I agree this is correct, but perhaps it would be clearer to say something like this:
* idpf_set_mb_vec_id() is only called from idpf_intr_req()
* Before that idpf_intr_req() calls idpf_send_alloc_vectors_msg()
* idpf_send_alloc_vectors_msg() allocates adapter->req_vec_chunk
Quoted 2 lines
The
idpf_set_mb_vec_id()becomes one-linear and it is called only once.
nit: one liner
Quoted 6 lines
Remove it and set mailbox vector index directly.
Reviewed-by Aleksandr Loktionov <[email protected]>Reviewed-by Michal Kubiak <[email protected]>Reviewed-by Pavan Kumar Linga <[email protected]>Signed-off-by Michal Swiatkowski <[email protected]>
The above notwithstanding, this looks good to me.
Salin, Samuel
Tested-byQuoted 39 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Simon Horman
Sent: Friday, April 11, 2025 3:45 AM
To: Michal Swiatkowski <[email protected]>
Cc: [email protected]; [email protected]; Loktionov, Aleksandr <[email protected]>; Kubiak, Michal <[email protected]>; Linga, Pavan Kumar <[email protected]>
Subject: Re: [Intel-wired-lan] [PATCH iwl-next v1] idpf: remove unreachable code from setting mailboxQuoted 9 lines · Michal Swiatkowski
Remove code that isn't reached. There is no need to check for
adapter->req_vec_chunks, because if it isn't setidpf_set_mb_vec_id()won't be called.Only one path when
idpf_set_mb_vec_id()is called:idpf_intr_req()
->idpf_send_alloc_vectors_msg()->adapter->req_vec_chunkis
allocated here, otherwise an error is returned andidpf_intr_req()exits with an error.I agree this is correct, but perhaps it would be clearer to say something like this:
*
idpf_set_mb_vec_id()is only called fromidpf_intr_req()
* Before thatidpf_intr_req()callsidpf_send_alloc_vectors_msg()
*idpf_send_alloc_vectors_msg()allocatesadapter->req_vec_chunkQuoted 2 lines
The
idpf_set_mb_vec_id()becomes one-linear and it is called only once.nit: one liner
Quoted 2 lines
Remove it and set mailbox vector index directly.
Quoted 8 lines
Quoted 4 lines
Reviewed-by Aleksandr Loktionov <[email protected]>Reviewed-by Michal Kubiak <[email protected]>Reviewed-by Pavan Kumar Linga <[email protected]>Signed-off-by Michal Swiatkowski <[email protected]>The above notwithstanding, this looks good to me.
Reviewed-by Simon Horman <[email protected]>