Skip to content

Commit

Permalink
staging: iio: ad7780: add gain reading to ad778x
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Renato Lui Geh authored and Jonathan Cameron committed Apr 4, 2019
1 parent ae9f86f commit 0149ba2
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions drivers/staging/iio/adc/ad7780.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 0149ba2

Please sign in to comment.