From abb07089b53862ce5de5316590eb3cf2afa7518e Mon Sep 17 00:00:00 2001 From: Shreeya Patel Date: Thu, 29 Mar 2018 14:51:19 +0530 Subject: [PATCH] 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 Signed-off-by: Jonathan Cameron --- drivers/staging/iio/accel/adis16209.c | 31 ++++++++++++--------------- 1 file 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, -- 2.30.2