summaryrefslogtreecommitdiff
path: root/drivers/staging
diff options
context:
space:
mode:
authorHernán Gonzalez <hernan@vanguardiasur.com.ar>2018-04-13 13:36:38 -0300
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2018-04-15 16:00:28 +0100
commit95302e54d2687ed778e4fe056e512dafac9f6588 (patch)
treeb908df6823f912570fe27e5405e61ac6c5acfbaf /drivers/staging
parenta60acdf940da288327e7c730e097dbfea49ac9bb (diff)
staging: iio: ad7746: Automatically swap values in readings/writings
Data to read or write was being handled with the swab16() macro instead of using i2c_smbus_{read,write}_swapped. Signed-off-by: Hernán Gonzalez <hernan@vanguardiasur.com.ar> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/staging')
-rw-r--r--drivers/staging/iio/cdc/ad7746.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/drivers/staging/iio/cdc/ad7746.c b/drivers/staging/iio/cdc/ad7746.c
index 4882dbc81c53..53e28aeef417 100644
--- a/drivers/staging/iio/cdc/ad7746.c
+++ b/drivers/staging/iio/cdc/ad7746.c
@@ -451,7 +451,7 @@ static int ad7746_write_raw(struct iio_dev *indio_dev,
goto out;
}
- ret = i2c_smbus_write_word_data(chip->client, reg, swab16(val));
+ ret = i2c_smbus_write_word_swapped(chip->client, reg, val);
if (ret < 0)
goto out;
@@ -462,8 +462,8 @@ static int ad7746_write_raw(struct iio_dev *indio_dev,
ret = -EINVAL;
goto out;
}
- ret = i2c_smbus_write_word_data(chip->client,
- AD7746_REG_CAP_OFFH, swab16(val));
+ ret = i2c_smbus_write_word_swapped(chip->client,
+ AD7746_REG_CAP_OFFH, val);
if (ret < 0)
goto out;
@@ -594,21 +594,21 @@ static int ad7746_read_raw(struct iio_dev *indio_dev,
goto out;
}
- ret = i2c_smbus_read_word_data(chip->client, reg);
+ ret = i2c_smbus_read_word_swapped(chip->client, reg);
if (ret < 0)
goto out;
/* 1 + gain_val / 2^16 */
*val = 1;
- *val2 = (15625 * swab16(ret)) / 1024;
+ *val2 = (15625 * ret) / 1024;
ret = IIO_VAL_INT_PLUS_MICRO;
break;
case IIO_CHAN_INFO_CALIBBIAS:
- ret = i2c_smbus_read_word_data(chip->client,
- AD7746_REG_CAP_OFFH);
+ ret = i2c_smbus_read_word_swapped(chip->client,
+ AD7746_REG_CAP_OFFH);
if (ret < 0)
goto out;
- *val = swab16(ret);
+ *val = ret;
ret = IIO_VAL_INT;
break;