trivial cleanup for get_count_order[_long]
cover trivial cleanup for get_count_order[_long]
The following two patches cleanup get_count_order[_long] a little.
The lib/test_bitops pass with these two patches.
Wei Yang (2):
bitops: simplify get_count_order_long()
bitops: use the same mechanism for get_count_order[_long]
include/linux/bitops.h | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)
Signature · 1 line
2.20.1 (Apple Git-117)
PATCH RESEND 1/2 bitops: simplify get_count_order_long()
These two cases could be unified into one.
Signed-off-by Wei Yang <[email protected]>
--- include/linux/bitops.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
include/linux/bitops.h +1 -4
@@ -206,10 +206,7 @@ static inline int get_count_order_long(unsigned long l) {if (l ==0UL )return -1 ; -else if (l & (l -1UL )) -return (int )fls_long (l); -else -return (int )fls_long (l) -1 ; +return (int )fls_long (--l); }/**
Signature · 1 line
2.20.1 (Apple Git-117)
PATCH RESEND 2/2 bitops: use the same mechanism for get_count_order[_long]
In reply to Wei YangThese two functions share the same logic.
Signed-off-by Wei Yang <[email protected]>
--- include/linux/bitops.h | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
include/linux/bitops.h +3 -5
@@ -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); }/**
Signature · 1 line
2.20.1 (Apple Git-117)