hw_random.h 1.4 KB

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