On Wed, Jan 20, 2021 at 04:06:30PM -0800, Yury Norov wrote:
Similarly to bitmap functions, users will benefit if we'll handle a case of small-size bitmaps that fit into a single word. While here, move the find_last_bit() declaration to bitops/find.h where other find_*_bit() functions sit.
...
+static inline +unsigned long find_first_bit(const unsigned long *addr, unsigned long size) +{ + if (small_const_nbits(size)) { + unsigned long idx; + + if (!*addr) + return size; + + idx = __ffs(*addr);
+ return idx < size ? idx : size;
But can't we mask it first, then check for 0 (no bit set) otherwise return the result of __ffs directly? Same comment for other similar places.
+ } + + return _find_first_bit(addr, size); +}
-- With Best Regards, Andy Shevchenko