Skip to content

Commit ba580fa

Browse files
committed
drivers: entropy: gecko_trng: Fix blocking behavior
entropy_get_entropy() is allowed to block while waiting for entropy. Don't exit with an error if entropy is exhausted, wait instead. Move clock enable out of the inner loop to avoid unnecessarily calling it multiple times. Upstream-status: available Signed-off-by: Aksel Skauge Mellbye <[email protected]> (cherry picked from commit ad867a1)
1 parent 76b9571 commit ba580fa

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

drivers/entropy/entropy_gecko_trng.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,17 +76,16 @@ static int entropy_gecko_trng_get_entropy(const struct device *dev,
7676

7777
ARG_UNUSED(dev);
7878

79+
#ifdef CONFIG_CRYPTO_ACC_GECKO_TRNG
80+
CMU_ClockEnable(cmuClock_CRYPTOACC, true);
81+
#endif
82+
7983
while (length) {
8084
#ifndef CONFIG_CRYPTO_ACC_GECKO_TRNG
8185
available = TRNG0->FIFOLEVEL * 4;
8286
#else
83-
CMU_ClockEnable(cmuClock_CRYPTOACC, true);
8487
available = S2_FIFO_LEVEL * 4;
8588
#endif
86-
if (available == 0) {
87-
return -EINVAL;
88-
}
89-
9089
count = SL_MIN(length, available);
9190
entropy_gecko_trng_read(buffer, count);
9291
buffer += count;

0 commit comments

Comments
 (0)