summaryrefslogtreecommitdiff
path: root/drivers/staging/iio/adc
diff options
context:
space:
mode:
authorRenato Lui Geh <renatogeh@gmail.com>2019-03-15 23:13:13 -0300
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2019-04-04 20:20:03 +0100
commit0149ba2d5b6d6799e6aeb1ae25773008745c1c5a (patch)
tree9fc8d7ae4713cc566ada7c6bcc75c84c15824c1c /drivers/staging/iio/adc
parentae9f86feb4294864cf7274acae6561ec4d95a7d0 (diff)
staging: iio: ad7780: add gain reading to ad778x
This patch adds a new functionality of reading gain values from the ad778x chips. This value is stored in the chip's state struct and is updated whenever a read or write call is performed on the driver. Signed-off-by: Renato Lui Geh <renatogeh@gmail.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/staging/iio/adc')
-rw-r--r--drivers/staging/iio/adc/ad7780.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/staging/iio/adc/ad7780.c b/drivers/staging/iio/adc/ad7780.c
index 0968a69e537e..abb30c161b00 100644
--- a/drivers/staging/iio/adc/ad7780.c
+++ b/drivers/staging/iio/adc/ad7780.c
@@ -42,6 +42,8 @@
#define AD7780_GAIN_MIDPOINT 64
#define AD7780_FILTER_MIDPOINT 13350
+static const unsigned int ad778x_gain[2] = { 1, 128 };
+
struct ad7780_chip_info {
struct iio_chan_spec channel;
unsigned int pattern_mask;
@@ -179,6 +181,9 @@ static int ad7780_postprocess_sample(struct ad_sigma_delta *sigma_delta,
((raw_sample & chip_info->pattern_mask) != chip_info->pattern))
return -EIO;
+ if (chip_info->is_ad778x)
+ st->gain = ad778x_gain[raw_sample & AD7780_GAIN];
+
return 0;
}