Linux IIO development
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: "David Lechner (TI)" <dlechner@baylibre.com>
Cc: "Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>, "Chris Hall" <c-hall@ti.com>,
	"Patrick Edwards" <pedwards@ti.com>,
	"Kurt Borja" <kuurtb@gmail.com>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] iio: adc: ti-ads112c14: add DRDY interrupt support
Date: Mon, 27 Jul 2026 02:34:03 +0100	[thread overview]
Message-ID: <20260727023403.3b733be7@jic23-huawei> (raw)
In-Reply-To: <20260724-iio-adc-ti-ads112c14-continuous-mode-v1-1-9eb0b7a4f020@baylibre.com>

On Fri, 24 Jul 2026 15:13:10 -0500
"David Lechner (TI)" <dlechner@baylibre.com> wrote:

> Add handling for the DRDY interrupt to wait for data ready events rather
> than polling (only when it is wired up).
> 
> Signed-off-by: David Lechner (TI) <dlechner@baylibre.com>

I'm not sure the comment that I've made will still be true by end
of the various series you've posted but for now the complex
code flow would be simplified by duplicating a couple of lines
and having two helper functions to pick between dependent on whether
we have the drdy interrupt or not.

> ---
> 
> Small note: the hard-coded 100 ms timeout will be replaced in a future
> series with a dynamic value, so I didn't bother with a macro or comments
> to explain why the value was chosen.
> 
> And passing indio_dev instead of data to irq is intentional as it will
> be used in the next patch.
> ---
>  drivers/iio/adc/ti-ads112c14.c | 82 ++++++++++++++++++++++++++++++++++++++----
>  1 file changed, 75 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/iio/adc/ti-ads112c14.c b/drivers/iio/adc/ti-ads112c14.c
> index 8ad8caee0ff7..57e301c15314 100644
> --- a/drivers/iio/adc/ti-ads112c14.c
> +++ b/drivers/iio/adc/ti-ads112c14.c

> +
>  static bool ads112c14_writeable_reg(struct device *dev, unsigned int reg)
>  {
>  	switch (reg) {
> @@ -601,17 +621,33 @@ static int ads112c14_single_conversion(struct ads112c14_data *data,
>  			return ret;
>  	}
>  
> +	if (data->drdy_irq) {
> +		reinit_completion(&data->drdy_completion);
> +		enable_irq(data->drdy_irq);
> +	}
> +
>  	ret = regmap_write(data->regmap, ADS112C14_REG_CONVERSION_CTRL,
>  			   ADS112C14_CONVERSION_CTRL_START);

Given this is basically the only shared code, maybe just split into
two helpers and chose between them?  The outer code in single_conversion
would be shared. I just mean this inner bit to establish we have data.


> -	if (ret)
> +	if (ret) {
> +		if (data->drdy_irq)
> +			disable_irq(data->drdy_irq);
>  		return ret;
> +	}
>  
> -	ret = regmap_read_poll_timeout(data->regmap,
> -				       ADS112C14_REG_STATUS_MSB, reg_val,
> -				       FIELD_GET(ADS112C14_STATUS_MSB_DRDY, reg_val),
> -				       1 * USEC_PER_MSEC, 100 * USEC_PER_MSEC);
> -	if (ret)
> -		return ret;
> +	if (data->drdy_irq) {
> +		ret = wait_for_completion_timeout(&data->drdy_completion,
> +						  msecs_to_jiffies(100));
> +		disable_irq(data->drdy_irq);
> +		if (ret == 0)
> +			return -ETIMEDOUT;
> +	} else {
> +		ret = regmap_read_poll_timeout(data->regmap,
> +					       ADS112C14_REG_STATUS_MSB, reg_val,
> +					       FIELD_GET(ADS112C14_STATUS_MSB_DRDY, reg_val),
> +					       1 * USEC_PER_MSEC, 100 * USEC_PER_MSEC);
> +		if (ret)
> +			return ret;
> +	}

  reply	other threads:[~2026-07-27  1:34 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-24 20:13 [PATCH 0/2] iio: adc: ti-ads112c14: continuous mode support David Lechner (TI)
2026-07-24 20:13 ` [PATCH 1/2] iio: adc: ti-ads112c14: add DRDY interrupt support David Lechner (TI)
2026-07-27  1:34   ` Jonathan Cameron [this message]
2026-07-24 20:13 ` [PATCH 2/2] iio: adc: ti-ads112c14: add continuous mode support David Lechner (TI)
2026-07-27  1:45   ` Jonathan Cameron
2026-07-27 13:45     ` David Lechner
2026-07-27 21:18       ` Jonathan Cameron

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=20260727023403.3b733be7@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=andy@kernel.org \
    --cc=c-hall@ti.com \
    --cc=dlechner@baylibre.com \
    --cc=kuurtb@gmail.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    --cc=pedwards@ti.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