[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <56F780FE.7000600@gmail.com>
Date: Sun, 27 Mar 2016 14:43:10 +0800
From: "zhaoxiu.zeng" <zhaoxiu.zeng@...il.com>
To: "David S. Miller" <davem@...emloft.net>
Cc: linux-kernel@...r.kernel.org, sparclinux@...r.kernel.org
Subject: [PATCH 10/31] Add sparc-specific parity functions
From: Zeng Zhaoxiu <zhaoxiu.zeng@...il.com>
Signed-off-by: Zeng Zhaoxiu <zhaoxiu.zeng@...il.com>
---
arch/sparc/include/asm/bitops_32.h | 1 +
arch/sparc/include/asm/bitops_64.h | 13 +++++++++++++
2 files changed, 14 insertions(+)
diff --git a/arch/sparc/include/asm/bitops_32.h b/arch/sparc/include/asm/bitops_32.h
index 600ed1d..8c41896 100644
--- a/arch/sparc/include/asm/bitops_32.h
+++ b/arch/sparc/include/asm/bitops_32.h
@@ -98,6 +98,7 @@ static inline void change_bit(unsigned long nr, volatile unsigned long *addr)
#include <asm-generic/bitops/__fls.h>
#include <asm-generic/bitops/fls64.h>
#include <asm-generic/bitops/hweight.h>
+#include <asm-generic/bitops/parity.h>
#include <asm-generic/bitops/lock.h>
#include <asm-generic/bitops/find.h>
#include <asm-generic/bitops/le.h>
diff --git a/arch/sparc/include/asm/bitops_64.h b/arch/sparc/include/asm/bitops_64.h
index 2d52240..4d3dcb3 100644
--- a/arch/sparc/include/asm/bitops_64.h
+++ b/arch/sparc/include/asm/bitops_64.h
@@ -47,6 +47,19 @@ unsigned int __arch_hweight16(unsigned int w);
unsigned int __arch_hweight8(unsigned int w);
#include <asm-generic/bitops/const_hweight.h>
+
+/*
+ * parityN: returns the parity of a N-bit word,
+ * i.e. the number of 1-bits in x modulo 2.
+ */
+
+#define __arch_parity4(w) (__arch_hweight8((w) & 0xf) & 1)
+#define __arch_parity8(w) (__arch_hweight8(w) & 1)
+#define __arch_parity16(w) (__arch_hweight16(w) & 1)
+#define __arch_parity32(w) (__arch_hweight32(w) & 1)
+#define __arch_parity64(w) ((unsigned int)__arch_hweight64(w) & 1)
+
+#include <asm-generic/bitops/const_hweight.h>
#include <asm-generic/bitops/lock.h>
#endif /* __KERNEL__ */
--
2.5.5
Powered by blists - more mailing lists