All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] bitops: use the same mechanism for get_count_order[_long]
@ 2020-05-25 21:59 Wei Yang
  2020-05-26  7:04 ` Andy Shevchenko
  2020-05-30 21:22 ` Wei Yang
  0 siblings, 2 replies; 4+ messages in thread
From: Wei Yang @ 2020-05-25 21:59 UTC (permalink / raw)
  To: akpm, andriy.shevchenko, christian.brauner; +Cc: linux-kernel, Wei Yang

These two functions share the same logic.

Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
---
 include/linux/bitops.h | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/include/linux/bitops.h b/include/linux/bitops.h
index 5b5609e81a84..80703ef27aee 100644
--- a/include/linux/bitops.h
+++ b/include/linux/bitops.h
@@ -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);
 }
 
 /**
-- 
2.23.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-05-30 21:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-25 21:59 [PATCH] bitops: use the same mechanism for get_count_order[_long] Wei Yang
2020-05-26  7:04 ` Andy Shevchenko
2020-05-26 21:57   ` Wei Yang
2020-05-30 21:22 ` Wei Yang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.