summaryrefslogtreecommitdiff
path: root/arch/m68k/include/asm
diff options
context:
space:
mode:
authorAlison Wang <b18965@freescale.com>2012-03-25 19:18:49 +0000
committerjason <jason@jason-ThinkPad-T61.(none)>2012-09-20 20:37:40 +0800
commitf7799a1175d1538ddaabc49fbd30660a926bb32f (patch)
treee89a7218190a823cd5ff7b4059f96f987362ff42 /arch/m68k/include/asm
parent2ee03c6e23237a29729b27457f69b22b2d7d4fe1 (diff)
downloadu-boot-imx-f7799a1175d1538ddaabc49fbd30660a926bb32f.zip
u-boot-imx-f7799a1175d1538ddaabc49fbd30660a926bb32f.tar.gz
u-boot-imx-f7799a1175d1538ddaabc49fbd30660a926bb32f.tar.bz2
ColdFire: Update the bitops for ColdFire platform
This patch uses the general ffs definition to replace the platform ffs definition. This patch also fixes the build error by adding hweightN definition for m5329evb and m5373evb. Signed-off-by: Jason Jin <Jason.jin@freescale.com> Signed-off-by: Alison Wang <b18965@freescale.com>
Diffstat (limited to 'arch/m68k/include/asm')
-rw-r--r--arch/m68k/include/asm/bitops.h59
1 files changed, 27 insertions, 32 deletions
diff --git a/arch/m68k/include/asm/bitops.h b/arch/m68k/include/asm/bitops.h
index ad971b4..525d90c 100644
--- a/arch/m68k/include/asm/bitops.h
+++ b/arch/m68k/include/asm/bitops.h
@@ -17,41 +17,36 @@ extern int test_and_change_bit(int nr, volatile void *addr);
#ifdef __KERNEL__
-/*
- * ffs: find first bit set. This is defined the same way as
- * the libc and compiler builtin ffs routines, therefore
- * differs in spirit from the above ffz (man ffs).
- */
-extern __inline__ int ffs(int x)
+
+extern inline int test_bit(int nr, __const__ volatile void *addr)
{
- int r = 1;
-
- if (!x)
- return 0;
- if (!(x & 0xffff)) {
- x >>= 16;
- r += 16;
- }
- if (!(x & 0xff)) {
- x >>= 8;
- r += 8;
- }
- if (!(x & 0xf)) {
- x >>= 4;
- r += 4;
- }
- if (!(x & 3)) {
- x >>= 2;
- r += 2;
- }
- if (!(x & 1)) {
- x >>= 1;
- r += 1;
- }
- return r;
+ __const__ unsigned int *p = (__const__ unsigned int *) addr;
+
+ return (p[nr >> 5] & (1UL << (nr & 31))) != 0;
}
+
+extern inline int test_and_set_bit(int nr, volatile void *vaddr)
+{
+ char retval;
+
+ volatile char *p = &((volatile char *)vaddr)[(nr^31) >> 3];
+ __asm__ __volatile__ ("bset %2,(%4); sne %0"
+ : "=d" (retval), "=m" (*p)
+ : "di" (nr & 7), "m" (*p), "a" (p));
+
+ return retval;
+}
+
#define __ffs(x) (ffs(x) - 1)
-#define PLATFORM_FFS
+
+/*
+ * * hweightN: returns the hamming weight (i.e. the number
+ * * of bits set) of a N-bit word
+ * */
+
+#define hweight32(x) generic_hweight32(x)
+#define hweight16(x) generic_hweight16(x)
+#define hweight8(x) generic_hweight8(x)
#endif /* __KERNEL__ */