From: Yury Norov Date: Tue, 9 Jun 2026 17:15:44 +0000 (-0400) Subject: net: hsr: simplify fill_last_seq_nrs() X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8058d9755ecf1d35bdd08df1bdb58d21ba69b9ed;p=thirdparty%2Flinux.git 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 Signed-off-by: Yury Norov Reviewed-by: Felix Maurer Link: https://patch.msgid.link/20260609171545.1051322-1-ynorov@nvidia.com Signed-off-by: Jakub Kicinski --- diff --git a/net/hsr/hsr_framereg.c b/net/hsr/hsr_framereg.c index a28dfd8490c5..e44929871274 100644 --- a/net/hsr/hsr_framereg.c +++ b/net/hsr/hsr_framereg.c @@ -825,18 +825,16 @@ 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); }