summaryrefslogtreecommitdiff
path: root/drivers/iio/adc/ad7606.h
diff options
context:
space:
mode:
authorStefan Popa <stefan.popa@analog.com>2019-04-02 16:18:39 +0300
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2019-04-14 15:22:29 +0300
commit6bf229abce7528bcf70c62d913eeabfc770ee72c (patch)
treee7498b3a6f01330be9e66f3005ea9770653a6818 /drivers/iio/adc/ad7606.h
parent9044b6e25e2fba8c5586f958da6ff89582d06a3d (diff)
downloadlinux-6bf229abce7528bcf70c62d913eeabfc770ee72c.tar.xz
iio: adc: ad7606: Move oversampling options in chip info and rework *_avail attributes
Available oversampling ratios and scales can be shown by calling a common ad7606_show_avail function which takes as parameters the array which stores the values, together with the size of the array. Oversampling options are now defined in chip info structure and they are loaded at probe. Has_Oversampling attribute was removed because oversampling_num was added and it is not needed anymore. The purpose of this patch is to deal with the scale_avail and oversampling_avail arrays in a generic way. This makes it easier to add support for new devices which will work with different scales and oversampling ratios. It is also an intermediate step for adding support for ad7616 which has different oversampling sampling ratios available. Signed-off-by: Stefan Popa <stefan.popa@analog.com> Signed-off-by: Beniamin Bia <beniamin.bia@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/iio/adc/ad7606.h')
-rw-r--r--drivers/iio/adc/ad7606.h16
1 files changed, 14 insertions, 2 deletions
diff --git a/drivers/iio/adc/ad7606.h b/drivers/iio/adc/ad7606.h
index 5d12410f68e1..8c91bd427c4e 100644
--- a/drivers/iio/adc/ad7606.h
+++ b/drivers/iio/adc/ad7606.h
@@ -12,12 +12,15 @@
* struct ad7606_chip_info - chip specific information
* @channels: channel specification
* @num_channels: number of channels
- * @has_oversampling: whether the device has oversampling support
+ * @oversampling_avail pointer to the array which stores the available
+ * oversampling ratios.
+ * @oversampling_num number of elements stored in oversampling_avail array
*/
struct ad7606_chip_info {
const struct iio_chan_spec *channels;
unsigned int num_channels;
- bool has_oversampling;
+ const unsigned int *oversampling_avail;
+ unsigned int oversampling_num;
};
/**
@@ -29,6 +32,11 @@ struct ad7606_chip_info {
* @range voltage range selection, selects which scale to apply
* @oversampling oversampling selection
* @base_address address from where to read data in parallel operation
+ * @scale_avail pointer to the array which stores the available scales
+ * @num_scales number of elements stored in the scale_avail array
+ * @oversampling_avail pointer to the array which stores the available
+ * oversampling ratios.
+ * @num_os_ratios number of elements stored in oversampling_avail array
* @lock protect sensor state from concurrent accesses to GPIOs
* @gpio_convst GPIO descriptor for conversion start signal (CONVST)
* @gpio_reset GPIO descriptor for device hard-reset
@@ -50,6 +58,10 @@ struct ad7606_state {
unsigned int range;
unsigned int oversampling;
void __iomem *base_address;
+ const unsigned int *scale_avail;
+ unsigned int num_scales;
+ const unsigned int *oversampling_avail;
+ unsigned int num_os_ratios;
struct mutex lock; /* protect sensor state */
struct gpio_desc *gpio_convst;