diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2022-10-13 13:57:07 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2022-10-13 13:57:07 +0200 |
commit | 3d46afb56fa3c5e3c41a382dc454b5bcda04d5ac (patch) | |
tree | 957de9cbc6a68e82c84ae26cc4712c3e86dfc964 /lib | |
parent | 965a946c49e016bcff5bbfffaa1a468cd74af0db (diff) | |
parent | 8513703c6c46428908264923260504ce81e3e3a7 (diff) | |
download | barebox-3d46afb56fa3c5e3c41a382dc454b5bcda04d5ac.tar.gz barebox-3d46afb56fa3c5e3c41a382dc454b5bcda04d5ac.tar.xz |
Merge branch 'for-next/misc'
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libfile.c | 6 | ||||
-rw-r--r-- | lib/logo/Makefile | 2 | ||||
-rw-r--r-- | lib/random.c | 25 |
3 files changed, 16 insertions, 17 deletions
diff --git a/lib/libfile.c b/lib/libfile.c index 3b7985fbca..b967232d19 100644 --- a/lib/libfile.c +++ b/lib/libfile.c @@ -387,7 +387,7 @@ int copy_file(const char *src, const char *dst, int verbose) srcfd = open(src, O_RDONLY); if (srcfd < 0) { - printf("could not open %s: %s\n", src, errno_str()); + printf("could not open %s: %m\n", src); ret = srcfd; goto out; } @@ -396,7 +396,7 @@ int copy_file(const char *src, const char *dst, int verbose) s = stat(dst, &dststat); if (s && s != -ENOENT) { - printf("could not stat %s: %s\n", dst, errno_str()); + printf("could not stat %s: %m\n", dst); ret = s; goto out; } @@ -407,7 +407,7 @@ int copy_file(const char *src, const char *dst, int verbose) dstfd = open(dst, mode); if (dstfd < 0) { - printf("could not open %s: %s\n", dst, errno_str()); + printf("could not open %s: %m\n", dst); ret = dstfd; goto out; } diff --git a/lib/logo/Makefile b/lib/logo/Makefile index d076a19a76..382701fb36 100644 --- a/lib/logo/Makefile +++ b/lib/logo/Makefile @@ -25,7 +25,7 @@ obj-$(CONFIG_BAREBOX_LOGO) += logo.o quiet_cmd_logo_S = LOGO.S $@ cmd_logo_S = \ ( \ - echo '\#include <asm-generic/barebox.lds.h>'; \ + echo '\#include <asm/barebox.lds.h>'; \ echo '.section .bblogo.rodata.$(subst -,_,$(*F)),"a"'; \ echo '.balign STRUCT_ALIGNMENT'; \ echo '.global __bblogo_$(subst -,_,$(*F))_start'; \ diff --git a/lib/random.c b/lib/random.c index fb3580f9c0..c6532df552 100644 --- a/lib/random.c +++ b/lib/random.c @@ -34,17 +34,8 @@ void get_random_bytes(void *_buf, int len) *buf++ = rand() % 256; } -/** - * get_crypto_bytes - get random numbers suitable for cryptographic needs. - */ -static int _get_crypto_bytes(void *buf, int len) +int hwrng_get_crypto_bytes(struct hwrng *rng, void *buf, int len) { - struct hwrng *rng; - - rng = hwrng_get_first(); - if (IS_ERR(rng)) - return PTR_ERR(rng); - while (len) { int bytes = hwrng_get_data(rng, buf, len, true); if (!bytes) @@ -60,13 +51,21 @@ static int _get_crypto_bytes(void *buf, int len) return 0; } +/** + * get_crypto_bytes - get random numbers suitable for cryptographic needs. + */ int get_crypto_bytes(void *buf, int len) { + struct hwrng *rng; int err; - err = _get_crypto_bytes(buf, len); - if (!err) - return 0; + rng = hwrng_get_first(); + err = PTR_ERR_OR_ZERO(rng); + if (!err) { + err = hwrng_get_crypto_bytes(rng, buf, len); + if (!err) + return 0; + } if (!IS_ENABLED(CONFIG_ALLOW_PRNG_FALLBACK)) { pr_err("error: no HWRNG available!\n"); |