lkml.org 
[lkml]   [2016]   [Apr]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH v2 04/30] Add blackfin-specific parity functions
    Date
    From: Zhaoxiu Zeng <zhaoxiu.zeng@gmail.com>

    Signed-off-by: Zhaoxiu Zeng <zhaoxiu.zeng@gmail.com>
    ---
    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..6609b7e 100644
    --- a/arch/blackfin/include/asm/bitops.h
    +++ b/arch/blackfin/include/asm/bitops.h
    @@ -23,6 +23,7 @@
    #include <asm-generic/bitops/sched.h>
    #include <asm-generic/bitops/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/ext2-atomic.h>
    @@ -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 w 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.0

    \
     
     \ /
      Last update: 2016-04-06 11:21    [W:4.608 / U:0.144 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site