]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
net: hsr: simplify fill_last_seq_nrs()
authorYury Norov <yury.norov@gmail.com>
Tue, 9 Jun 2026 17:15:44 +0000 (13:15 -0400)
committerJakub Kicinski <kuba@kernel.org>
Fri, 12 Jun 2026 23:20:28 +0000 (16:20 -0700)
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 <ynorov@nvidia.com>
Reviewed-by: Felix Maurer <fmaurer@redhat.com>
Link: https://patch.msgid.link/20260609171545.1051322-1-ynorov@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/hsr/hsr_framereg.c

index a28dfd8490c5b35083808e26daff5f54414451d0..e44929871274452996041402e37c8ee97c8980ac 100644 (file)
@@ -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);
 }