fix(st-crypto): do not read RNG data if it's not ready

Having RNG_SR_DRDY bit in RNG_SR register does not mean that there are 4
RNG words ready to be read. Add a check on RNG_SR_DRDY between each word
reading.

Signed-off-by: Gatien Chevallier <gatien.chevallier@foss.st.com>
Change-Id: I46af7ca6c0ddbe19540b248365a5016b15b9a707
This commit is contained in:
Gatien Chevallier 2023-05-26 15:49:03 +02:00 committed by Yann Gautier
parent 4593e7cbe8
commit 53092a7780

View file

@ -187,6 +187,10 @@ int stm32_rng_read(uint8_t *out, uint32_t size)
count = 4U;
while (len != 0U) {
if ((mmio_read_32(stm32_rng.base + RNG_SR) & RNG_SR_DRDY) == 0U) {
break;
}
data32 = mmio_read_32(stm32_rng.base + RNG_DR);
count--;