From: Jonathan Cameron <jic23@kernel.org>
To: "zhaoxiu.zeng" <zhaoxiu.zeng@gmail.com>,
Lars-Peter Clausen <lars@metafoo.de>,
Michael Hennerich <Michael.Hennerich@analog.com>,
Hartmut Knaack <knaack.h@gmx.de>,
Peter Meerwald <pmeerw@pmeerw.net>
Cc: linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org
Subject: Re: [PATCH 28/31] iio: gyro: use parity32 in adxrs450.c
Date: Mon, 28 Mar 2016 09:35:42 +0100 [thread overview]
Message-ID: <56F8ECDE.3010701@kernel.org> (raw)
In-Reply-To: <56F78ED3.8080603@gmail.com>
On 27/03/16 08:42, zhaoxiu.zeng wrote:
> From: Zeng Zhaoxiu <zhaoxiu.zeng@gmail.com>
>
> Signed-off-by: Zeng Zhaoxiu <zhaoxiu.zeng@gmail.com>
Interesting. Whilst obviously correct I wonder if this obscures the
intent of the code a little. Lars, what do you think?
Jonathan
> ---
> drivers/iio/gyro/adxrs450.c | 8 ++------
> 1 file changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/iio/gyro/adxrs450.c b/drivers/iio/gyro/adxrs450.c
> index a330d42..f1f19fc20 100644
> --- a/drivers/iio/gyro/adxrs450.c
> +++ b/drivers/iio/gyro/adxrs450.c
> @@ -108,9 +108,7 @@ static int adxrs450_spi_read_reg_16(struct iio_dev *indio_dev,
>
> mutex_lock(&st->buf_lock);
> tx = ADXRS450_READ_DATA | (reg_address << 17);
> -
> - if (!(hweight32(tx) & 1))
> - tx |= ADXRS450_P;
> + tx |= !parity32(tx) * ADXRS450_P;
>
> st->tx = cpu_to_be32(tx);
> ret = spi_sync_transfer(st->us, xfers, ARRAY_SIZE(xfers));
> @@ -144,9 +142,7 @@ static int adxrs450_spi_write_reg_16(struct iio_dev *indio_dev,
>
> mutex_lock(&st->buf_lock);
> tx = ADXRS450_WRITE_DATA | (reg_address << 17) | (val << 1);
> -
> - if (!(hweight32(tx) & 1))
> - tx |= ADXRS450_P;
> + tx |= !parity32(tx) * ADXRS450_P;
>
> st->tx = cpu_to_be32(tx);
> ret = spi_write(st->us, &st->tx, sizeof(st->tx));
>
next prev parent reply other threads:[~2016-03-28 8:35 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1458788612-4367-1-git-send-email-zhaoxiu.zeng@gmail.com>
2016-03-27 7:42 ` [PATCH 28/31] iio: gyro: use parity32 in adxrs450.c zhaoxiu.zeng
2016-03-28 8:35 ` Jonathan Cameron [this message]
2016-03-28 8:50 ` Lars-Peter Clausen
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=56F8ECDE.3010701@kernel.org \
--to=jic23@kernel.org \
--cc=Michael.Hennerich@analog.com \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pmeerw@pmeerw.net \
--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;
as well as URLs for NNTP newsgroup(s).