summaryrefslogtreecommitdiffstats
path: root/drivers/staging/iio/accel
diff options
context:
space:
mode:
authorShreeya Patel <shreeya.patel23498@gmail.com>2018-03-29 14:51:19 +0530
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2018-03-30 13:50:35 +0100
commitabb07089b53862ce5de5316590eb3cf2afa7518e (patch)
tree52d555d3ec7b8ccc4fceedd26de5a3322066af2a /drivers/staging/iio/accel
parent11b2ffbbc3d4d73ef33f479d1b5b3d1d51485d85 (diff)
downloadlinux-abb07089b53862ce5de5316590eb3cf2afa7518e.tar.gz
linux-abb07089b53862ce5de5316590eb3cf2afa7518e.tar.bz2
linux-abb07089b53862ce5de5316590eb3cf2afa7518e.zip
Staging: iio: adis16209: Use GENMASK
Use GENMASK to improve readability and remove the local variables used to store intermediate data. Signed-off-by: Shreeya Patel <shreeya.patel23498@gmail.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/staging/iio/accel')
-rw-r--r--drivers/staging/iio/accel/adis16209.c31
1 files changed, 14 insertions, 17 deletions
diff --git a/drivers/staging/iio/accel/adis16209.c b/drivers/staging/iio/accel/adis16209.c
index e77c1eed3b67..fd1d89cbf50e 100644
--- a/drivers/staging/iio/accel/adis16209.c
+++ b/drivers/staging/iio/accel/adis16209.c
@@ -112,25 +112,22 @@ static int adis16209_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:
- case IIO_INCLI:
- bits = 14;
- break;
- default:
- return -EINVAL;
- }
- val16 = val & ((1 << bits) - 1);
- addr = adis16209_addresses[chan->scan_index][0];
- return adis_write_reg_16(st, addr, val16);
+ if (mask != IIO_CHAN_INFO_CALIBBIAS)
+ return -EINVAL;
+
+ switch (chan->type) {
+ case IIO_ACCEL:
+ case IIO_INCLI:
+ m = GENMASK(13, 0);
+ break;
+ default:
+ return -EINVAL;
}
- return -EINVAL;
+
+ return adis_write_reg_16(st, adis16209_addresses[chan->scan_index][0],
+ val & m);
}
static int adis16209_read_raw(struct iio_dev *indio_dev,