diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2017-04-07 09:59:29 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2017-04-07 09:59:29 +0200 |
commit | 4ef8ec1a48e2d4e459d4b2232970026bffaeb4aa (patch) | |
tree | 06c13993a65284257e8365e2b60b0c7cba93d930 /include | |
parent | f07295645358b59a7446421bb5c74a69d41fc96a (diff) | |
parent | b0a0d7c05dde1476b249aa8d6d36de0189e9eeab (diff) | |
download | barebox-4ef8ec1a48e2d4e459d4b2232970026bffaeb4aa.tar.gz barebox-4ef8ec1a48e2d4e459d4b2232970026bffaeb4aa.tar.xz |
Merge branch 'for-next/hwrng'
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/hw_random.h | 47 | ||||
-rw-r--r-- | include/stdlib.h | 1 |
2 files changed, 48 insertions, 0 deletions
diff --git a/include/linux/hw_random.h b/include/linux/hw_random.h new file mode 100644 index 0000000000..bae442166c --- /dev/null +++ b/include/linux/hw_random.h @@ -0,0 +1,47 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#ifndef LINUX_HWRANDOM_H_ +#define LINUX_HWRANDOM_H_ + +#include <linux/list.h> + +/** + * struct hwrng - Hardware Random Number Generator driver + * @name: Unique RNG name. + * @init: Initialization callback (can be NULL). + * @read: New API. drivers can fill up to max bytes of data + * into the buffer. The buffer is aligned for any type. + */ +struct hwrng { + const char *name; + int (*init)(struct hwrng *rng); + int (*read)(struct hwrng *rng, void *data, size_t max, bool wait); + + struct list_head list; + + struct cdev cdev; + struct device_d *dev; + void *buf; +}; + +/* Register a new Hardware Random Number Generator driver. */ +int hwrng_register(struct device_d *dev, struct hwrng *rng); +int hwrng_get_data(struct hwrng *rng, void *buffer, size_t size, int wait); + +#ifdef CONFIG_HWRNG +struct hwrng *hwrng_get_first(void); +#else +static inline struct hwrng *hwrng_get_first(void) { return ERR_PTR(-ENODEV); }; +#endif + +#endif /* LINUX_HWRANDOM_H_ */ diff --git a/include/stdlib.h b/include/stdlib.h index f3185069f3..ee3f229968 100644 --- a/include/stdlib.h +++ b/include/stdlib.h @@ -13,6 +13,7 @@ void srand(unsigned int seed); /* fill a buffer with pseudo-random data */ void get_random_bytes(void *buf, int len); +int get_crypto_bytes(void *buf, int len); static inline u32 random32(void) { |