hw_random.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. #include <linux/types.h>
  11. #include <linux/list.h>
  12. /**
  13. * struct hwrng - Hardware Random Number Generator driver
  14. * @name: Unique RNG name.
  15. * @init: Initialization callback (can be NULL).
  16. * @cleanup: Cleanup callback (can be NULL).
  17. * @data_present: Callback to determine if data is available
  18. * on the RNG. If NULL, it is assumed that
  19. * there is always data available. *OBSOLETE*
  20. * @data_read: Read data from the RNG device.
  21. * Returns the number of lower random bytes in "data".
  22. * Must not be NULL. *OBSOLETE*
  23. * @read: New API. drivers can fill up to max bytes of data
  24. * into the buffer. The buffer is aligned for any type.
  25. * @priv: Private data, for use by the RNG driver.
  26. */
  27. struct hwrng {
  28. const char *name;
  29. int (*init)(struct hwrng *rng);
  30. void (*cleanup)(struct hwrng *rng);
  31. int (*data_present)(struct hwrng *rng, int wait);
  32. int (*data_read)(struct hwrng *rng, u32 *data);
  33. int (*read)(struct hwrng *rng, void *data, size_t max, bool wait);
  34. unsigned long priv;
  35. /* internal. */
  36. struct list_head list;
  37. };
  38. /** Register a new Hardware Random Number Generator driver. */
  39. extern int hwrng_register(struct hwrng *rng);
  40. /** Unregister a Hardware Random Number Generator driver. */
  41. extern void hwrng_unregister(struct hwrng *rng);
  42. #endif /* LINUX_HWRANDOM_H_ */