]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
staging: iio: accel: adis16240: Improve readability on write_raw function
authorRodrigo Ribeiro <rodrigorsdc@gmail.com>
Tue, 13 Aug 2019 19:31:01 +0000 (16:31 -0300)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sun, 18 Aug 2019 19:12:52 +0000 (20:12 +0100)
Replace shift and minus operation by GENMASK macro and remove the local
variables used to store intermediate data.

Signed-off-by: Rodrigo Ribeiro Carvalho <rodrigorsdc@gmail.com>
Reviewed-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/staging/iio/accel/adis16240.c

index 62f4b3b1b4572661b38d8459fb050bd1871a4b35..82099db4bf0c6f89db89b17667fe657e62f79edd 100644 (file)
@@ -309,15 +309,12 @@ static int adis16240_write_raw(struct iio_dev *indio_dev,
                               long mask)
 {
        struct adis *st = iio_priv(indio_dev);
-       int bits = 10;
-       s16 val16;
        u8 addr;
 
        switch (mask) {
        case IIO_CHAN_INFO_CALIBBIAS:
-               val16 = val & ((1 << bits) - 1);
                addr = adis16240_addresses[chan->scan_index][0];
-               return adis_write_reg_16(st, addr, val16);
+               return adis_write_reg_16(st, addr, val & GENMASK(9, 0));
        }
        return -EINVAL;
 }