[PATCH v5 12/16] iio: adc: xilinx-xadc: Refine Zynq read/write error handling on timeout/interrupt

Andy Shevchenko andriy.shevchenko at intel.com
Tue Nov 10 08:21:56 PST 2026


On Tue, Nov 10, 2026 at 10:31:57AM +0530, Dileep Kumar Nagavarapu wrote:
> Refine the error codes returned from the wait, the same way in both
> xadc_zynq_write_adc_reg() and xadc_zynq_read_adc_reg(): a timeout
> (ret == 0) now returns -ETIMEDOUT instead of the previous -EIO,
> giving a more precise errno for this condition. An interrupted wait
> (ret < 0) now propagates that error to the caller instead of being
> silently treated as success.
> 
> xadc_zynq_write_adc_reg() waits on xadc->completion after issuing the
> Zynq DRP write command, then drains the response word from
> XADC_ZYNQ_REG_DFIFO. The DFIFO read already ran unconditionally after
> the wait, regardless of outcome.

...

>  	ret = wait_for_completion_interruptible_timeout(&xadc->completion, HZ);
> -	if (ret == 0)
> -		ret = -EIO;
> -	else
> -		ret = 0;
>  
>  	xadc_read_reg(xadc, XADC_ZYNQ_REG_DFIFO, &tmp);
>  
> -	return ret;
> +	if (ret == 0)
> +		return -ETIMEDOUT;
> +
> +	if (ret < 0)
> +		return ret;

First check for generic errors, then for exclusive conditions ( == 0).

> +	return 0;

...

>  	ret = wait_for_completion_interruptible_timeout(&xadc->completion, HZ);
>  	if (ret == 0)
> -		ret = -EIO;
> +		return -ETIMEDOUT;
> +
>  	if (ret < 0)
>  		return ret;

Ditto.

-- 
With Best Regards,
Andy Shevchenko





More information about the linux-arm-kernel mailing list