aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2013-01-17 09:57:06 +0100
committerTakashi Iwai <tiwai@suse.de>2013-01-17 09:57:06 +0100
commit11d6dd6851a7c18b549530834947d5db4bf93749 (patch)
treec284b072af8d59f0a724069a8291fc911c175480
parent77b2b59ed61513fb339d5bdeb8100d2cc7d383f4 (diff)
downloadhda-emu-11d6dd6851a7c18b549530834947d5db4bf93749.tar.gz
Add hweight32() definition in linux/bitops.h
Signed-off-by: Takashi Iwai <tiwai@suse.de>
-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 8e7c974..b2b8b3e 100644
--- a/include/linux/bitops.h
+++ b/include/linux/bitops.h
@@ -13,6 +13,16 @@ static inline unsigned long hweight_long(unsigned long w)
return c;
}
+static inline unsigned int hweight32(unsigned int w)
+{
+ int i, c = 0;
+ for (i = 0; i < sizeof(w) * 8; i++) {
+ c += w & 1;
+ w >>= 1;
+ }
+ return c;
+}
+
static inline unsigned long find_first_bit(const unsigned long *addr,
unsigned long size)
{