Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753529AbcC0FyQ (ORCPT ); Sun, 27 Mar 2016 01:54:16 -0400 Received: from mail-pa0-f65.google.com ([209.85.220.65]:36590 "EHLO mail-pa0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751451AbcC0FyH (ORCPT ); Sun, 27 Mar 2016 01:54:07 -0400 Subject: [PATCH 05/31] Add blackfin-specific parity functions References: <1458788612-4367-1-git-send-email-zhaoxiu.zeng@gmail.com> Cc: linux-kernel@vger.kernel.org, adi-buildroot-devel@lists.sourceforge.net To: Steven Miao , Zeng Zhaoxiu From: "zhaoxiu.zeng" Message-ID: <56F77567.3020302@gmail.com> Date: Sun, 27 Mar 2016 13:53:43 +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: 1495 Lines: 56 From: Zeng Zhaoxiu Signed-off-by: Zeng Zhaoxiu --- arch/blackfin/include/asm/bitops.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/arch/blackfin/include/asm/bitops.h b/arch/blackfin/include/asm/bitops.h index b298b65..81b078a 100644 --- a/arch/blackfin/include/asm/bitops.h +++ b/arch/blackfin/include/asm/bitops.h @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -137,4 +138,34 @@ static inline unsigned int __arch_hweight8(unsigned int w) return __arch_hweight32(w & 0xff); } +/* + * parityN: returns the parity of a N-bit word, + * i.e. the number of 1-bits in x modulo 2. + */ + +static inline unsigned int __arch_parity32(unsigned int w) +{ + return __arch_hweight32(w) & 1; +} + +static inline unsigned int __arch_parity64(__u64 w) +{ + return __arch_parity32((unsigned int)(w >> 32) ^ (unsigned int)w); +} + +static inline unsigned int __arch_parity16(unsigned int w) +{ + return __arch_parity32(w & 0xffff); +} + +static inline unsigned int __arch_parity8(unsigned int w) +{ + return __arch_parity32(w & 0xff); +} + +static inline unsigned int __arch_parity4(unsigned int w) +{ + return __arch_parity32(w & 0xf); +} + #endif /* _BLACKFIN_BITOPS_H */ -- 2.5.5