From: David Daney <ddaney.cavm@gmail.com>
To: "zhaoxiu.zeng" <zhaoxiu.zeng@gmail.com>
Cc: Ralf Baechle <ralf@linux-mips.org>,
Leonid Yegoshin <Leonid.Yegoshin@imgtec.com>,
"Maciej W. Rozycki" <macro@linux-mips.org>,
linux-kernel@vger.kernel.org, linux-mips@linux-mips.org
Subject: Re: [PATCH 07/31] Add mips-specific parity functions
Date: Mon, 28 Mar 2016 10:25:02 -0700 [thread overview]
Message-ID: <56F968EE.1000307@gmail.com> (raw)
In-Reply-To: <56F7785F.1090101@gmail.com>
On 03/26/2016 11:06 PM, zhaoxiu.zeng wrote:
> From: Zeng Zhaoxiu <zhaoxiu.zeng@gmail.com>
>
There is nothing MIPS specific here. Why not put it in asm-generic or
some similar place where it can be shared by all architectures?
Also, are you sure __builtin_popcount() is available on all GCC versions
that are supported for building the kernel?
David Daney
> Signed-off-by: Zeng Zhaoxiu <zhaoxiu.zeng@gmail.com>
> ---
> arch/mips/include/asm/arch_parity.h | 44 +++++++++++++++++++++++++++++++++++++
> arch/mips/include/asm/bitops.h | 3 +++
> 2 files changed, 47 insertions(+)
> create mode 100644 arch/mips/include/asm/arch_parity.h
>
> diff --git a/arch/mips/include/asm/arch_parity.h b/arch/mips/include/asm/arch_parity.h
> new file mode 100644
> index 0000000..23b3c23
> --- /dev/null
> +++ b/arch/mips/include/asm/arch_parity.h
> @@ -0,0 +1,44 @@
> +/*
> + * This file is subject to the terms and conditions of the GNU General Public
> + * License. See the file "COPYING" in the main directory of this archive
> + * for more details.
> + *
> + */
> +#ifndef _ASM_ARCH_PARITY_H
> +#define _ASM_ARCH_PARITY_H
> +
> +#ifdef ARCH_HAS_USABLE_BUILTIN_POPCOUNT
> +
> +#include <asm/types.h>
> +
> +static inline unsigned int __arch_parity32(unsigned int w)
> +{
> + return __builtin_popcount(w) & 1;
> +}
> +
> +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);
> +}
> +
> +static inline unsigned int __arch_parity64(__u64 w)
> +{
> + return (unsigned int)__builtin_popcountll(w) & 1;
> +}
> +
> +#else
> +#include <asm-generic/bitops/arch_hweight.h>
> +#include <asm-generic/bitops/arch_parity.h>
> +#endif
> +
> +#endif /* _ASM_ARCH_PARITY_H */
> diff --git a/arch/mips/include/asm/bitops.h b/arch/mips/include/asm/bitops.h
> index ce9666c..0b87734 100644
> --- a/arch/mips/include/asm/bitops.h
> +++ b/arch/mips/include/asm/bitops.h
> @@ -626,6 +626,9 @@ static inline int ffs(int word)
> #include <asm/arch_hweight.h>
> #include <asm-generic/bitops/const_hweight.h>
>
> +#include <asm/arch_parity.h>
> +#include <asm-generic/bitops/const_parity.h>
> +
> #include <asm-generic/bitops/le.h>
> #include <asm-generic/bitops/ext2-atomic.h>
>
>
next prev parent reply other threads:[~2016-03-28 17:25 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1458788612-4367-1-git-send-email-zhaoxiu.zeng@gmail.com>
2016-03-27 6:06 ` [PATCH 07/31] Add mips-specific parity functions zhaoxiu.zeng
2016-03-28 17:25 ` David Daney [this message]
2016-03-29 2:15 ` Zeng Zhaoxiu
2016-03-27 6:55 ` [PATCH 13/31] mips: use parity functions in cerr-sb1.c zhaoxiu.zeng
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=56F968EE.1000307@gmail.com \
--to=ddaney.cavm@gmail.com \
--cc=Leonid.Yegoshin@imgtec.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@linux-mips.org \
--cc=macro@linux-mips.org \
--cc=ralf@linux-mips.org \
--cc=zhaoxiu.zeng@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox