aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iio
diff options
context:
space:
mode:
authorMatt Ranostay <matt.ranostay@konsulko.com>2020-01-03 17:29:08 -0800
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2020-01-12 11:34:16 +0000
commit4766897a9d3bd6af171cdc5ff140e8d132d62d40 (patch)
treedfcc45e0ba2feddc5d7978c895730939adf15897 /drivers/iio
parentiio: humidity: dht11 remove TODO since it doesn't make sense (diff)
downloadlinux-dev-4766897a9d3bd6af171cdc5ff140e8d132d62d40.tar.xz
linux-dev-4766897a9d3bd6af171cdc5ff140e8d132d62d40.zip
iio: chemical: atlas-sensor: add helper function atlas_buffer_num_channels()
Add helper function to detect the number of channels to output in trigger handler. This is based on IIO_TIMESTAMP channel being the delimiter between input and output channels. Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/iio')
-rw-r--r--drivers/iio/chemical/atlas-sensor.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/drivers/iio/chemical/atlas-sensor.c b/drivers/iio/chemical/atlas-sensor.c
index 99095c80531b..2f0a6fed2589 100644
--- a/drivers/iio/chemical/atlas-sensor.c
+++ b/drivers/iio/chemical/atlas-sensor.c
@@ -86,6 +86,16 @@ static const struct regmap_config atlas_regmap_config = {
.val_bits = 8,
};
+static int atlas_buffer_num_channels(const struct iio_chan_spec *spec)
+{
+ int idx = 0;
+
+ for (; spec->type != IIO_TIMESTAMP; spec++)
+ idx++;
+
+ return idx;
+};
+
static const struct iio_chan_spec atlas_ph_channels[] = {
{
.type = IIO_PH,
@@ -354,11 +364,12 @@ static irqreturn_t atlas_trigger_handler(int irq, void *private)
struct iio_poll_func *pf = private;
struct iio_dev *indio_dev = pf->indio_dev;
struct atlas_data *data = iio_priv(indio_dev);
+ int channels = atlas_buffer_num_channels(data->chip->channels);
int ret;
ret = regmap_bulk_read(data->regmap, data->chip->data_reg,
(u8 *) &data->buffer,
- sizeof(__be32) * (data->chip->num_channels - 2));
+ sizeof(__be32) * channels);
if (!ret)
iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,