Skip to content

Commit b311da8

Browse files
rodrigorsdcJonathan Cameron
authored andcommitted
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>
1 parent 62ed7a8 commit b311da8

1 file changed

Lines changed: 1 addition & 4 deletions

File tree

‎drivers/staging/iio/accel/adis16240.c‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -309,15 +309,12 @@ static int adis16240_write_raw(struct iio_dev *indio_dev,
309309
long mask)
310310
{
311311
struct adis *st = iio_priv(indio_dev);
312-
int bits = 10;
313-
s16 val16;
314312
u8 addr;
315313

316314
switch (mask) {
317315
case IIO_CHAN_INFO_CALIBBIAS:
318-
val16 = val & ((1 << bits) - 1);
319316
addr = adis16240_addresses[chan->scan_index][0];
320-
return adis_write_reg_16(st, addr, val16);
317+
return adis_write_reg_16(st, addr, val & GENMASK(9, 0));
321318
}
322319
return -EINVAL;
323320
}

0 commit comments

Comments
 (0)