From: Zeng Zhaoxiu <zhaoxiu.zeng@gmail.com>
To: Sam Ravnborg <sam@ravnborg.org>
Cc: Denys Vlasenko <dvlasenk@redhat.com>,
Arnd Bergmann <arnd@arndb.de>,
Andrew Morton <akpm@linux-foundation.org>,
Martin Kepplinger <martink@posteo.de>,
Sasha Levin <sasha.levin@oracle.com>,
Ingo Molnar <mingo@kernel.org>, Yury Norov <yury.norov@gmail.com>,
linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org
Subject: Re: [PATCH 01/31] bitops: add parity functions
Date: Mon, 28 Mar 2016 10:15:24 +0800 [thread overview]
Message-ID: <56F893BC.1030100@gmail.com> (raw)
In-Reply-To: <56F7E24F.3040306@gmail.com>
On 2016年03月27日 21:38, zhaoxiu.zeng wrote:
> On 2016/3/27 20:44, Sam Ravnborg wrote:
>> Hi Zeng.
>>
>> Looking through the arch specific implementations of __arch_parity().
>> Some architectures uses #defines, other uses inline static functions.
>>
>> Any particular reason that you select one approach over the other
>> in the different cases?
>>
>> ia64:
>> +#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))
>>
>> tile:
>> +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);
>> +}
>>
> No particular reason, just like the architecture's __arch_hweightN.
>
>> Just two examples.
>>
>> Adding the parity helpers seems like veny nice simplifications.
>>
>> A few comments to some of those I looked at.
>> (I am not subscribed to lkml, so you get it as comments here)
>>
> I think the conversion is simple and readable.
>
>> [PATCH 21/31] mtd: use parity16 in ssfdc.c
>> The original code semes to check that the parity equals the
>> value of first bit in the address.
>> This seems lost after the conversion.
>>
> The original get_parity return 1 if the number is even, so
> if block_address is valid, "block_address & 0x7ff" must be odd.
Make corrections:
The original get_parity return 1 if hweight of the input number is even, so
if block_address is valid, hweight of "block_address & 0x7ff" must be odd.
>
>> [PATCH 20/31] scsi: use parity32 in isci/phy.c
>> + if (parity32(phy_cap.all))
>> phy_cap.parity = 1;
>> Could be written like this - simpler IMO:
>> phy_cap.parity = parity32(phy_cap.all);
>>
>>
>> Sam
>>
> Yes. Thanks!
>
next prev parent reply other threads:[~2016-03-28 2:15 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-24 3:03 [PATCH 01/31] bitops: add parity functions Zhaoxiu Zeng
2016-03-24 8:38 ` Denys Vlasenko
2016-03-24 22:28 ` Andrew Morton
2016-03-26 22:08 ` Martin Kepplinger
2016-03-27 7:51 ` zhaoxiu.zeng
2016-03-27 3:33 ` zhaoxiu.zeng
2016-03-27 12:44 ` Sam Ravnborg
2016-03-27 13:38 ` zhaoxiu.zeng
2016-03-27 17:56 ` Sam Ravnborg
2016-03-28 2:44 ` Zeng Zhaoxiu
2016-03-28 2:15 ` Zeng Zhaoxiu [this message]
2016-03-28 6:51 ` Sam Ravnborg
2016-03-29 2:27 ` Zeng Zhaoxiu
2016-03-29 2:56 ` Joe Perches
2016-03-29 2:56 ` Joe Perches
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=56F893BC.1030100@gmail.com \
--to=zhaoxiu.zeng@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=arnd@arndb.de \
--cc=dvlasenk@redhat.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=martink@posteo.de \
--cc=mingo@kernel.org \
--cc=sam@ravnborg.org \
--cc=sasha.levin@oracle.com \
--cc=yury.norov@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;
as well as URLs for NNTP newsgroup(s).