From: Wei Yang Date: Fri, 16 Oct 2020 03:11:41 +0000 (-0700) Subject: bitops: simplify get_count_order_long() X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=a9eb63705e379f10a3c9d13fc6aee8b50805e862;p=linux.git bitops: simplify get_count_order_long() These two cases could be unified into one. Signed-off-by: Wei Yang Signed-off-by: Andrew Morton Cc: Christian Brauner Cc: Andy Shevchenko Link: https://lkml.kernel.org/r/20200807085837.11697-2-richard.weiyang@linux.alibaba.com Signed-off-by: Linus Torvalds --- diff --git a/include/linux/bitops.h b/include/linux/bitops.h index 99f2ac30b1d9b..030a98f0c4528 100644 --- a/include/linux/bitops.h +++ b/include/linux/bitops.h @@ -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); } /**