![]() |
|
|||
0001 /* 0002 Hardware Random Number Generator 0003 0004 Please read Documentation/admin-guide/hw_random.rst for details on use. 0005 0006 ---------------------------------------------------------- 0007 This software may be used and distributed according to the terms 0008 of the GNU General Public License, incorporated herein by reference. 0009 0010 */ 0011 0012 #ifndef LINUX_HWRANDOM_H_ 0013 #define LINUX_HWRANDOM_H_ 0014 0015 #include <linux/completion.h> 0016 #include <linux/types.h> 0017 #include <linux/list.h> 0018 #include <linux/kref.h> 0019 0020 /** 0021 * struct hwrng - Hardware Random Number Generator driver 0022 * @name: Unique RNG name. 0023 * @init: Initialization callback (can be NULL). 0024 * @cleanup: Cleanup callback (can be NULL). 0025 * @data_present: Callback to determine if data is available 0026 * on the RNG. If NULL, it is assumed that 0027 * there is always data available. *OBSOLETE* 0028 * @data_read: Read data from the RNG device. 0029 * Returns the number of lower random bytes in "data". 0030 * Must not be NULL. *OBSOLETE* 0031 * @read: New API. drivers can fill up to max bytes of data 0032 * into the buffer. The buffer is aligned for any type 0033 * and max is a multiple of 4 and >= 32 bytes. 0034 * @priv: Private data, for use by the RNG driver. 0035 * @quality: Estimation of true entropy in RNG's bitstream 0036 * (in bits of entropy per 1024 bits of input; 0037 * valid values: 1 to 1024, or 0 for unknown). 0038 */ 0039 struct hwrng { 0040 const char *name; 0041 int (*init)(struct hwrng *rng); 0042 void (*cleanup)(struct hwrng *rng); 0043 int (*data_present)(struct hwrng *rng, int wait); 0044 int (*data_read)(struct hwrng *rng, u32 *data); 0045 int (*read)(struct hwrng *rng, void *data, size_t max, bool wait); 0046 unsigned long priv; 0047 unsigned short quality; 0048 0049 /* internal. */ 0050 struct list_head list; 0051 struct kref ref; 0052 struct completion cleanup_done; 0053 }; 0054 0055 struct device; 0056 0057 /** Register a new Hardware Random Number Generator driver. */ 0058 extern int hwrng_register(struct hwrng *rng); 0059 extern int devm_hwrng_register(struct device *dev, struct hwrng *rng); 0060 /** Unregister a Hardware Random Number Generator driver. */ 0061 extern void hwrng_unregister(struct hwrng *rng); 0062 extern void devm_hwrng_unregister(struct device *dve, struct hwrng *rng); 0063 0064 #endif /* LINUX_HWRANDOM_H_ */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |