summaryrefslogtreecommitdiff
path: root/include/linux/bitops.h
diff options
context:
space:
mode:
authorJeff Garzik <jgarzik@pobox.com>2005-11-18 19:42:40 +0300
committerJeff Garzik <jgarzik@pobox.com>2005-11-18 19:42:40 +0300
commit85a07029aaba8f5b27241bcff56cc009c9f4993b (patch)
treec579554c2ea9c942ccbea60e223bc62d8262f652 /include/linux/bitops.h
parent0da36b3467040908d3df6bc1f5b4d592a8b23b63 (diff)
parent79bfb0a98fdc73ed6a18469cef245cbf50a1d8bb (diff)
downloadlinux-85a07029aaba8f5b27241bcff56cc009c9f4993b.tar.xz
Merge branch 'upstream'
Diffstat (limited to 'include/linux/bitops.h')
-rw-r--r--include/linux/bitops.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/include/linux/bitops.h b/include/linux/bitops.h
index cb3c3ef50f50..38c2fb7ebe09 100644
--- a/include/linux/bitops.h
+++ b/include/linux/bitops.h
@@ -84,6 +84,16 @@ static __inline__ int get_bitmask_order(unsigned int count)
return order; /* We could be slightly more clever with -1 here... */
}
+static __inline__ int get_count_order(unsigned int count)
+{
+ int order;
+
+ order = fls(count) - 1;
+ if (count & (count - 1))
+ order++;
+ return order;
+}
+
/*
* hweightN: returns the hamming weight (i.e. the number
* of bits set) of a N-bit word