summaryrefslogtreecommitdiff
path: root/src/arch/x86/rdrand.c
diff options
context:
space:
mode:
authorElyes Haouas <ehaouas@noos.fr>2022-11-08 14:38:41 +0100
committerFelix Singer <felixsinger@posteo.net>2022-12-25 15:09:16 +0000
commit9523e3b7905a3c20214b8af4bacd50abe178eded (patch)
treec2a9ea9438b0d4d1f4c18bcaaccb845bf4b899b6 /src/arch/x86/rdrand.c
parent70191da272222217cb208ed0972cf4ddb78881f8 (diff)
arch/x86: Use 'enum cb_err'
Change-Id: I38e4b8c6adfaaa45377b2fbe0644285d21841cd1 Signed-off-by: Elyes Haouas <ehaouas@noos.fr> Reviewed-on: https://review.coreboot.org/c/coreboot/+/68369 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Martin L Roth <gaumless@gmail.com> Reviewed-by: Felix Singer <felixsinger@posteo.net>
Diffstat (limited to 'src/arch/x86/rdrand.c')
-rw-r--r--src/arch/x86/rdrand.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/arch/x86/rdrand.c b/src/arch/x86/rdrand.c
index 985aeba6c1..31958dba7f 100644
--- a/src/arch/x86/rdrand.c
+++ b/src/arch/x86/rdrand.c
@@ -1,7 +1,7 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#include <random.h>
-#include <stdint.h>
+#include <types.h>
/*
* Intel recommends that applications attempt 10 retries in a tight loop
@@ -41,19 +41,19 @@ static inline uint8_t rdrand_64(uint64_t *rand)
}
#endif
-int get_random_number_32(uint32_t *rand)
+enum cb_err get_random_number_32(uint32_t *rand)
{
int i;
/* Perform a loop call until RDRAND succeeds or returns failure. */
for (i = 0; i < RDRAND_RETRY_LOOPS; i++) {
if (rdrand_32(rand))
- return 0;
+ return CB_SUCCESS;
}
- return -1;
+ return CB_ERR;
}
-int get_random_number_64(uint64_t *rand)
+enum cb_err get_random_number_64(uint64_t *rand)
{
int i;
uint32_t rand_high, rand_low;
@@ -62,13 +62,13 @@ int get_random_number_64(uint64_t *rand)
for (i = 0; i < RDRAND_RETRY_LOOPS; i++) {
#if ENV_X86_64
if (rdrand_64(rand))
- return 0;
+ return CB_SUCCESS;
#endif
if (rdrand_32(&rand_high) && rdrand_32(&rand_low)) {
*rand = ((uint64_t)rand_high << 32) |
(uint64_t)rand_low;
- return 0;
+ return CB_SUCCESS;
}
}
- return -1;
+ return CB_ERR;
}