Skip to content
Snippets Groups Projects
Commit 004fba1a authored by Wei Yang's avatar Wei Yang Committed by Linus Torvalds
Browse files

bitops: use the same mechanism for get_count_order[_long]


These two functions share the same logic.

Signed-off-by: default avatarWei Yang <richard.weiyang@linux.alibaba.com>
Signed-off-by: default avatarAndrew 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: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent a9eb6370
No related branches found
No related tags found
No related merge requests found
......@@ -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);
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment