wifi: carl9170: micro-optimize carl9170_tx_shift_bm()
authorYury Norov <yury.norov@gmail.com>
Wed, 26 Mar 2025 15:51:58 +0000 (11:51 -0400)
committerJeff Johnson <jeff.johnson@oss.qualcomm.com>
Wed, 21 May 2025 01:08:38 +0000 (18:08 -0700)
The function calls bitmap_empty() just before find_first_bit(). Both
functions are O(N). Because find_first_bit() returns >= nbits in case of
empty bitmap, the bitmap_empty() test may be avoided.

Signed-off-by: Yury Norov <yury.norov@gmail.com>
Acked-by: Christian Lamparter <chunkeey@gmail.com>
Link: https://patch.msgid.link/20250326155200.39895-1-yury.norov@gmail.com
Signed-off-by: Jeff Johnson <jeff.johnson@oss.qualcomm.com>
drivers/net/wireless/ath/carl9170/tx.c

index 0226c31a6cae2631ba5c9cf8ce10e179dbef5a0a..b7717f9e1e9b923eaf5265d7be682f688802710a 100644 (file)
@@ -366,8 +366,7 @@ static void carl9170_tx_shift_bm(struct ar9170 *ar,
        if (WARN_ON_ONCE(off >= CARL9170_BAW_BITS))
                return;
 
-       if (!bitmap_empty(tid_info->bitmap, off))
-               off = find_first_bit(tid_info->bitmap, off);
+       off = min(off, find_first_bit(tid_info->bitmap, off));
 
        tid_info->bsn += off;
        tid_info->bsn &= 0x0fff;