Skip to content

Commit

Permalink
bitops: use the same mechanism for get_count_order[_long]
Browse files Browse the repository at this point in the history
These two functions share the same logic.

Signed-off-by: Wei Yang <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Cc: Christian Brauner <[email protected]>
Cc: Andy Shevchenko <[email protected]>
Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
weiyang-linux authored and torvalds committed Oct 16, 2020
1 parent a9eb637 commit 004fba1
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions include/linux/bitops.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down

0 comments on commit 004fba1

Please sign in to comment.