aboutsummaryrefslogtreecommitdiffstats
path: root/lib/hweight.c
diff options
context:
space:
mode:
authorDavid Woodhouse <David.Woodhouse@intel.com>2010-03-26 14:55:59 +0000
committerDavid Woodhouse <David.Woodhouse@intel.com>2010-03-26 14:55:59 +0000
commit329f9052dbadf6f4afe2231668bd00c579a4aa10 (patch)
treee080a5c70df40f3ae8cf28a95a3267757668ab97 /lib/hweight.c
parent395b228858778d3c44f7c413693a6acaa8bb62dc (diff)
parent220bf991b0366cc50a94feede3d7341fa5710ee4 (diff)
downloadkernel_samsung_smdk4412-329f9052dbadf6f4afe2231668bd00c579a4aa10.zip
kernel_samsung_smdk4412-329f9052dbadf6f4afe2231668bd00c579a4aa10.tar.gz
kernel_samsung_smdk4412-329f9052dbadf6f4afe2231668bd00c579a4aa10.tar.bz2
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
Conflicts: drivers/mtd/nand/sh_flctl.c Maxim's patch to initialise sysfs attributes depends on the patch which actually adds sysfs_attr_init().
Diffstat (limited to 'lib/hweight.c')
-rw-r--r--lib/hweight.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/hweight.c b/lib/hweight.c
index 389424e..63ee4eb 100644
--- a/lib/hweight.c
+++ b/lib/hweight.c
@@ -11,11 +11,18 @@
unsigned int hweight32(unsigned int w)
{
+#ifdef ARCH_HAS_FAST_MULTIPLIER
+ w -= (w >> 1) & 0x55555555;
+ w = (w & 0x33333333) + ((w >> 2) & 0x33333333);
+ w = (w + (w >> 4)) & 0x0f0f0f0f;
+ return (w * 0x01010101) >> 24;
+#else
unsigned int res = w - ((w >> 1) & 0x55555555);
res = (res & 0x33333333) + ((res >> 2) & 0x33333333);
res = (res + (res >> 4)) & 0x0F0F0F0F;
res = res + (res >> 8);
return (res + (res >> 16)) & 0x000000FF;
+#endif
}
EXPORT_SYMBOL(hweight32);