Commit 15e374da authored by Himanshu Jha's avatar Himanshu Jha Committed by Jonathan Cameron

Staging: iio: accel: adis16201: Use GENMASK

Use GENMASK to improve readability and remove the local variables used to
store intermediate data.
Signed-off-by: default avatarHimanshu Jha <himanshujha199640@gmail.com>
Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent d8a6fc18
...@@ -185,28 +185,24 @@ static int adis16201_write_raw(struct iio_dev *indio_dev, ...@@ -185,28 +185,24 @@ static int adis16201_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) {
bits = 12; case IIO_ACCEL:
break; m = GENMASK(11, 0);
case IIO_INCLI: break;
bits = 9; case IIO_INCLI:
break; m = GENMASK(8, 0);
default: break;
return -EINVAL; default:
} return -EINVAL;
val16 = val & ((1 << bits) - 1);
addr = adis16201_addresses[chan->scan_index];
return adis_write_reg_16(st, addr, val16);
} }
return -EINVAL; return adis_write_reg_16(st, adis16201_addresses[chan->scan_index],
val & m);
} }
static const struct iio_chan_spec adis16201_channels[] = { static const struct iio_chan_spec adis16201_channels[] = {
......
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