The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Jonathan Cameron <jic23@kernel.org>
Cc: linux-iio@vger.kernel.org,
	"David Lechner" <dlechner@baylibre.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	linux-kernel@vger.kernel.org,
	"Jonathan Cameron" <jonathan.cameron@oss.qualcomm.com>
Subject: Re: [PATCH] iio: adc: max1027: complete the EOC wait when using an external trigger
Date: Mon, 23 Nov 2026 09:51:07 +0100	[thread overview]
Message-ID: <87mrr0ue10.fsf@bootlin.com> (raw)
In-Reply-To: <20261122195249.13ee9686@jic23-hlaptop> (Jonathan Cameron's message of "Sun, 22 Nov 2026 19:52:49 +0000")

On 22/11/2026 at 19:52:49 GMT, Jonathan Cameron <jic23@kernel.org> wrote:

> On Tue, 17 Nov 2026 11:52:46 +0100
> Miquel Raynal <miquel.raynal@bootlin.com> wrote:
>
>> Hi Jonathan,
>> 
>> On 15/11/2026 at 20:45:51 GMT, Jonathan Cameron <jic23@kernel.org> wrote:
>> 
>> > From: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
>> >
>> > When an external trigger is in use, max1027_trigger_handler() starts the
>> > conversion and then waits in max1027_wait_eoc() for the end of conversion
>> > interrupt to complete(&st->complete). However max1027_handler() only
>> > completes it when the buffer is disabled. With the buffer enabled it
>> > instead polls the current trigger, which is the external trigger
>> > that is still being handled, so the poll does nothing,
>> > the wait times out and every sample fails with -ETIMEDOUT.
>> >
>> > Complete the wait when the buffer is enabled but the device's own
>> > trigger is not in use, as the comment above the check already
>> > describes.
>> >
>> > Fixes: 075d3280b4a1 ("iio: adc: max1027: Allow all kind of triggers to be used")
>> > Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
>> >
>> > ---
>> >
>> > The comment clearly states that we should just complete for
>> > triggers other than the one provided by this device, but the
>> > code doesn't do this. Ideal would be if someone has the part and
>> > can test this.  
>> 
>> I no longer have an easy way to run that code, but looking at it 5 years
>> later, I agree with your description of the problem as well as your
>> solution.
>> 
>> > LLM spotted the issue whilst doing some other cleanup and
>> > prepared the patch.
>> >
>> > I think the reason this got past testing was that the code was
>> > fixed to actually return an error on timeout whereas a bug
>> > previously meant it always dropped through and carried on.  
>> 
>> Ah, right, intersting, I guess you talk about
>> 2021ef060900 ("iio: adc: max1027: fix error code in max1027_wait_eoc()")
>> 
>> > ---
>> >  drivers/iio/adc/max1027.c | 2 +-
>> >  1 file changed, 1 insertion(+), 1 deletion(-)
>> >
>> > diff --git a/drivers/iio/adc/max1027.c b/drivers/iio/adc/max1027.c
>> > index d475cc91108d..65a0e85faca9 100644
>> > --- a/drivers/iio/adc/max1027.c
>> > +++ b/drivers/iio/adc/max1027.c
>> > @@ -478,7 +478,7 @@ static irqreturn_t max1027_handler(int irq, void *private)
>> >  	 * with another device. The core will then call the relevant handler to
>> >  	 * perform the data processing step.
>> >  	 */
>> > -	if (!iio_buffer_enabled(indio_dev))
>> > +	if (!iio_buffer_enabled(indio_dev) || !iio_trigger_using_own(indio_dev))
>> >  		complete(&st->complete);
>> >  	else
>> >  		iio_trigger_poll(st->trig);  
>> 
>> In case you want to make it closer to what other drivers do, you may
>> invert the condition to simplify the reading:
>> 
>> 	if (iio_buffer_enabled(indio_dev) && iio_trigger_using_own(indio_dev))
>>   		iio_trigger_poll(st->trig);
>>   	else
>>   		complete(&st->complete);
> That is indeed more natural so done what you suggest and applied.
> We are fairly late in the cycle so I'm not going to rush this in.
>
> Applied to the testing branch of iio.git, so targeting next merge
> window.

At -rc4? There is still a month before the merge window, for such a
small change located in a driver, I would not bother delaying it :-)

Cheers,
Miquèl

      reply	other threads:[~2026-11-23  8:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-15 20:45 [PATCH] iio: adc: max1027: complete the EOC wait when using an external trigger Jonathan Cameron
2026-11-17 10:52 ` Miquel Raynal
2026-11-22 19:52   ` Jonathan Cameron
2026-11-23  8:51     ` Miquel Raynal [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=87mrr0ue10.fsf@bootlin.com \
    --to=miquel.raynal@bootlin.com \
    --cc=andy@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=jic23@kernel.org \
    --cc=jonathan.cameron@oss.qualcomm.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.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