Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754142AbcC0Gny (ORCPT ); Sun, 27 Mar 2016 02:43:54 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:33020 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752035AbcC0Gnt (ORCPT ); Sun, 27 Mar 2016 02:43:49 -0400 Subject: [PATCH 10/31] Add sparc-specific parity functions To: "David S. Miller" References: <1458788612-4367-1-git-send-email-zhaoxiu.zeng@gmail.com> Cc: linux-kernel@vger.kernel.org, sparclinux@vger.kernel.org From: "zhaoxiu.zeng" Message-ID: <56F780FE.7000600@gmail.com> Date: Sun, 27 Mar 2016 14:43:10 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.7.1 MIME-Version: 1.0 In-Reply-To: <1458788612-4367-1-git-send-email-zhaoxiu.zeng@gmail.com> Content-Type: text/plain; charset=gbk Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1678 Lines: 46 From: Zeng Zhaoxiu Signed-off-by: Zeng Zhaoxiu --- 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 #include #include +#include #include #include #include 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 + +/* + * 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 #include #endif /* __KERNEL__ */ -- 2.5.5