Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1363884 > unrolled thread
| Started by | Zhaoxiu Zeng <zhaoxiu.zeng@gmail.com> |
|---|---|
| First post | 2016-03-24 04:10 +0100 |
| Last post | 2016-03-27 10:00 +0200 |
| Articles | 20 on this page of 58 — 17 participants |
Back to article view | Back to linux.kernel
[PATCH 01/31] bitops: add parity functions Zhaoxiu Zeng <zhaoxiu.zeng@gmail.com> - 2016-03-24 04:10 +0100
Re: [PATCH 01/31] bitops: add parity functions Denys Vlasenko <dvlasenk@redhat.com> - 2016-03-24 09:40 +0100
Re: [PATCH 01/31] bitops: add parity functions Andrew Morton <akpm@linux-foundation.org> - 2016-03-24 23:30 +0100
Re: [PATCH 01/31] bitops: add parity functions Martin Kepplinger <martink@posteo.de> - 2016-03-26 23:10 +0100
Re: [PATCH 01/31] bitops: add parity functions "zhaoxiu.zeng" <zhaoxiu.zeng@gmail.com> - 2016-03-27 10:00 +0200
Re: [PATCH 01/31] bitops: add parity functions "zhaoxiu.zeng" <zhaoxiu.zeng@gmail.com> - 2016-03-27 05:40 +0200
Re: [PATCH 01/31] bitops: add parity functions Sam Ravnborg <sam@ravnborg.org> - 2016-03-27 14:50 +0200
Re: [PATCH 01/31] bitops: add parity functions "zhaoxiu.zeng" <zhaoxiu.zeng@gmail.com> - 2016-03-27 15:40 +0200
Re: [PATCH 01/31] bitops: add parity functions Sam Ravnborg <sam@ravnborg.org> - 2016-03-27 20:00 +0200
Re: [PATCH 01/31] bitops: add parity functions Zeng Zhaoxiu <zhaoxiu.zeng@gmail.com> - 2016-03-28 04:50 +0200
Re: [PATCH 01/31] bitops: add parity functions Zeng Zhaoxiu <zhaoxiu.zeng@gmail.com> - 2016-03-28 04:20 +0200
Re: [PATCH 01/31] bitops: add parity functions Sam Ravnborg <sam@ravnborg.org> - 2016-03-28 09:00 +0200
Re: [PATCH 01/31] bitops: add parity functions Zeng Zhaoxiu <zhaoxiu.zeng@gmail.com> - 2016-03-29 04:30 +0200
Re: [PATCH 01/31] bitops: add parity functions Joe Perches <joe@perches.com> - 2016-03-29 05:00 +0200
[PATCH 02/31] Include generic parity.h in some architectures' bitops.h "zhaoxiu.zeng" <zhaoxiu.zeng@gmail.com> - 2016-03-27 06:10 +0200
[PATCH 03/31] Add alpha-specific parity functions "zhaoxiu.zeng" <zhaoxiu.zeng@gmail.com> - 2016-03-27 07:50 +0200
Re: [PATCH 03/31] Add alpha-specific parity functions Richard Henderson <rth@twiddle.net> - 2016-03-28 20:40 +0200
[PATCH 04/31] Add avr32-specific parity functions "zhaoxiu.zeng" <zhaoxiu.zeng@gmail.com> - 2016-03-27 07:50 +0200
Re: [PATCH 04/31] Add avr32-specific parity functions Hans-Christian Noren Egtvedt <egtvedt@samfundet.no> - 2016-03-28 22:10 +0200
[PATCH 05/31] Add blackfin-specific parity functions "zhaoxiu.zeng" <zhaoxiu.zeng@gmail.com> - 2016-03-27 08:00 +0200
[PATCH 07/31] Add mips-specific parity functions "zhaoxiu.zeng" <zhaoxiu.zeng@gmail.com> - 2016-03-27 08:10 +0200
Re: [PATCH 07/31] Add mips-specific parity functions David Daney <ddaney.cavm@gmail.com> - 2016-03-28 19:30 +0200
Re: [PATCH 07/31] Add mips-specific parity functions Zeng Zhaoxiu <zhaoxiu.zeng@gmail.com> - 2016-03-29 04:20 +0200
[PATCH 06/31] Add ia64-specific parity functions "zhaoxiu.zeng" <zhaoxiu.zeng@gmail.com> - 2016-03-27 08:10 +0200
[PATCH 08/31] Add tile-specific parity functions "zhaoxiu.zeng" <zhaoxiu.zeng@gmail.com> - 2016-03-27 08:20 +0200
[PATCH 09/31] Add powerpc-specific parity functions "zhaoxiu.zeng" <zhaoxiu.zeng@gmail.com> - 2016-03-27 08:40 +0200
[PATCH 11/31] Add x86-specific parity functions "zhaoxiu.zeng" <zhaoxiu.zeng@gmail.com> - 2016-03-27 08:50 +0200
Re: [PATCH 11/31] Add x86-specific parity functions One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk> - 2016-03-29 14:20 +0200
[PATCH 10/31] Add sparc-specific parity functions "zhaoxiu.zeng" <zhaoxiu.zeng@gmail.com> - 2016-03-27 08:50 +0200
Re: [PATCH 10/31] Add sparc-specific parity functions David Miller <davem@davemloft.net> - 2016-03-28 04:50 +0200
Re: [PATCH 10/31] Add sparc-specific parity functions Zeng Zhaoxiu <zhaoxiu.zeng@gmail.com> - 2016-03-28 07:50 +0200
Re: [PATCH 10/31] Add sparc-specific parity functions David Miller <davem@davemloft.net> - 2016-03-28 17:30 +0200
Re: [PATCH 10/31] Add sparc-specific parity functions Sam Ravnborg <sam@ravnborg.org> - 2016-03-28 17:40 +0200
Re: [PATCH 10/31] Add sparc-specific parity functions David Miller <davem@davemloft.net> - 2016-03-28 17:50 +0200
[PATCH 12/31] sunrpc: auth_gss: use parity8 "zhaoxiu.zeng" <zhaoxiu.zeng@gmail.com> - 2016-03-27 09:00 +0200
[PATCH 13/31] mips: use parity functions in cerr-sb1.c "zhaoxiu.zeng" <zhaoxiu.zeng@gmail.com> - 2016-03-27 09:00 +0200
[PATCH 15/31] media: use parity8 in vivid-vbi-gen.c "zhaoxiu.zeng" <zhaoxiu.zeng@gmail.com> - 2016-03-27 09:10 +0200
[PATCH 14/31] lib: bch: use parity32 "zhaoxiu.zeng" <zhaoxiu.zeng@gmail.com> - 2016-03-27 09:10 +0200
[PATCH 17/31] input: joystick: use parity32 in grip_mp.c "zhaoxiu.zeng" <zhaoxiu.zeng@gmail.com> - 2016-03-27 09:20 +0200
[PATCH 18/31] input: joystick: use parity64 in sidewinder.c "zhaoxiu.zeng" <zhaoxiu.zeng@gmail.com> - 2016-03-27 09:20 +0200
[PATCH 16/31] media: saa7115: use parity functions "zhaoxiu.zeng" <zhaoxiu.zeng@gmail.com> - 2016-03-27 09:20 +0200
[PATCH 19/31] input: serio: use parity16 in ams_delta_serio.c "zhaoxiu.zeng" <zhaoxiu.zeng@gmail.com> - 2016-03-27 09:20 +0200
[PATCH 22/31] mtd: use parity functions in inftlcore.c "zhaoxiu.zeng" <zhaoxiu.zeng@gmail.com> - 2016-03-27 09:30 +0200
[PATCH 21/31] mtd: use parity16 in ssfdc.c "zhaoxiu.zeng" <zhaoxiu.zeng@gmail.com> - 2016-03-27 09:30 +0200
Re: [PATCH 21/31] mtd: use parity16 in ssfdc.c Brian Norris <computersforpeace@gmail.com> - 2016-04-02 01:50 +0200
[PATCH 20/31] scsi: use parity32 in isci/phy.c "zhaoxiu.zeng" <zhaoxiu.zeng@gmail.com> - 2016-03-27 09:30 +0200
[PATCH 26/31] input: serio: use parity8 in pcips2.c "zhaoxiu.zeng" <zhaoxiu.zeng@gmail.com> - 2016-03-27 09:40 +0200
[PATCH 25/31] ethernet: use parity8 in sun/niu.c "zhaoxiu.zeng" <zhaoxiu.zeng@gmail.com> - 2016-03-27 09:40 +0200
Re: [PATCH 25/31] ethernet: use parity8 in sun/niu.c Michal Nazarewicz <mina86@mina86.com> - 2016-03-28 16:40 +0200
[PATCH 24/31] mtd: use parity16 in sm_ftl.c "zhaoxiu.zeng" <zhaoxiu.zeng@gmail.com> - 2016-03-27 09:40 +0200
[PATCH 23/31] crypto: qat: use parity functions in qat_hal.c "zhaoxiu.zeng" <zhaoxiu.zeng@gmail.com> - 2016-03-27 09:40 +0200
[PATCH 28/31] iio: gyro: use parity32 in adxrs450.c "zhaoxiu.zeng" <zhaoxiu.zeng@gmail.com> - 2016-03-27 09:50 +0200
Re: [PATCH 28/31] iio: gyro: use parity32 in adxrs450.c Jonathan Cameron <jic23@kernel.org> - 2016-03-28 10:40 +0200
Re: [PATCH 28/31] iio: gyro: use parity32 in adxrs450.c Lars-Peter Clausen <lars@metafoo.de> - 2016-03-28 11:30 +0200
[PATCH 29/31] serial: use parity32 in max3100.c "zhaoxiu.zeng" <zhaoxiu.zeng@gmail.com> - 2016-03-27 09:50 +0200
[PATCH 30/31] input: mouse: use parity8 in elantech "zhaoxiu.zeng" <zhaoxiu.zeng@gmail.com> - 2016-03-27 09:50 +0200
[PATCH 27/31] input: serio: use parity8 in sa1111ps2.c "zhaoxiu.zeng" <zhaoxiu.zeng@gmail.com> - 2016-03-27 09:50 +0200
[PATCH 31/31] ethernet: broadcom: use parity8 in tg3.c "zhaoxiu.zeng" <zhaoxiu.zeng@gmail.com> - 2016-03-27 10:00 +0200
Page 2 of 3 — ← Prev page 1 [2] 3 Next page →
| From | "zhaoxiu.zeng" <zhaoxiu.zeng@gmail.com> |
|---|---|
| Date | 2016-03-27 08:10 +0200 |
| Subject | [PATCH 07/31] Add mips-specific parity functions |
| Message-ID | <rhc3E-45f-3@gated-at.bofh.it> |
| In reply to | #1363884 |
From: Zeng Zhaoxiu <zhaoxiu.zeng@gmail.com>
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>
--
2.5.5
[toc] | [prev] | [next] | [standalone]
| From | David Daney <ddaney.cavm@gmail.com> |
|---|---|
| Date | 2016-03-28 19:30 +0200 |
| Subject | Re: [PATCH 07/31] Add mips-specific parity functions |
| Message-ID | <rhJ9f-1LU-1@gated-at.bofh.it> |
| In reply to | #1365061 |
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>
>
>
[toc] | [prev] | [next] | [standalone]
| From | Zeng Zhaoxiu <zhaoxiu.zeng@gmail.com> |
|---|---|
| Date | 2016-03-29 04:20 +0200 |
| Subject | Re: [PATCH 07/31] Add mips-specific parity functions |
| Message-ID | <rhRq9-7RF-1@gated-at.bofh.it> |
| In reply to | #1365597 |
在 2016年03月29日 01:25, David Daney 写道:
> 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
>
Refrence to arch_hweight.h.
In the 68th line of
arch/mips/include/asm/mach-cavium-octeon/cpu-feature-overrides.h, we can
see:
#ifdef __OCTEON__
/*
* All gcc versions that have OCTEON support define __OCTEON__ and have the
* __builtin_popcount support.
*/
#define ARCH_HAS_USABLE_BUILTIN_POPCOUNT 1
#endif
/*
* All gcc versions that have OCTEON support define __OCTEON__ and have the
* __builtin_popcount support.
*/
>> 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>
>>
>>
>
[toc] | [prev] | [next] | [standalone]
| From | "zhaoxiu.zeng" <zhaoxiu.zeng@gmail.com> |
|---|---|
| Date | 2016-03-27 08:10 +0200 |
| Subject | [PATCH 06/31] Add ia64-specific parity functions |
| Message-ID | <rhc3E-45f-5@gated-at.bofh.it> |
| In reply to | #1363884 |
From: Zeng Zhaoxiu <zhaoxiu.zeng@gmail.com>
Signed-off-by: Zeng Zhaoxiu <zhaoxiu.zeng@gmail.com>
---
arch/ia64/include/asm/bitops.h | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/arch/ia64/include/asm/bitops.h b/arch/ia64/include/asm/bitops.h
index 71e8145..de13d89 100644
--- a/arch/ia64/include/asm/bitops.h
+++ b/arch/ia64/include/asm/bitops.h
@@ -439,6 +439,22 @@ static __inline__ unsigned long __arch_hweight64(unsigned long x)
#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.
+ */
+static __inline__ unsigned int __arch_parity64(unsigned long x)
+{
+ return (unsigned int)ia64_popcnt(x) & 1;
+}
+
+#define __arch_parity32(x) ((unsigned int) __arch_parity64((x) & 0xfffffffful))
+#define __arch_parity16(x) ((unsigned int) __arch_parity64((x) & 0xfffful))
+#define __arch_parity8(x) ((unsigned int) __arch_parity64((x) & 0xfful))
+#define __arch_parity4(x) ((unsigned int) __arch_parity64((x) & 0xful))
+
+#include <asm-generic/bitops/const_parity.h>
+
#endif /* __KERNEL__ */
#include <asm-generic/bitops/find.h>
--
2.5.5
[toc] | [prev] | [next] | [standalone]
| From | "zhaoxiu.zeng" <zhaoxiu.zeng@gmail.com> |
|---|---|
| Date | 2016-03-27 08:20 +0200 |
| Subject | [PATCH 08/31] Add tile-specific parity functions |
| Message-ID | <rhcdj-48J-1@gated-at.bofh.it> |
| In reply to | #1363884 |
From: Zeng Zhaoxiu <zhaoxiu.zeng@gmail.com>
Signed-off-by: Zeng Zhaoxiu <zhaoxiu.zeng@gmail.com>
---
arch/tile/include/asm/bitops.h | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/arch/tile/include/asm/bitops.h b/arch/tile/include/asm/bitops.h
index 20caa34..370d007 100644
--- a/arch/tile/include/asm/bitops.h
+++ b/arch/tile/include/asm/bitops.h
@@ -81,10 +81,36 @@ static inline unsigned long __arch_hweight64(__u64 w)
return __builtin_popcountll(w);
}
+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;
+}
+
#include <asm-generic/bitops/builtin-__ffs.h>
#include <asm-generic/bitops/builtin-__fls.h>
#include <asm-generic/bitops/builtin-ffs.h>
#include <asm-generic/bitops/const_hweight.h>
+#include <asm-generic/bitops/const_parity.h>
#include <asm-generic/bitops/lock.h>
#include <asm-generic/bitops/find.h>
#include <asm-generic/bitops/sched.h>
--
2.5.5
[toc] | [prev] | [next] | [standalone]
| From | "zhaoxiu.zeng" <zhaoxiu.zeng@gmail.com> |
|---|---|
| Date | 2016-03-27 08:40 +0200 |
| Subject | [PATCH 09/31] Add powerpc-specific parity functions |
| Message-ID | <rhcwF-4gC-1@gated-at.bofh.it> |
| In reply to | #1363884 |
From: Zeng Zhaoxiu <zhaoxiu.zeng@gmail.com> Signed-off-by: Zeng Zhaoxiu <zhaoxiu.zeng@gmail.com> --- arch/powerpc/include/asm/bitops.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arch/powerpc/include/asm/bitops.h b/arch/powerpc/include/asm/bitops.h index 59abc62..90ee0f2 100644 --- a/arch/powerpc/include/asm/bitops.h +++ b/arch/powerpc/include/asm/bitops.h @@ -269,8 +269,15 @@ unsigned int __arch_hweight16(unsigned int w); unsigned int __arch_hweight32(unsigned int w); unsigned long __arch_hweight64(__u64 w); #include <asm-generic/bitops/const_hweight.h> +#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_parity.h> #else #include <asm-generic/bitops/hweight.h> +#include <asm-generic/bitops/parity.h> #endif #include <asm-generic/bitops/find.h> -- 2.5.5
[toc] | [prev] | [next] | [standalone]
| From | "zhaoxiu.zeng" <zhaoxiu.zeng@gmail.com> |
|---|---|
| Date | 2016-03-27 08:50 +0200 |
| Subject | [PATCH 11/31] Add x86-specific parity functions |
| Message-ID | <rhcGl-4kX-1@gated-at.bofh.it> |
| In reply to | #1363884 |
From: Zeng Zhaoxiu <zhaoxiu.zeng@gmail.com> Signed-off-by: Zeng Zhaoxiu <zhaoxiu.zeng@gmail.com> --- arch/x86/include/asm/bitops.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h index 7766d1c..d3210c0 100644 --- a/arch/x86/include/asm/bitops.h +++ b/arch/x86/include/asm/bitops.h @@ -501,6 +501,18 @@ static __always_inline int fls64(__u64 x) #include <asm-generic/bitops/const_hweight.h> +#define __arch_parity32(x) (__arch_hweight32(x) & 1) +#define __arch_parity4(x) (__arch_parity32((x) & 0xf)) +#define __arch_parity8(x) (__arch_parity32((x) & 0xff)) +#define __arch_parity16(x) (__arch_parity32((x) & 0xffff)) +#ifdef CONFIG_X86_32 +#define __arch_parity64(x) (__arch_parity32((unsigned int)((x) >> 32) ^ (unsigned int)(x))) +#else +#define __arch_parity64(x) (__arch_hweight64(x) & 1) +#endif + +#include <asm-generic/bitops/const_parity.h> + #include <asm-generic/bitops/le.h> #include <asm-generic/bitops/ext2-atomic-setbit.h> -- 2.5.5
[toc] | [prev] | [next] | [standalone]
| From | One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk> |
|---|---|
| Date | 2016-03-29 14:20 +0200 |
| Subject | Re: [PATCH 11/31] Add x86-specific parity functions |
| Message-ID | <ri0MO-65P-5@gated-at.bofh.it> |
| In reply to | #1365066 |
On Sun, 27 Mar 2016 14:45:50 +0800 "zhaoxiu.zeng" <zhaoxiu.zeng@gmail.com> wrote: > From: Zeng Zhaoxiu <zhaoxiu.zeng@gmail.com> > > Signed-off-by: Zeng Zhaoxiu <zhaoxiu.zeng@gmail.com> > --- > arch/x86/include/asm/bitops.h | 12 ++++++++++++ > 1 file changed, 12 insertions(+) > > diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h > index 7766d1c..d3210c0 100644 > --- a/arch/x86/include/asm/bitops.h > +++ b/arch/x86/include/asm/bitops.h > @@ -501,6 +501,18 @@ static __always_inline int fls64(__u64 x) > > #include <asm-generic/bitops/const_hweight.h> > > +#define __arch_parity32(x) (__arch_hweight32(x) & 1) > +#define __arch_parity4(x) (__arch_parity32((x) & 0xf)) > +#define __arch_parity8(x) (__arch_parity32((x) & 0xff)) > +#define __arch_parity16(x) (__arch_parity32((x) & 0xffff)) > +#ifdef CONFIG_X86_32 > +#define __arch_parity64(x) (__arch_parity32((unsigned int)((x) >> 32) ^ (unsigned int)(x))) > +#else > +#define __arch_parity64(x) (__arch_hweight64(x) & 1) > +#endif arch_hweight32() is a subroutine call to a helper on x86 and the rest appears to make no sense for this CPU. Gcc has its own parity helper and even if you are not using that the CPU itself has a parity flag for doing 8bit parity so you just use TEST/J[N]P for parity 8 (and the obvious for 4 and 16). For 32bit parity there is __builtin_parity(). For 64bit __builtin_parityll(). Alan
[toc] | [prev] | [next] | [standalone]
| From | "zhaoxiu.zeng" <zhaoxiu.zeng@gmail.com> |
|---|---|
| Date | 2016-03-27 08:50 +0200 |
| Subject | [PATCH 10/31] Add sparc-specific parity functions |
| Message-ID | <rhcGl-4kX-3@gated-at.bofh.it> |
| In reply to | #1363884 |
From: Zeng Zhaoxiu <zhaoxiu.zeng@gmail.com> Signed-off-by: Zeng Zhaoxiu <zhaoxiu.zeng@gmail.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
[toc] | [prev] | [next] | [standalone]
| From | David Miller <davem@davemloft.net> |
|---|---|
| Date | 2016-03-28 04:50 +0200 |
| Subject | Re: [PATCH 10/31] Add sparc-specific parity functions |
| Message-ID | <rhvpD-Dg-3@gated-at.bofh.it> |
| In reply to | #1365067 |
From: "zhaoxiu.zeng" <zhaoxiu.zeng@gmail.com> Date: Sun, 27 Mar 2016 14:43:10 +0800 > + > +/* > + * 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) This looks like asm-generic/ material to me.
[toc] | [prev] | [next] | [standalone]
| From | Zeng Zhaoxiu <zhaoxiu.zeng@gmail.com> |
|---|---|
| Date | 2016-03-28 07:50 +0200 |
| Subject | Re: [PATCH 10/31] Add sparc-specific parity functions |
| Message-ID | <rhydQ-2zS-1@gated-at.bofh.it> |
| In reply to | #1365270 |
在 2016年03月28日 10:43, David Miller 写道: > From: "zhaoxiu.zeng" <zhaoxiu.zeng@gmail.com> > Date: Sun, 27 Mar 2016 14:43:10 +0800 > >> + >> +/* >> + * 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) > This looks like asm-generic/ material to me. This is generic for the architectures which have popcount instruction, but more higher costs than asm-generic/ for others.
[toc] | [prev] | [next] | [standalone]
| From | David Miller <davem@davemloft.net> |
|---|---|
| Date | 2016-03-28 17:30 +0200 |
| Subject | Re: [PATCH 10/31] Add sparc-specific parity functions |
| Message-ID | <rhHh7-vz-13@gated-at.bofh.it> |
| In reply to | #1365331 |
From: Zeng Zhaoxiu <zhaoxiu.zeng@gmail.com> Date: Mon, 28 Mar 2016 13:44:03 +0800 > 在 2016年03月28日 10:43, David Miller 写道: >> From: "zhaoxiu.zeng" <zhaoxiu.zeng@gmail.com> >> Date: Sun, 27 Mar 2016 14:43:10 +0800 >> >>> + >>> +/* >>> + * 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) >> This looks like asm-generic/ material to me. > > This is generic for the architectures which have popcount instruction, > but more higher costs than asm-generic/ for others. Which is why said stanza's in the asm-generic header should be triggered by a CPP define or similar.
[toc] | [prev] | [next] | [standalone]
| From | Sam Ravnborg <sam@ravnborg.org> |
|---|---|
| Date | 2016-03-28 17:40 +0200 |
| Subject | Re: [PATCH 10/31] Add sparc-specific parity functions |
| Message-ID | <rhHqP-yH-15@gated-at.bofh.it> |
| In reply to | #1365544 |
On Mon, Mar 28, 2016 at 11:29:15AM -0400, David Miller wrote: > From: Zeng Zhaoxiu <zhaoxiu.zeng@gmail.com> > Date: Mon, 28 Mar 2016 13:44:03 +0800 > > > 在 2016年03月28日 10:43, David Miller 写道: > >> From: "zhaoxiu.zeng" <zhaoxiu.zeng@gmail.com> > >> Date: Sun, 27 Mar 2016 14:43:10 +0800 > >> > >>> + > >>> +/* > >>> + * 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) > >> This looks like asm-generic/ material to me. > > > > This is generic for the architectures which have popcount instruction, > > but more higher costs than asm-generic/ for others. > > Which is why said stanza's in the asm-generic header should be triggered > by a CPP define or similar. For sparc we would need to do a run-time patch as far as I see. If popc is availble then use of hweight* should be fine. But without popc then I think the generic implementation that uses the stanford algorithm would be most efficient, rather than the base this on the generic hweight functions. Sam
[toc] | [prev] | [next] | [standalone]
| From | David Miller <davem@davemloft.net> |
|---|---|
| Date | 2016-03-28 17:50 +0200 |
| Subject | Re: [PATCH 10/31] Add sparc-specific parity functions |
| Message-ID | <rhHAt-C5-5@gated-at.bofh.it> |
| In reply to | #1365551 |
From: Sam Ravnborg <sam@ravnborg.org> Date: Mon, 28 Mar 2016 17:37:43 +0200 > If popc is availble then use of hweight* should be fine. > But without popc then I think the generic implementation that > uses the stanford algorithm would be most efficient, > rather than the base this on the generic hweight functions. Agreed.
[toc] | [prev] | [next] | [standalone]
| From | "zhaoxiu.zeng" <zhaoxiu.zeng@gmail.com> |
|---|---|
| Date | 2016-03-27 09:00 +0200 |
| Subject | [PATCH 12/31] sunrpc: auth_gss: use parity8 |
| Message-ID | <rhcQ2-4ou-3@gated-at.bofh.it> |
| In reply to | #1363884 |
From: Zeng Zhaoxiu <zhaoxiu.zeng@gmail.com>
Signed-off-by: Zeng Zhaoxiu <zhaoxiu.zeng@gmail.com>
---
net/sunrpc/auth_gss/gss_krb5_keys.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/net/sunrpc/auth_gss/gss_krb5_keys.c b/net/sunrpc/auth_gss/gss_krb5_keys.c
index 8701331..c41b389 100644
--- a/net/sunrpc/auth_gss/gss_krb5_keys.c
+++ b/net/sunrpc/auth_gss/gss_krb5_keys.c
@@ -243,16 +243,12 @@ err_return:
return ret;
}
-#define smask(step) ((1<<step)-1)
-#define pstep(x, step) (((x)&smask(step))^(((x)>>step)&smask(step)))
-#define parity_char(x) pstep(pstep(pstep((x), 4), 2), 1)
-
static void mit_des_fixup_key_parity(u8 key[8])
{
int i;
for (i = 0; i < 8; i++) {
key[i] &= 0xfe;
- key[i] |= 1^parity_char(key[i]);
+ key[i] |= !parity8(key[i]);
}
}
--
2.5.5
[toc] | [prev] | [next] | [standalone]
| From | "zhaoxiu.zeng" <zhaoxiu.zeng@gmail.com> |
|---|---|
| Date | 2016-03-27 09:00 +0200 |
| Subject | [PATCH 13/31] mips: use parity functions in cerr-sb1.c |
| Message-ID | <rhcQ2-4ou-5@gated-at.bofh.it> |
| In reply to | #1363884 |
From: Zeng Zhaoxiu <zhaoxiu.zeng@gmail.com>
Signed-off-by: Zeng Zhaoxiu <zhaoxiu.zeng@gmail.com>
---
arch/mips/mm/cerr-sb1.c | 67 +++++++++++++------------------------------------
1 file changed, 17 insertions(+), 50 deletions(-)
diff --git a/arch/mips/mm/cerr-sb1.c b/arch/mips/mm/cerr-sb1.c
index ee5c1ff..2e7d660 100644
--- a/arch/mips/mm/cerr-sb1.c
+++ b/arch/mips/mm/cerr-sb1.c
@@ -264,27 +264,6 @@ asmlinkage void sb1_cache_error(void)
#endif
}
-
-/* Parity lookup table. */
-static const uint8_t parity[256] = {
- 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
- 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
- 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
- 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
- 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
- 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
- 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
- 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
- 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
- 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
- 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
- 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
- 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
- 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
- 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
- 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0
-};
-
/* Masks to select bits for Hamming parity, mask_72_64[i] for bit[i] */
static const uint64_t mask_72_64[8] = {
0x0738C808099264FFULL,
@@ -298,34 +277,28 @@ static const uint64_t mask_72_64[8] = {
};
/* Calculate the parity on a range of bits */
-static char range_parity(uint64_t dword, int max, int min)
+static inline char range_parity(uint64_t dword, int max, int min)
{
- char parity = 0;
- int i;
- dword >>= min;
- for (i=max-min; i>=0; i--) {
- if (dword & 0x1)
- parity = !parity;
- dword >>= 1;
+ int n = max - min + 1;
+ if (__builtin_constant_p(n)) {
+ if (n <= 8)
+ return parity8((unsigned int)(dword >> min) & ((1U << n) - 1));
+ if (n <= 16)
+ return parity16((unsigned int)(dword >> min) & ((1U << n) - 1));
+ if (n <= 32)
+ return parity32((unsigned int)(dword >> min) & ((1U << n) - 1));
}
- return parity;
+ return parity64((dword >> min) & ((1ULL << n) - 1));
}
/* Calculate the 4-bit even byte-parity for an instruction */
-static unsigned char inst_parity(uint32_t word)
+static inline unsigned char inst_parity(uint32_t word)
{
- int i, j;
- char parity = 0;
- for (j=0; j<4; j++) {
- char byte_parity = 0;
- for (i=0; i<8; i++) {
- if (word & 0x80000000)
- byte_parity = !byte_parity;
- word <<= 1;
- }
- parity <<= 1;
- parity |= byte_parity;
- }
+ char parity;
+ parity = parity8(word >> 24) << 3;
+ parity |= parity8(word >> 16) << 2;
+ parity |= parity8(word >> 8) << 1;
+ parity |= parity8(word);
return parity;
}
@@ -436,7 +409,6 @@ static uint32_t extract_ic(unsigned short addr, int data)
static uint8_t dc_ecc(uint64_t dword)
{
uint64_t t;
- uint32_t w;
uint8_t p;
int i;
@@ -445,12 +417,7 @@ static uint8_t dc_ecc(uint64_t dword)
{
p <<= 1;
t = dword & mask_72_64[i];
- w = (uint32_t)(t >> 32);
- p ^= (parity[w>>24] ^ parity[(w>>16) & 0xFF]
- ^ parity[(w>>8) & 0xFF] ^ parity[w & 0xFF]);
- w = (uint32_t)(t & 0xFFFFFFFF);
- p ^= (parity[w>>24] ^ parity[(w>>16) & 0xFF]
- ^ parity[(w>>8) & 0xFF] ^ parity[w & 0xFF]);
+ p |= parity64(t);
}
return p;
}
--
2.5.5
[toc] | [prev] | [next] | [standalone]
| From | "zhaoxiu.zeng" <zhaoxiu.zeng@gmail.com> |
|---|---|
| Date | 2016-03-27 09:10 +0200 |
| Subject | [PATCH 15/31] media: use parity8 in vivid-vbi-gen.c |
| Message-ID | <rhcZH-4Ir-3@gated-at.bofh.it> |
| In reply to | #1363884 |
From: Zeng Zhaoxiu <zhaoxiu.zeng@gmail.com>
Signed-off-by: Zeng Zhaoxiu <zhaoxiu.zeng@gmail.com>
---
drivers/media/platform/vivid/vivid-vbi-gen.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/drivers/media/platform/vivid/vivid-vbi-gen.c b/drivers/media/platform/vivid/vivid-vbi-gen.c
index a2159de..d5ba0fc 100644
--- a/drivers/media/platform/vivid/vivid-vbi-gen.c
+++ b/drivers/media/platform/vivid/vivid-vbi-gen.c
@@ -175,14 +175,9 @@ static const u8 vivid_cc_sequence2[30] = {
0x14, 0x2f, /* End of Caption */
};
-static u8 calc_parity(u8 val)
+static inline u8 calc_parity(u8 val)
{
- unsigned i;
- unsigned tot = 0;
-
- for (i = 0; i < 7; i++)
- tot += (val & (1 << i)) ? 1 : 0;
- return val | ((tot & 1) ? 0 : 0x80);
+ return (!parity8(val) << 7) | val;
}
static void vivid_vbi_gen_set_time_of_day(u8 *packet)
--
2.5.5
[toc] | [prev] | [next] | [standalone]
| From | "zhaoxiu.zeng" <zhaoxiu.zeng@gmail.com> |
|---|---|
| Date | 2016-03-27 09:10 +0200 |
| Subject | [PATCH 14/31] lib: bch: use parity32 |
| Message-ID | <rhcZH-4Ir-5@gated-at.bofh.it> |
| In reply to | #1363884 |
From: Zeng Zhaoxiu <zhaoxiu.zeng@gmail.com>
Signed-off-by: Zeng Zhaoxiu <zhaoxiu.zeng@gmail.com>
---
lib/bch.c | 14 +-------------
1 file changed, 1 insertion(+), 13 deletions(-)
diff --git a/lib/bch.c b/lib/bch.c
index bc89dfe4..6c6e8d4 100644
--- a/lib/bch.c
+++ b/lib/bch.c
@@ -278,18 +278,6 @@ static inline int deg(unsigned int poly)
return fls(poly)-1;
}
-static inline int parity(unsigned int x)
-{
- /*
- * public domain code snippet, lifted from
- * http://www-graphics.stanford.edu/~seander/bithacks.html
- */
- x ^= x >> 1;
- x ^= x >> 2;
- x = (x & 0x11111111U) * 0x11111111U;
- return (x >> 28) & 1;
-}
-
/* Galois field basic operations: multiply, divide, inverse, etc. */
static inline unsigned int gf_mul(struct bch_control *bch, unsigned int a,
@@ -494,7 +482,7 @@ static int solve_linear_system(struct bch_control *bch, unsigned int *rows,
tmp = 0;
for (r = m-1; r >= 0; r--) {
mask = rows[r] & (tmp|1);
- tmp |= parity(mask) << (m-r);
+ tmp |= parity32(mask) << (m-r);
}
sol[p] = tmp >> 1;
}
--
2.5.5
[toc] | [prev] | [next] | [standalone]
| From | "zhaoxiu.zeng" <zhaoxiu.zeng@gmail.com> |
|---|---|
| Date | 2016-03-27 09:20 +0200 |
| Subject | [PATCH 17/31] input: joystick: use parity32 in grip_mp.c |
| Message-ID | <rhd9o-4Mh-3@gated-at.bofh.it> |
| In reply to | #1363884 |
From: Zeng Zhaoxiu <zhaoxiu.zeng@gmail.com>
Signed-off-by: Zeng Zhaoxiu <zhaoxiu.zeng@gmail.com>
---
drivers/input/joystick/grip_mp.c | 16 +---------------
1 file changed, 1 insertion(+), 15 deletions(-)
diff --git a/drivers/input/joystick/grip_mp.c b/drivers/input/joystick/grip_mp.c
index 573191d..3e29eb1 100644
--- a/drivers/input/joystick/grip_mp.c
+++ b/drivers/input/joystick/grip_mp.c
@@ -112,20 +112,6 @@ static const int axis_map[] = { 5, 9, 1, 5, 6, 10, 2, 6, 4, 8, 0, 4, 5, 9, 1, 5
static int register_slot(int i, struct grip_mp *grip);
/*
- * Returns whether an odd or even number of bits are on in pkt.
- */
-
-static int bit_parity(u32 pkt)
-{
- int x = pkt ^ (pkt >> 16);
- x ^= x >> 8;
- x ^= x >> 4;
- x ^= x >> 2;
- x ^= x >> 1;
- return x & 1;
-}
-
-/*
* Poll gameport; return true if all bits set in 'onbits' are on and
* all bits set in 'offbits' are off.
*/
@@ -235,7 +221,7 @@ static int mp_io(struct gameport* gameport, int sendflags, int sendcode, u32 *pa
pkt = (pkt >> 2) | 0xf0000000;
}
- if (bit_parity(pkt) == 1)
+ if (parity32(pkt))
return IO_RESET;
/* Acknowledge packet receipt */
--
2.5.5
[toc] | [prev] | [next] | [standalone]
| From | "zhaoxiu.zeng" <zhaoxiu.zeng@gmail.com> |
|---|---|
| Date | 2016-03-27 09:20 +0200 |
| Subject | [PATCH 18/31] input: joystick: use parity64 in sidewinder.c |
| Message-ID | <rhd9n-4Mh-1@gated-at.bofh.it> |
| In reply to | #1363884 |
From: Zeng Zhaoxiu <zhaoxiu.zeng@gmail.com>
Signed-off-by: Zeng Zhaoxiu <zhaoxiu.zeng@gmail.com>
---
drivers/input/joystick/sidewinder.c | 24 ++++--------------------
1 file changed, 4 insertions(+), 20 deletions(-)
diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c
index 4a95b22..7ea486e 100644
--- a/drivers/input/joystick/sidewinder.c
+++ b/drivers/input/joystick/sidewinder.c
@@ -259,22 +259,6 @@ static void sw_init_digital(struct gameport *gameport)
}
/*
- * sw_parity() computes parity of __u64
- */
-
-static int sw_parity(__u64 t)
-{
- int x = t ^ (t >> 32);
-
- x ^= x >> 16;
- x ^= x >> 8;
- x ^= x >> 4;
- x ^= x >> 2;
- x ^= x >> 1;
- return x & 1;
-}
-
-/*
* sw_ccheck() checks synchronization bits and computes checksum of nibbles.
*/
@@ -334,7 +318,7 @@ static int sw_parse(unsigned char *buf, struct sw *sw)
for (i = 0; i < sw->number; i ++) {
- if (sw_parity(GB(i*15,15)))
+ if (parity64(GB(i*15,15)))
return -1;
input_report_abs(sw->dev[i], ABS_X, GB(i*15+3,1) - GB(i*15+2,1));
@@ -351,7 +335,7 @@ static int sw_parse(unsigned char *buf, struct sw *sw)
case SW_ID_PP:
case SW_ID_FFP:
- if (!sw_parity(GB(0,48)) || (hat = GB(42,4)) > 8)
+ if (!parity64(GB(0,48)) || (hat = GB(42,4)) > 8)
return -1;
dev = sw->dev[0];
@@ -372,7 +356,7 @@ static int sw_parse(unsigned char *buf, struct sw *sw)
case SW_ID_FSP:
- if (!sw_parity(GB(0,43)) || (hat = GB(28,4)) > 8)
+ if (!parity64(GB(0,43)) || (hat = GB(28,4)) > 8)
return -1;
dev = sw->dev[0];
@@ -397,7 +381,7 @@ static int sw_parse(unsigned char *buf, struct sw *sw)
case SW_ID_FFW:
- if (!sw_parity(GB(0,33)))
+ if (!parity64(GB(0,33)))
return -1;
dev = sw->dev[0];
--
2.5.5
[toc] | [prev] | [next] | [standalone]
Page 2 of 3 — ← Prev page 1 [2] 3 Next page →
Back to top | Article view | linux.kernel
csiph-web