Re: [PATCH] iio: adc: sophgo-saradc: Handle errors from optional IRQ lookup

Jonathan Cameron <[email protected]>
Newsgroups dev.linux.lists.sophgo,org.kernel.vger.linux-iio,org.kernel.vger.linux-kernel
Message-ID <20260822023959.4319f0c3@jic23-huawei>
On Thu, 13 Aug 2026 14:48:10 +0700
[email protected] wrote:

> From: bui duc phuc <[email protected]>
> 
> 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.

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


> 
> Propagate negative errors other than -ENXIO.
> 
> Signed-off-by: bui duc phuc <[email protected]>
> ---
>  drivers/iio/adc/sophgo-cv1800b-adc.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/iio/adc/sophgo-cv1800b-adc.c b/drivers/iio/adc/sophgo-cv1800b-adc.c
> index bdc3e1326a9a..c6eed09acfcd 100644
> --- a/drivers/iio/adc/sophgo-cv1800b-adc.c
> +++ b/drivers/iio/adc/sophgo-cv1800b-adc.c
> @@ -182,6 +182,8 @@ static int cv1800b_adc_probe(struct platform_device *pdev)
>  		return PTR_ERR(saradc->regs);
>  
>  	saradc->irq = platform_get_irq_optional(pdev, 0);
> +	if (saradc->irq < 0 && saradc->irq != -ENXIO)
> +		return saradc->irq;
>  	if (saradc->irq > 0) {
>  		init_completion(&saradc->completion);
>  		ret = devm_request_irq(dev, saradc->irq,
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.