]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
bitmap: replace _reg_op(REG_OP_ISFREE) with find_next_bit()
authorYury Norov <yury.norov@gmail.com>
Mon, 25 Sep 2023 02:38:15 +0000 (19:38 -0700)
committerYury Norov <yury.norov@gmail.com>
Sun, 15 Oct 2023 03:25:22 +0000 (20:25 -0700)
_reg_op(REG_OP_ISFREE) can be trivially replaced with find_next_bit().
Doing that opens room for potential small_const_nbits() optimization.

CC: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
CC: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: Yury Norov <yury.norov@gmail.com>
lib/bitmap.c

index babed4dcb4679627778e6a0b1c09f9167b842788..e4d761a69fe83802f04165d2aca9820651f2271e 100644 (file)
@@ -840,7 +840,7 @@ int bitmap_allocate_region(unsigned long *bitmap, unsigned int pos, int order)
 {
        unsigned int len = BIT(order);
 
-       if (!__reg_op(bitmap, pos, order, REG_OP_ISFREE))
+       if (find_next_bit(bitmap, pos + len, pos) < pos + len)
                return -EBUSY;
        bitmap_set(bitmap, pos, len);
        return 0;