From: Jonathan Cameron <Jonathan.Cameron@xxxxxxxxxx> Dropping the indirection on address lookup as there was only one address enables several other minor cleanups. Signed-off-by: Jonathan Cameron <Jonathan.Cameron@xxxxxxxxxx> --- drivers/staging/iio/accel/adis16203.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/staging/iio/accel/adis16203.c b/drivers/staging/iio/accel/adis16203.c index b59a003f3e26..67c0340d7097 100644 --- a/drivers/staging/iio/accel/adis16203.c +++ b/drivers/staging/iio/accel/adis16203.c @@ -5,6 +5,7 @@ * Copyright 2010 Analog Devices Inc. */ +#include <linux/bitfield.h> #include <linux/device.h> #include <linux/kernel.h> #include <linux/module.h> @@ -57,6 +58,8 @@ #define ADIS16203_ERROR_ACTIVE BIT(14) +#define ADIS16203_INCLI_NULL_MSK GENMASK(13, 0) + enum adis16203_scan { ADIS16203_SCAN_INCLI_X, ADIS16203_SCAN_SUPPLY, @@ -66,10 +69,6 @@ enum adis16203_scan { #define DRIVER_NAME "adis16203" -static const u8 adis16203_addresses[] = { - [ADIS16203_SCAN_INCLI_X] = ADIS16203_INCL_NULL, -}; - static int adis16203_write_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int val, @@ -77,10 +76,12 @@ static int adis16203_write_raw(struct iio_dev *indio_dev, long mask) { struct adis *st = iio_priv(indio_dev); - /* currently only one writable parameter which keeps this simple */ - u8 addr = adis16203_addresses[chan->scan_index]; - return adis_write_reg_16(st, addr, val & 0x3FFF); + if (mask != IIO_CHAN_INFO_CALIBBIAS) + return -EINVAL; + + return adis_write_reg_16(st, ADIS16203_INCL_NULL, + FIELD_PREP(ADIS16203_INCLI_NULL_MSK, val)); } static int adis16203_read_raw(struct iio_dev *indio_dev, @@ -90,7 +91,7 @@ static int adis16203_read_raw(struct iio_dev *indio_dev, { struct adis *st = iio_priv(indio_dev); int ret; - u8 addr; + s16 val16; switch (mask) { @@ -123,8 +124,7 @@ static int adis16203_read_raw(struct iio_dev *indio_dev, *val = 25000 / -470 - 1278; /* 25 C = 1278 */ return IIO_VAL_INT; case IIO_CHAN_INFO_CALIBBIAS: - addr = adis16203_addresses[chan->scan_index]; - ret = adis_read_reg_16(st, addr, &val16); + ret = adis_read_reg_16(st, ADIS16203_INCL_NULL, &val16); if (ret) return ret; *val = sign_extend32(val16, 13); -- 2.39.1