aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorMichael Hennerich <michael.hennerich@analog.com>2009-12-22 06:32:06 -0500
committerMike Frysinger <vapier@gentoo.org>2010-03-09 00:30:47 -0500
commit0f7b468b6eace87ecdc59b3ec8476d50b0561ac2 (patch)
tree0353e8ba78a5d05d32f916f1664b9e46d1f1dc46 /arch
parent252077cf7d44f1f261a5fdaedab88057f8379859 (diff)
Blackfin: add optimized version of Hamming Weight functions
Signed-off-by: Michael Hennerich <michael.hennerich@analog.com> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/blackfin/Kconfig3
-rw-r--r--arch/blackfin/include/asm/bitops.h74
2 files changed, 55 insertions, 22 deletions
diff --git a/arch/blackfin/Kconfig b/arch/blackfin/Kconfig
index 3bd8e833c89..b483639c80b 100644
--- a/arch/blackfin/Kconfig
+++ b/arch/blackfin/Kconfig
@@ -45,9 +45,6 @@ config ZONE_DMA
45config GENERIC_FIND_NEXT_BIT 45config GENERIC_FIND_NEXT_BIT
46 def_bool y 46 def_bool y
47 47
48config GENERIC_HWEIGHT
49 def_bool y
50
51config GENERIC_HARDIRQS 48config GENERIC_HARDIRQS
52 def_bool y 49 def_bool y
53 50
diff --git a/arch/blackfin/include/asm/bitops.h b/arch/blackfin/include/asm/bitops.h
index a2ff3fb3568..605ba8e9b2e 100644
--- a/arch/blackfin/include/asm/bitops.h
+++ b/arch/blackfin/include/asm/bitops.h
@@ -7,22 +7,41 @@
7#ifndef _BLACKFIN_BITOPS_H 7#ifndef _BLACKFIN_BITOPS_H
8#define _BLACKFIN_BITOPS_H 8#define _BLACKFIN_BITOPS_H
9 9
10#ifndef CONFIG_SMP 10#include <linux/compiler.h>
11# include <asm-generic/bitops.h> 11
12#else 12#include <asm-generic/bitops/__ffs.h>
13#include <asm-generic/bitops/ffz.h>
14#include <asm-generic/bitops/fls.h>
15#include <asm-generic/bitops/__fls.h>
16#include <asm-generic/bitops/fls64.h>
17#include <asm-generic/bitops/find.h>
13 18
14#ifndef _LINUX_BITOPS_H 19#ifndef _LINUX_BITOPS_H
15#error only <linux/bitops.h> can be included directly 20#error only <linux/bitops.h> can be included directly
16#endif 21#endif
17 22
18#include <linux/compiler.h>
19#include <asm/byteorder.h> /* swab32 */
20
21#include <asm-generic/bitops/ffs.h>
22#include <asm-generic/bitops/__ffs.h>
23#include <asm-generic/bitops/sched.h> 23#include <asm-generic/bitops/sched.h>
24#include <asm-generic/bitops/ffz.h> 24#include <asm-generic/bitops/ffs.h>
25#include <asm-generic/bitops/lock.h>
26#include <asm-generic/bitops/ext2-non-atomic.h>
27#include <asm-generic/bitops/ext2-atomic.h>
28#include <asm-generic/bitops/minix.h>
29
30#ifndef CONFIG_SMP
31#include <linux/irqflags.h>
32
33/*
34 * clear_bit may not imply a memory barrier
35 */
36#ifndef smp_mb__before_clear_bit
37#define smp_mb__before_clear_bit() smp_mb()
38#define smp_mb__after_clear_bit() smp_mb()
39#endif
40#include <asm-generic/bitops/atomic.h>
41#include <asm-generic/bitops/non-atomic.h>
42#else
25 43
44#include <asm/byteorder.h> /* swab32 */
26#include <linux/linkage.h> 45#include <linux/linkage.h>
27 46
28asmlinkage int __raw_bit_set_asm(volatile unsigned long *addr, int nr); 47asmlinkage int __raw_bit_set_asm(volatile unsigned long *addr, int nr);
@@ -89,19 +108,36 @@ static inline int test_and_change_bit(int nr, volatile unsigned long *addr)
89 108
90#include <asm-generic/bitops/non-atomic.h> 109#include <asm-generic/bitops/non-atomic.h>
91 110
92#include <asm-generic/bitops/find.h> 111#endif /* CONFIG_SMP */
93#include <asm-generic/bitops/hweight.h>
94#include <asm-generic/bitops/lock.h>
95 112
96#include <asm-generic/bitops/ext2-atomic.h> 113/*
97#include <asm-generic/bitops/ext2-non-atomic.h> 114 * hweightN: returns the hamming weight (i.e. the number
115 * of bits set) of a N-bit word
116 */
98 117
99#include <asm-generic/bitops/minix.h> 118static inline unsigned int hweight32(unsigned int w)
119{
120 unsigned int res;
100 121
101#include <asm-generic/bitops/fls.h> 122 __asm__ ("%0.l = ONES %0;"
102#include <asm-generic/bitops/__fls.h> 123 "%0 = %0.l (Z);"
103#include <asm-generic/bitops/fls64.h> 124 : "=d" (res) : "d" (w));
125 return res;
126}
104 127
105#endif /* CONFIG_SMP */ 128static inline unsigned int hweight64(__u64 w)
129{
130 return hweight32((unsigned int)(w >> 32)) + hweight32((unsigned int)w);
131}
132
133static inline unsigned int hweight16(unsigned int w)
134{
135 return hweight32(w & 0xffff);
136}
137
138static inline unsigned int hweight8(unsigned int w)
139{
140 return hweight32(w & 0xff);
141}
106 142
107#endif /* _BLACKFIN_BITOPS_H */ 143#endif /* _BLACKFIN_BITOPS_H */