diff options
author | Himanshu Jha <himanshujha199640@gmail.com> | 2018-03-23 00:42:43 +0530 |
---|---|---|
committer | Jonathan Cameron <Jonathan.Cameron@huawei.com> | 2018-03-24 14:20:13 +0000 |
commit | 15e374daf9037240e2882f54c7b729327b574e30 (patch) | |
tree | 5522dd81297c55e5d9dce265ef597d4e3f2fdbea /drivers/staging | |
parent | d8a6fc1813789afdc99e0c993b18ecf216ff408e (diff) |
Staging: iio: accel: adis16201: Use GENMASK
Use GENMASK to improve readability and remove the local variables used to
store intermediate data.
Signed-off-by: Himanshu Jha <himanshujha199640@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/staging')
-rw-r--r-- | drivers/staging/iio/accel/adis16201.c | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/drivers/staging/iio/accel/adis16201.c b/drivers/staging/iio/accel/adis16201.c index b04dbb35496c..f95d1ea8dc17 100644 --- a/drivers/staging/iio/accel/adis16201.c +++ b/drivers/staging/iio/accel/adis16201.c @@ -185,28 +185,24 @@ static int adis16201_write_raw(struct iio_dev *indio_dev, long mask) { struct adis *st = iio_priv(indio_dev); - int bits; - s16 val16; - u8 addr; + int m; - switch (mask) { - case IIO_CHAN_INFO_CALIBBIAS: - switch (chan->type) { - case IIO_ACCEL: - bits = 12; - break; - case IIO_INCLI: - bits = 9; - break; - default: - return -EINVAL; - } - val16 = val & ((1 << bits) - 1); - addr = adis16201_addresses[chan->scan_index]; - return adis_write_reg_16(st, addr, val16); + if (mask != IIO_CHAN_INFO_CALIBBIAS) + return -EINVAL; + + switch (chan->type) { + case IIO_ACCEL: + m = GENMASK(11, 0); + break; + case IIO_INCLI: + m = GENMASK(8, 0); + break; + default: + return -EINVAL; } - return -EINVAL; + return adis_write_reg_16(st, adis16201_addresses[chan->scan_index], + val & m); } static const struct iio_chan_spec adis16201_channels[] = { |