summaryrefslogtreecommitdiff
path: root/drivers/staging/iio
diff options
context:
space:
mode:
authorJonathan Cameron <Jonathan.Cameron@huawei.com>2021-03-14 18:14:48 +0000
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2021-04-07 08:36:35 +0100
commitadd538f4beb25c8334aa40cab6cfe066e836151f (patch)
tree65281779d9afce00c58f666aa2a90ea2887f1e6f /drivers/staging/iio
parenta71654af0a2199503c02e996b386d335158e0818 (diff)
staging:iio:cdc:ad7150: use swapped reads/writes for i2c rather than open coding
Reduces boilerplate and chances of getting the error handling wrong. No functional change. Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Reviewed-by: Alexandru Ardelean <alexandru.ardelean@analog.com> Reviewed-by: Barry Song <song.bao.hua@hisilicon> Link: https://lore.kernel.org/r/20210314181511.531414-2-jic23@kernel.org
Diffstat (limited to 'drivers/staging/iio')
-rw-r--r--drivers/staging/iio/cdc/ad7150.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/drivers/staging/iio/cdc/ad7150.c b/drivers/staging/iio/cdc/ad7150.c
index 48132ab157ef..c3ed88c5e0a5 100644
--- a/drivers/staging/iio/cdc/ad7150.c
+++ b/drivers/staging/iio/cdc/ad7150.c
@@ -109,18 +109,20 @@ static int ad7150_read_raw(struct iio_dev *indio_dev,
switch (mask) {
case IIO_CHAN_INFO_RAW:
- ret = i2c_smbus_read_word_data(chip->client,
- ad7150_addresses[channel][0]);
+ ret = i2c_smbus_read_word_swapped(chip->client,
+ ad7150_addresses[channel][0]);
if (ret < 0)
return ret;
- *val = swab16(ret);
+ *val = ret;
+
return IIO_VAL_INT;
case IIO_CHAN_INFO_AVERAGE_RAW:
- ret = i2c_smbus_read_word_data(chip->client,
- ad7150_addresses[channel][1]);
+ ret = i2c_smbus_read_word_swapped(chip->client,
+ ad7150_addresses[channel][1]);
if (ret < 0)
return ret;
- *val = swab16(ret);
+ *val = ret;
+
return IIO_VAL_INT;
default:
return -EINVAL;
@@ -188,9 +190,9 @@ static int ad7150_write_event_params(struct iio_dev *indio_dev,
/* Note completely different from the adaptive versions */
case IIO_EV_TYPE_THRESH:
value = chip->threshold[rising][chan];
- return i2c_smbus_write_word_data(chip->client,
- ad7150_addresses[chan][3],
- swab16(value));
+ return i2c_smbus_write_word_swapped(chip->client,
+ ad7150_addresses[chan][3],
+ value);
case IIO_EV_TYPE_MAG_ADAPTIVE:
sens = chip->mag_sensitivity[rising][chan];
timeout = chip->mag_timeout[rising][chan];