staging: iio: accel: adis16240: Improve readability on write_raw function

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>
This commit is contained in:
Rodrigo Ribeiro 2019-08-13 16:31:01 -03:00 коммит произвёл Jonathan Cameron
Родитель 62ed7a81ef
Коммит b311da85f7
1 изменённых файлов: 1 добавлений и 4 удалений

Просмотреть файл

@ -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;
}