public inbox for linux-iio@vger.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Matt Ranostay <matt.ranostay@konsulko.com>
Cc: linux-iio@vger.kernel.org
Subject: Re: [PATCH] iio: chemical: atlas-sensor: add helper function atlas_buffer_num_channels()
Date: Sat, 11 Jan 2020 12:12:58 +0000	[thread overview]
Message-ID: <20200111121258.522d215b@archlinux> (raw)
In-Reply-To: <20200104012908.17020-1-matt.ranostay@konsulko.com>

On Fri,  3 Jan 2020 17:29:08 -0800
Matt Ranostay <matt.ranostay@konsulko.com> wrote:

> 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>

Applied,

Thanks,

Jonathan

> ---
>  drivers/iio/chemical/atlas-sensor.c | 13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)
> 
> 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,


      reply	other threads:[~2020-01-11 12:13 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-04  1:29 [PATCH] iio: chemical: atlas-sensor: add helper function atlas_buffer_num_channels() Matt Ranostay
2020-01-11 12:12 ` Jonathan Cameron [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200111121258.522d215b@archlinux \
    --to=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=matt.ranostay@konsulko.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox