bitops: use the same mechanism for get_count_order[_long]

These two functions share the same logic.

Signed-off-by: Wei Yang <richard.weiyang@linux.alibaba.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Christian Brauner <christian.brauner@ubuntu.com>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lkml.kernel.org/r/20200807085837.11697-3-richard.weiyang@linux.alibaba.com
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Wei Yang 2020-10-15 20:11:46 -07:00 committed by Linus Torvalds
parent a9eb63705e
commit 004fba1ae6
1 changed files with 3 additions and 5 deletions

View File

@ -188,12 +188,10 @@ static inline unsigned fls_long(unsigned long l)
static inline int get_count_order(unsigned int count)
{
int order;
if (count == 0)
return -1;
order = fls(count) - 1;
if (count & (count - 1))
order++;
return order;
return fls(--count);
}
/**