From: Jonathan Cameron <jic23@kernel.org>
To: Bui Duc Phuc <phucduc.bui@gmail.com>
Cc: David Lechner <dlechner@baylibre.com>,
nuno.sa@analog.com, Chen Wang <chen.wang@linux.dev>,
Inochi Amaoto <inochiama@gmail.com>,
Takashi Sakamoto <o-takashi@sakamocchi.jp>,
u.kleine-koenig@baylibre.com, Danilo Krummrich <dakr@kernel.org>,
Bjorn Helgaas <bhelgaas@google.com>,
linux-iio@vger.kernel.org, sophgo@lists.linux.dev,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] iio: adc: sophgo-saradc: Handle errors from optional IRQ lookup
Date: Sun, 23 Aug 2026 20:02:49 +0100 [thread overview]
Message-ID: <20260823200249.23a02f47@jic23-huawei> (raw)
In-Reply-To: <CAABR9nFdnFH-gspxEZffAb13_vvrs+x4Ksznq5JFO1gMEmw4_Q@mail.gmail.com>
On Sun, 23 Aug 2026 05:27:21 +0700
Bui Duc Phuc <phucduc.bui@gmail.com> wrote:
> Hi Jonathan,
>
> Thank you for your feedback.
>
> > >
> > > platform_get_irq_optional() returns a positive IRQ number on success or
> > > a negative error code on failure. For an optional IRQ, -ENXIO indicates
> > > that no optional IRQ is available. Other errors, such as -EPROBE_DEFER
> > > and -EINVAL, should be propagated so that the caller can handle them
> > > appropriately.
> >
> > That function is very much undocumented other than not printing a
> > message when it returns an error. However I think you analysis is
> > correct.
> >
>
> Yes, I agree. The documentation for this function may not be clear enough,
> which could have led to error handling being implemented incorrectly
> in some places.
>
> There is also an inconsistency in this driver: if devm_request_irq() fails,
> the error is returned and the probe fails. But if platform_get_irq_optional()
> fails, the error is ignored.
> I'm not sure whether the author misunderstood and assumed that any
> negative return value simply means that there is no IRQ.
If the platform irq get fails because there isn't one in firmware, we expect
to just carry on (no interrupt support). What we are missing is failing when
there is one but we get an error anyway.
For the later devm_request_irq() that is only called if we have an irq
from firmware, but something else goes wrong. That one should definitely
always fail probe as it indicates a probe (rather than lack of interrupt
support)
>
> > I'm not going to rush this is because it is not known to have
> > been a problem in the wild (only odd loading orders should have
> > caused deferal).
> >
>
> I understand your point. However, in this case the error can be
> completely hidden:
> There is no error message or log, the error is not returned, and the
> driver falls back
> to polling:
> -----------------------------------
> if (saradc->irq < 0) {
> u32 reg;
>
> return readl_poll_timeout(saradc->regs + CV1800B_ADC_STATUS_REG,
> reg, !(reg & CV1800B_ADC_BUSY),
> 500, CV1800B_READ_TIMEOUT_US);
> }
> ------------------------------------
>
> So there may never be an obvious failure for a user to report.
Without evidence that there are real setups where interrupt controller
loads late enough to result in a deferral + are used with this chip
I'm fine with the small risk of just using polling in kernels prior
to the fix. Everything still works, just potentially less efficiently.
Jonathan
>
> Best regards,
> Phuc
prev parent reply other threads:[~2026-08-23 19:02 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-13 7:48 [PATCH] iio: adc: sophgo-saradc: Handle errors from optional IRQ lookup phucduc.bui
2026-08-22 1:39 ` Jonathan Cameron
2026-08-22 22:27 ` Bui Duc Phuc
2026-08-23 19:02 ` 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=20260823200249.23a02f47@jic23-huawei \
--to=jic23@kernel.org \
--cc=bhelgaas@google.com \
--cc=chen.wang@linux.dev \
--cc=dakr@kernel.org \
--cc=dlechner@baylibre.com \
--cc=inochiama@gmail.com \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=o-takashi@sakamocchi.jp \
--cc=phucduc.bui@gmail.com \
--cc=sophgo@lists.linux.dev \
--cc=u.kleine-koenig@baylibre.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