iio: adc: stm32: fix stm32h7_adc_enable error handling
commita3b5655ebd
upstream. Error handling in stm32h7_adc_enable routine doesn't unwind enable sequence correctly. ADEN can only be cleared by hardware (e.g. by writing one to ADDIS). It's also better to clear ADRDY just after it's been set by hardware. Fixes:95e339b6e8
("iio: adc: stm32: add support for STM32H7") Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com> Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
2492eca0a0
commit
f4f94e9bae
|
@ -764,8 +764,6 @@ static int stm32h7_adc_enable(struct stm32_adc *adc)
|
|||
int ret;
|
||||
u32 val;
|
||||
|
||||
/* Clear ADRDY by writing one, then enable ADC */
|
||||
stm32_adc_set_bits(adc, STM32H7_ADC_ISR, STM32H7_ADRDY);
|
||||
stm32_adc_set_bits(adc, STM32H7_ADC_CR, STM32H7_ADEN);
|
||||
|
||||
/* Poll for ADRDY to be set (after adc startup time) */
|
||||
|
@ -773,8 +771,11 @@ static int stm32h7_adc_enable(struct stm32_adc *adc)
|
|||
val & STM32H7_ADRDY,
|
||||
100, STM32_ADC_TIMEOUT_US);
|
||||
if (ret) {
|
||||
stm32_adc_clr_bits(adc, STM32H7_ADC_CR, STM32H7_ADEN);
|
||||
stm32_adc_set_bits(adc, STM32H7_ADC_CR, STM32H7_ADDIS);
|
||||
dev_err(&indio_dev->dev, "Failed to enable ADC\n");
|
||||
} else {
|
||||
/* Clear ADRDY by writing one */
|
||||
stm32_adc_set_bits(adc, STM32H7_ADC_ISR, STM32H7_ADRDY);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
|
Loading…
Reference in a new issue