iio: adc: ti-adc12138: fail init on calibration timeout
PATCH 1/1 iio: adc: ti-adc12138: fail init on calibration timeout
adc12138_init() starts device calibration and waits for the EOC interrupt before checking the calibration status. The wait helper returns -ETIMEDOUT if the interrupt does not arrive in time, but the init path ignores the error and continues probing the device. This could lead to registering the device even tho it may not be properly initialized.
Return the wait error so probe fails cleanly when calibration does not complete.
--- drivers/iio/adc/ti-adc12138.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/iio/adc/ti-adc12138.c +5 -1
@@ -300,7 +300,11 @@ static int adc12138_init(struct adc12138 *adc)if (status <0 )return status; -adc12138_wait_eoc (adc,msecs_to_jiffies (100 )); + ret =adc12138_wait_eoc (adc,msecs_to_jiffies (100 )); +if (ret) { +dev_warn (&adc->spi->dev,"wait eoc timeout\n" ); +return ret; + } status =adc12138_read_status (adc);if (status &ADC12138_STATUS_CAL ) {
--
2.54.0
Quoted 9 lines · Prashant Rahul
adc12138_init()starts device calibration and waits for the EOC interrupt before checking the calibration status. The wait helper returns-ETIMEDOUTif the interrupt does not arrive in time, but the init path ignores the error and continues probing the device. This could lead to registering the device even tho it may not be properly initialized.Return the wait error so probe fails cleanly when calibration does not complete.
After the timeout, the driver checks the status. If the calibration is not complete, it already returns an error with the appropriate information. I would expect that error is preferrable to a context-less "wait eoc timeout".
John Ogness
Quoted 4 lines · John Ogness
After the timeout, the driver checks the status. If the calibration is not complete, it already returns an error with the appropriate information. I would expect that error is preferrable to a context-less "wait eoc timeout".
I agree with you. Apologies for not realising that earlier. Thank you for pointing it you.
Quoted 9 lines · Prashant Rahul
adc12138_init()starts device calibration and waits for the EOC interrupt before checking the calibration status. The wait helper returns-ETIMEDOUTif the interrupt does not arrive in time, but the init path ignores the error and continues probing the device. This could lead to registering the device even tho it may not be properly initialized.Return the wait error so probe fails cleanly when calibration does not complete.
...
drivers/iio/adc/ti-adc12138.c static int adc12138_init(struct adc12138 *adc)
Quoted 5 lines
drivers/iio/adc/ti-adc12138.c +4
-0+ ret =adc12138_wait_eoc (adc,msecs_to_jiffies (100 )); +if (ret) { +dev_warn (&adc->spi->dev,"wait eoc timeout\n" ); +return ret;
return dev_warn_probe(...);
Quoted 1 line
drivers/iio/adc/ti-adc12138.c +1
-0+ }
Signature · 2 lines
With Best Regards, Andy Shevchenko