From: Jonathan Cameron <jic23@kernel.org>
To: Gwendal Grignou <gwendal@chromium.org>
Cc: lars@metafoo.de, andy.shevchenko@gmail.com, linux-iio@vger.kernel.org
Subject: Re: [PATCH 2/4] iio: ti-ads1015: Remove shift variable ads1015_read_raw
Date: Wed, 3 Nov 2021 18:53:25 +0000 [thread overview]
Message-ID: <20211103185325.5d968556@jic23-huawei> (raw)
In-Reply-To: <20211101071822.522178-3-gwendal@chromium.org>
On Mon, 1 Nov 2021 00:18:20 -0700
Gwendal Grignou <gwendal@chromium.org> wrote:
> By using scan_type.realbits when processing raw data,
> we use scan_type.shit only once, thus we don't need to define a local
Possibly Freudian typo..
> variable for it anymore.
>
> Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Otherwise looks fine to me and works for both
realbits = 16, shift = 0
realbits = 12, shift = 4
Jonathan
> ---
> drivers/iio/adc/ti-ads1015.c | 8 +++-----
> 1 file changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/iio/adc/ti-ads1015.c b/drivers/iio/adc/ti-ads1015.c
> index b0352e91ac165..b92d4cd1b8238 100644
> --- a/drivers/iio/adc/ti-ads1015.c
> +++ b/drivers/iio/adc/ti-ads1015.c
> @@ -464,9 +464,7 @@ static int ads1015_read_raw(struct iio_dev *indio_dev,
>
> mutex_lock(&data->lock);
> switch (mask) {
> - case IIO_CHAN_INFO_RAW: {
> - int shift = chan->scan_type.shift;
> -
> + case IIO_CHAN_INFO_RAW:
> ret = iio_device_claim_direct_mode(indio_dev);
> if (ret)
> break;
> @@ -487,7 +485,8 @@ static int ads1015_read_raw(struct iio_dev *indio_dev,
> goto release_direct;
> }
>
> - *val = sign_extend32(*val >> shift, 15 - shift);
> + *val = sign_extend32(*val >> chan->scan_type.shift,
> + chan->scan_type.realbits - 1);
>
> ret = ads1015_set_power_state(data, false);
> if (ret < 0)
> @@ -497,7 +496,6 @@ static int ads1015_read_raw(struct iio_dev *indio_dev,
> release_direct:
> iio_device_release_direct_mode(indio_dev);
> break;
> - }
> case IIO_CHAN_INFO_SCALE:
> idx = data->channel_data[chan->address].pga;
> *val = ads1015_fullscale_range[idx];
next prev parent reply other threads:[~2021-11-03 18:48 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-01 7:18 [PATCH 0/4] iio: Use scan_type shift and realbits when processing raw data Gwendal Grignou
2021-11-01 7:18 ` [PATCH 1/4] " Gwendal Grignou
2021-11-03 18:42 ` Jonathan Cameron
2021-11-04 8:24 ` Gwendal Grignou
2021-11-04 8:49 ` Eugen.Hristev
2021-11-01 7:18 ` [PATCH 2/4] iio: ti-ads1015: Remove shift variable ads1015_read_raw Gwendal Grignou
2021-11-03 18:53 ` Jonathan Cameron [this message]
2021-11-01 7:18 ` [PATCH 3/4] iio: xilinx-xadc-core: Use local variable in xadc_read_raw Gwendal Grignou
2021-11-03 18:55 ` Jonathan Cameron
2021-11-01 7:18 ` [PATCH 4/4] iio: mpl3115: Use scan_type.shift and realbit in mpl3115_read_raw Gwendal Grignou
2021-11-03 18:58 ` 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=20211103185325.5d968556@jic23-huawei \
--to=jic23@kernel.org \
--cc=andy.shevchenko@gmail.com \
--cc=gwendal@chromium.org \
--cc=lars@metafoo.de \
--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