Re: [PATCH v3 3/8] bitmap: fix opencoded bitmap_allocate_region()
From: Andy Shevchenko
Date: Thu Aug 17 2023 - 05:46:23 EST
On Tue, Aug 15, 2023 at 04:36:23PM -0700, Yury Norov wrote:
> bitmap_find_region() opencodes bitmap_allocate_region(). Fix it.
...
> for (pos = 0; (end = pos + BIT(order)) <= bits; pos = end) {
> - if (!__reg_op(bitmap, pos, order, REG_OP_ISFREE))
> - continue;
> - __reg_op(bitmap, pos, order, REG_OP_ALLOC);
> - return pos;
> + if (!bitmap_allocate_region(bitmap, pos, order))
> + return pos;
You can also leave more code untouched, by replacing only first conditional
with
if (bitmap_allocate_region(bitmap, pos, order))
continue;
return pos;
> }
> return -ENOMEM;
--
With Best Regards,
Andy Shevchenko