Michael Buesch | 844dd05 | 2006-06-26 00:24:59 -0700 | [diff] [blame] | 1 | /* |
| 2 | Hardware Random Number Generator |
| 3 | |
| 4 | Please read Documentation/hw_random.txt for details on use. |
| 5 | |
| 6 | ---------------------------------------------------------- |
| 7 | This software may be used and distributed according to the terms |
| 8 | of the GNU General Public License, incorporated herein by reference. |
| 9 | |
| 10 | */ |
| 11 | |
| 12 | #ifndef LINUX_HWRANDOM_H_ |
| 13 | #define LINUX_HWRANDOM_H_ |
Michael Buesch | 844dd05 | 2006-06-26 00:24:59 -0700 | [diff] [blame] | 14 | |
| 15 | #include <linux/types.h> |
| 16 | #include <linux/list.h> |
| 17 | |
| 18 | /** |
| 19 | * struct hwrng - Hardware Random Number Generator driver |
| 20 | * @name: Unique RNG name. |
| 21 | * @init: Initialization callback (can be NULL). |
| 22 | * @cleanup: Cleanup callback (can be NULL). |
| 23 | * @data_present: Callback to determine if data is available |
| 24 | * on the RNG. If NULL, it is assumed that |
| 25 | * there is always data available. |
| 26 | * @data_read: Read data from the RNG device. |
| 27 | * Returns the number of lower random bytes in "data". |
| 28 | * Must not be NULL. |
| 29 | * @priv: Private data, for use by the RNG driver. |
| 30 | */ |
| 31 | struct hwrng { |
| 32 | const char *name; |
| 33 | int (*init)(struct hwrng *rng); |
| 34 | void (*cleanup)(struct hwrng *rng); |
Patrick McHardy | 984e976 | 2007-11-21 12:24:45 +0800 | [diff] [blame] | 35 | int (*data_present)(struct hwrng *rng, int wait); |
Michael Buesch | 844dd05 | 2006-06-26 00:24:59 -0700 | [diff] [blame] | 36 | int (*data_read)(struct hwrng *rng, u32 *data); |
| 37 | unsigned long priv; |
| 38 | |
| 39 | /* internal. */ |
| 40 | struct list_head list; |
| 41 | }; |
| 42 | |
| 43 | /** Register a new Hardware Random Number Generator driver. */ |
| 44 | extern int hwrng_register(struct hwrng *rng); |
| 45 | /** Unregister a Hardware Random Number Generator driver. */ |
Rafael J. Wysocki | b844eba | 2008-03-23 20:28:24 +0100 | [diff] [blame] | 46 | extern void hwrng_unregister(struct hwrng *rng); |
Michael Buesch | 844dd05 | 2006-06-26 00:24:59 -0700 | [diff] [blame] | 47 | |
Michael Buesch | 844dd05 | 2006-06-26 00:24:59 -0700 | [diff] [blame] | 48 | #endif /* LINUX_HWRANDOM_H_ */ |