net: hsr: simplify fill_last_seq_nrs()
Subsystems (3)
PATCH 1/1 net: hsr: simplify fill_last_seq_nrs()
The function checks the HSR_PT_SLAVE_A and HSR_PT_SLAVE_B bitmaps for emptiness right before calling find_last_bit().
This pass may be avoided, because if the bitmap is empty, the find_last_bit() returns >= HSR_SEQ_BLOCK_SIZE
--- net/hsr/hsr_framereg.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-)
net/hsr/hsr_framereg.c +6 -10
@@ -827,18 +827,14 @@ static void fill_last_seq_nrs(struct hsr_node *node, u16 *if1_seq, u16 *if2_seq) block_sz =hsr_seq_block_size (node); block = node->block_buf + block_off * block_sz; -if (!bitmap_empty (block->seq_nrs[HSR_PT_SLAVE_B -1 ], -HSR_SEQ_BLOCK_SIZE )) { - seq_bit =find_last_bit (block->seq_nrs[HSR_PT_SLAVE_B -1 ], -HSR_SEQ_BLOCK_SIZE ); + seq_bit =find_last_bit (block->seq_nrs[HSR_PT_SLAVE_B -1 ],HSR_SEQ_BLOCK_SIZE ); +if (seq_bit <HSR_SEQ_BLOCK_SIZE ) *if1_seq = (block->block_idx <<HSR_SEQ_BLOCK_SHIFT ) | seq_bit; - } -if (!bitmap_empty (block->seq_nrs[HSR_PT_SLAVE_A -1 ], -HSR_SEQ_BLOCK_SIZE )) { - seq_bit =find_last_bit (block->seq_nrs[HSR_PT_SLAVE_A -1 ], -HSR_SEQ_BLOCK_SIZE ); + + seq_bit =find_last_bit (block->seq_nrs[HSR_PT_SLAVE_A -1 ],HSR_SEQ_BLOCK_SIZE ); +if (seq_bit <HSR_SEQ_BLOCK_SIZE ) *if2_seq = (block->block_idx <<HSR_SEQ_BLOCK_SHIFT ) | seq_bit; - } +spin_unlock_bh (&node->seq_out_lock); }
Signature · 1 line
2.53.0
Quoted 7 lines · Yury Norov
The function checks the
HSR_PT_SLAVE_AandHSR_PT_SLAVE_Bbitmaps for emptiness right before callingfind_last_bit().This pass may be avoided, because if the bitmap is empty, the
find_last_bit()returns >=HSR_SEQ_BLOCK_SIZESigned-off-by Yury Norov <[email protected]>
Looks good to me, thank you!
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 9 lines · On Tue, 9 Jun 2026 13:15:44 -0400 you wrote:
The function checks the
HSR_PT_SLAVE_AandHSR_PT_SLAVE_Bbitmaps for emptiness right before callingfind_last_bit().This pass may be avoided, because if the bitmap is empty, the
find_last_bit()returns >=HSR_SEQ_BLOCK_SIZESigned-off-by Yury Norov <[email protected]>[...]
Here is the summary with links:
- net: hsr: simplify fill_last_seq_nrs()
https://git.kernel.org/netdev/net-next/c/8058d9755ecf
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html