From: Lars-Peter Clausen <lars@metafoo.de>
To: Jonathan Cameron <jic23@kernel.org>, linux-iio@vger.kernel.org
Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com>,
Dan Carpenter <dan.carpenter@oracle.com>
Subject: Re: [PATCH] iio: accel: sca3000: Use sign_extend32() instead of opencoding sign extension.
Date: Sun, 3 Oct 2021 20:03:10 +0200 [thread overview]
Message-ID: <30fd2ee6-8182-8576-80ff-1cebab55a0dc@metafoo.de> (raw)
In-Reply-To: <20210603164729.3584702-1-jic23@kernel.org>
On 6/3/21 6:47 PM, Jonathan Cameron wrote:
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
>
> Whilst nice to get rid of this non obvious code, this also clears a
> static checker warning:
>
> drivers/iio/accel/sca3000.c:734 sca3000_read_raw()
> warn: no-op. '((*val) << 19) >> 19'
>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> ---
> drivers/iio/accel/sca3000.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/iio/accel/sca3000.c b/drivers/iio/accel/sca3000.c
> index cb753a43533c..0692ccb80293 100644
> --- a/drivers/iio/accel/sca3000.c
> +++ b/drivers/iio/accel/sca3000.c
> @@ -731,8 +731,7 @@ static int sca3000_read_raw(struct iio_dev *indio_dev,
> return ret;
> }
> *val = (be16_to_cpup((__be16 *)st->rx) >> 3) & 0x1FFF;
> - *val = ((*val) << (sizeof(*val) * 8 - 13)) >>
> - (sizeof(*val) * 8 - 13);
> + *val = sign_extend32(*val, 13);
Should be 12 I think. The index is 0 based.
> } else {
> /* get the temperature when available */
> ret = sca3000_read_data_short(st,
next prev parent reply other threads:[~2021-10-03 18:03 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-03 16:47 [PATCH] iio: accel: sca3000: Use sign_extend32() instead of opencoding sign extension Jonathan Cameron
2021-07-18 15:16 ` Jonathan Cameron
2021-10-03 16:06 ` Jonathan Cameron
2021-10-03 18:03 ` Lars-Peter Clausen [this message]
2021-10-10 16:29 ` Jonathan Cameron
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=30fd2ee6-8182-8576-80ff-1cebab55a0dc@metafoo.de \
--to=lars@metafoo.de \
--cc=Jonathan.Cameron@huawei.com \
--cc=dan.carpenter@oracle.com \
--cc=jic23@kernel.org \
--cc=linux-iio@vger.kernel.org \
/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).