Commit abb07089 authored by Shreeya Patel's avatar Shreeya Patel Committed by Jonathan Cameron

Staging: iio: adis16209: Use GENMASK

Use GENMASK to improve readability and remove the local
variables used to store intermediate data.
Signed-off-by: default avatarShreeya Patel <shreeya.patel23498@gmail.com>
Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent 11b2ffbb
...@@ -112,25 +112,22 @@ static int adis16209_write_raw(struct iio_dev *indio_dev, ...@@ -112,25 +112,22 @@ static int adis16209_write_raw(struct iio_dev *indio_dev,
long mask) long mask)
{ {
struct adis *st = iio_priv(indio_dev); struct adis *st = iio_priv(indio_dev);
int bits; int m;
s16 val16;
u8 addr;
switch (mask) { if (mask != IIO_CHAN_INFO_CALIBBIAS)
case IIO_CHAN_INFO_CALIBBIAS: return -EINVAL;
switch (chan->type) {
case IIO_ACCEL: switch (chan->type) {
case IIO_INCLI: case IIO_ACCEL:
bits = 14; case IIO_INCLI:
break; m = GENMASK(13, 0);
default: break;
return -EINVAL; default:
} return -EINVAL;
val16 = val & ((1 << bits) - 1);
addr = adis16209_addresses[chan->scan_index][0];
return adis_write_reg_16(st, addr, val16);
} }
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, static int adis16209_read_raw(struct iio_dev *indio_dev,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment