diff options
author | Melissa Wen <melissa.srw@gmail.com> | 2019-06-14 13:32:21 -0300 |
---|---|---|
committer | Jonathan Cameron <Jonathan.Cameron@huawei.com> | 2019-06-17 21:06:48 +0100 |
commit | 34b94f9383138acc892f460bfcb9a35581e048fd (patch) | |
tree | 1dfe8b71455b51036fb06dc1201eabaad9ae21fe /drivers/staging/iio | |
parent | staging: iio: ad7150: use ternary operating to ensure 0/1 value (diff) | |
download | linux-dev-34b94f9383138acc892f460bfcb9a35581e048fd.tar.xz linux-dev-34b94f9383138acc892f460bfcb9a35581e048fd.zip |
staging: iio: ad7150: use FIELD_GET and GENMASK
Use the bitfield macro FIELD_GET, and GENMASK to do the shift and mask in
one go. This makes the code more readable than explicit masking followed
by a shift.
Signed-off-by: Melissa Wen <melissa.srw@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/staging/iio')
-rw-r--r-- | drivers/staging/iio/cdc/ad7150.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/staging/iio/cdc/ad7150.c b/drivers/staging/iio/cdc/ad7150.c index 25598bf124fb..aa750a9178e8 100644 --- a/drivers/staging/iio/cdc/ad7150.c +++ b/drivers/staging/iio/cdc/ad7150.c @@ -5,6 +5,7 @@ * Copyright 2010-2011 Analog Devices Inc. */ +#include <linux/bitfield.h> #include <linux/interrupt.h> #include <linux/device.h> #include <linux/kernel.h> @@ -45,6 +46,9 @@ #define AD7150_SN0 22 #define AD7150_ID 23 +/* AD7150 masks */ +#define AD7150_THRESHTYPE_MSK GENMASK(6, 5) + /** * struct ad7150_chip_info - instance specific chip data * @client: i2c client for this device @@ -137,7 +141,7 @@ static int ad7150_read_event_config(struct iio_dev *indio_dev, if (ret < 0) return ret; - threshtype = (ret >> 5) & 0x03; + threshtype = FIELD_GET(AD7150_THRESHTYPE_MSK, ret); adaptive = !!(ret & 0x80); switch (type) { |