drivers: entropy: stm32 rng driver should not block if Seed error occurs

When a Seed error occurs during the random nb generation,
the driver tries to recover and exit without providing a random data
This avoids looping endlessly on the DRDY bit of the RNG status reg
because it remains 0 in case of error.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
This commit is contained in:
Francois Ramu 2022-02-22 17:30:42 +01:00 committed by Carles Cufí
commit 8e99151937

View file

@ -361,6 +361,18 @@ static int entropy_stm32_rng_get_entropy_isr(const struct device *dev,
irq_disable(IRQN);
irq_unlock(key);
/* do not proceed if a Seed error occurred */
if (LL_RNG_IsActiveFlag_SECS(entropy_stm32_rng_data.rng) ||
LL_RNG_IsActiveFlag_SEIS(entropy_stm32_rng_data.rng)) {
(void)random_byte_get(); /* this will recover the error */
/* restore irq as we enter */
if (irq_enabled) {
irq_enable(IRQN);
}
return 0; /* return cnt is null : no random data available */
}
/* Clear NVIC pending bit. This ensures that a subsequent
* RNG event will set the Cortex-M single-bit event register
* to 1 (the bit is set when NVIC pending IRQ status is