Staging: iio: adis16209: Use GENMASK
authorShreeya Patel <shreeya.patel23498@gmail.com>
Thu, 29 Mar 2018 09:21:19 +0000 (14:51 +0530)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Fri, 30 Mar 2018 12:50:35 +0000 (13:50 +0100)
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>
drivers/staging/iio/accel/adis16209.c

index e77c1eed3b67f7ab26e2562ac704f8392792c909..fd1d89cbf50ecd46e4d59b4bc7533f18b1d3ba29 100644 (file)
@@ -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,