From af5dae2e3d25272aec22f919a35968a934367716 Mon Sep 17 00:00:00 2001 From: Przemyslaw Marczak Date: Wed, 19 Feb 2014 17:09:37 +0100 Subject: [PATCH] MAINLINE lib: rand: add call to hw_rand() - hardware random number generator Changes: - lib/rand.c: add call to hw_rand() (depends on CONFIG_RAND_HW_ACCEL) - include/common.h: add hw_rand() declaration. Change-Id: I7439440fd9d20311466c9e3bb8a5512a6da63fb7 Signed-off-by: Przemyslaw Marczak --- include/common.h | 3 +++ lib/rand.c | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/include/common.h b/include/common.h index 15f5834..f67f9c5 100644 --- a/include/common.h +++ b/include/common.h @@ -840,6 +840,9 @@ void srand(unsigned int seed); unsigned int rand(void); unsigned int rand_r(unsigned int *seedp); #endif +#ifdef CONFIG_RAND_HW_ACCEL +unsigned int hw_rand(void); +#endif /* common/console.c */ int console_init_f(void); /* Before relocation; uses the serial stuff */ diff --git a/lib/rand.c b/lib/rand.c index 5c367e1..f534635 100644 --- a/lib/rand.c +++ b/lib/rand.c @@ -23,7 +23,11 @@ unsigned int rand_r(unsigned int *seedp) unsigned int rand(void) { +#ifdef CONFIG_RAND_HW_ACCEL + return hw_rand(); +#else return rand_r(&y); +#endif } void srand(unsigned int seed) -- 2.7.4