summaryrefslogtreecommitdiff
path: root/drivers/iio/adc/ti-ads1015.c
diff options
context:
space:
mode:
authorGwendal Grignou <gwendal@chromium.org>2021-11-04 11:24:11 +0300
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2021-11-17 20:51:43 +0300
commitaad54091e1b50d725baa31c11358e6d6dcf44cf0 (patch)
tree5230c2facb98edc28abd5b3e78d4df709374e206 /drivers/iio/adc/ti-ads1015.c
parent4d57fb548a1b086fc216c94cc186fba03c396190 (diff)
downloadlinux-aad54091e1b50d725baa31c11358e6d6dcf44cf0.tar.xz
iio: ti-ads1015: Remove shift variable ads1015_read_raw
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 variable for it anymore. Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Link: https://lore.kernel.org/r/20211104082413.3681212-12-gwendal@chromium.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/iio/adc/ti-ads1015.c')
-rw-r--r--drivers/iio/adc/ti-ads1015.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/drivers/iio/adc/ti-ads1015.c b/drivers/iio/adc/ti-ads1015.c
index b0352e91ac16..b92d4cd1b823 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];