Blame view

include/linux/hw_random.h 2.2 KB
844dd05fe   Michael Buesch   [PATCH] Add new g...
1
2
3
4
5
6
7
8
9
10
11
12
13
  /*
  	Hardware Random Number Generator
  
  	Please read Documentation/hw_random.txt for details on use.
  
  	----------------------------------------------------------
  	This software may be used and distributed according to the terms
          of the GNU General Public License, incorporated herein by reference.
  
   */
  
  #ifndef LINUX_HWRANDOM_H_
  #define LINUX_HWRANDOM_H_
844dd05fe   Michael Buesch   [PATCH] Add new g...
14

77584ee57   Herbert Xu   hwrng: core - Use...
15
  #include <linux/completion.h>
844dd05fe   Michael Buesch   [PATCH] Add new g...
16
17
  #include <linux/types.h>
  #include <linux/list.h>
3a2c0ba5a   Rusty Russell   hwrng: use refere...
18
  #include <linux/kref.h>
844dd05fe   Michael Buesch   [PATCH] Add new g...
19
20
21
22
23
24
25
26
  
  /**
   * struct hwrng - Hardware Random Number Generator driver
   * @name:		Unique RNG name.
   * @init:		Initialization callback (can be NULL).
   * @cleanup:		Cleanup callback (can be NULL).
   * @data_present:	Callback to determine if data is available
   *			on the RNG. If NULL, it is assumed that
9996508b3   Ian Molton   hwrng: core - Rep...
27
   *			there is always data available.  *OBSOLETE*
844dd05fe   Michael Buesch   [PATCH] Add new g...
28
29
   * @data_read:		Read data from the RNG device.
   *			Returns the number of lower random bytes in "data".
988acec9e   Sasha Levin   hwrng: fix spelli...
30
   *			Must not be NULL.    *OBSOLETE*
9996508b3   Ian Molton   hwrng: core - Rep...
31
   * @read:		New API. drivers can fill up to max bytes of data
ed0bd721c   Daniel Thompson   hwrng: core - Imp...
32
33
34
   *			into the buffer. The buffer is aligned for any type
   *			and max is guaranteed to be >= to that alignment
   *			(either 4 or 8 depending on architecture).
844dd05fe   Michael Buesch   [PATCH] Add new g...
35
   * @priv:		Private data, for use by the RNG driver.
0f734e6e7   Torsten Duwe   hwrng: add per-de...
36
37
   * @quality:		Estimation of true entropy in RNG's bitstream
   *			(per mill).
844dd05fe   Michael Buesch   [PATCH] Add new g...
38
39
40
41
42
   */
  struct hwrng {
  	const char *name;
  	int (*init)(struct hwrng *rng);
  	void (*cleanup)(struct hwrng *rng);
984e976f5   Patrick McHardy   [HWRNG]: move sta...
43
  	int (*data_present)(struct hwrng *rng, int wait);
844dd05fe   Michael Buesch   [PATCH] Add new g...
44
  	int (*data_read)(struct hwrng *rng, u32 *data);
9996508b3   Ian Molton   hwrng: core - Rep...
45
  	int (*read)(struct hwrng *rng, void *data, size_t max, bool wait);
844dd05fe   Michael Buesch   [PATCH] Add new g...
46
  	unsigned long priv;
0f734e6e7   Torsten Duwe   hwrng: add per-de...
47
  	unsigned short quality;
844dd05fe   Michael Buesch   [PATCH] Add new g...
48
49
50
  
  	/* internal. */
  	struct list_head list;
3a2c0ba5a   Rusty Russell   hwrng: use refere...
51
  	struct kref ref;
77584ee57   Herbert Xu   hwrng: core - Use...
52
  	struct completion cleanup_done;
844dd05fe   Michael Buesch   [PATCH] Add new g...
53
  };
4d9b519c9   Dmitry Torokhov   hwrng: add devm_*...
54
  struct device;
844dd05fe   Michael Buesch   [PATCH] Add new g...
55
56
  /** Register a new Hardware Random Number Generator driver. */
  extern int hwrng_register(struct hwrng *rng);
4d9b519c9   Dmitry Torokhov   hwrng: add devm_*...
57
  extern int devm_hwrng_register(struct device *dev, struct hwrng *rng);
844dd05fe   Michael Buesch   [PATCH] Add new g...
58
  /** Unregister a Hardware Random Number Generator driver. */
b844eba29   Rafael J. Wysocki   PM: Remove destro...
59
  extern void hwrng_unregister(struct hwrng *rng);
4d9b519c9   Dmitry Torokhov   hwrng: add devm_*...
60
  extern void devm_hwrng_unregister(struct device *dve, struct hwrng *rng);
c84dbf61a   Torsten Duwe   random: add_hwgen...
61
62
  /** Feed random bits into the pool. */
  extern void add_hwgenerator_randomness(const char *buffer, size_t count, size_t entropy);
844dd05fe   Michael Buesch   [PATCH] Add new g...
63

844dd05fe   Michael Buesch   [PATCH] Add new g...
64
  #endif /* LINUX_HWRANDOM_H_ */