summaryrefslogtreecommitdiffstats
path: root/arch/sandbox/board
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2019-10-21 14:20:46 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2019-10-23 09:06:48 +0200
commit4d4258d24b82ac4316702d173c1e3aaf3d361c35 (patch)
tree98f46c41e80c72913ab082ad02130af8a467743f /arch/sandbox/board
parent040e74a8b6cd316f9553b80aa8b1a7f83672bbed (diff)
downloadbarebox-4d4258d24b82ac4316702d173c1e3aaf3d361c35.tar.gz
barebox-4d4258d24b82ac4316702d173c1e3aaf3d361c35.tar.xz
hwrng: dev-random: always use /dev/urandom
/dev/random can block long after boot time. It seems there's a consensus that /dev/urandom is safe to use except for very early boot, which isn't when barebox sandbox is usually run. To make the HWRNG more useful, always use /dev/urandom. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/sandbox/board')
-rw-r--r--arch/sandbox/board/dev-random.c7
1 files changed, 1 insertions, 6 deletions
diff --git a/arch/sandbox/board/dev-random.c b/arch/sandbox/board/dev-random.c
index f65e5ef6e5..60295e9fce 100644
--- a/arch/sandbox/board/dev-random.c
+++ b/arch/sandbox/board/dev-random.c
@@ -4,10 +4,6 @@
devrandom_t *devrandom_init(void) {
devrandom_t *fds = xzalloc(sizeof(*fds));
- fds->randomfd = linux_open("/dev/random", false);
- if (fds->randomfd < 0)
- return ERR_PTR(-EPERM);
-
fds->urandomfd = linux_open("/dev/urandom", false);
if (fds->urandomfd < 0)
return ERR_PTR(-EPERM);
@@ -17,8 +13,7 @@ devrandom_t *devrandom_init(void) {
int devrandom_read(devrandom_t *devrandom, void *buf, size_t len, int wait)
{
- if (wait)
- return linux_read(devrandom->randomfd, buf, len);
+ (void)wait; /* /dev/urandom won't block */
return linux_read(devrandom->urandomfd, buf, len);
}