printf: Remove unused 'bprintf'
[drm/drm-misc.git] / include / linux / hw_random.h
blobb424555753b11f27ecb3a73bf3d773a6460df967
1 /*
2 Hardware Random Number Generator
4 Please read Documentation/admin-guide/hw_random.rst for details on use.
6 ----------------------------------------------------------
7 This software may be used and distributed according to the terms
8 of the GNU General Public License, incorporated herein by reference.
12 #ifndef LINUX_HWRANDOM_H_
13 #define LINUX_HWRANDOM_H_
15 #include <linux/completion.h>
16 #include <linux/kref.h>
17 #include <linux/types.h>
19 /**
20 * struct hwrng - Hardware Random Number Generator driver
21 * @name: Unique RNG name.
22 * @init: Initialization callback (can be NULL).
23 * @cleanup: Cleanup callback (can be NULL).
24 * @data_present: Callback to determine if data is available
25 * on the RNG. If NULL, it is assumed that
26 * there is always data available. *OBSOLETE*
27 * @data_read: Read data from the RNG device.
28 * Returns the number of lower random bytes in "data".
29 * Must not be NULL. *OBSOLETE*
30 * @read: New API. drivers can fill up to max bytes of data
31 * into the buffer. The buffer is aligned for any type
32 * and max is a multiple of 4 and >= 32 bytes.
33 * @priv: Private data, for use by the RNG driver.
34 * @quality: Estimation of true entropy in RNG's bitstream
35 * (in bits of entropy per 1024 bits of input;
36 * valid values: 1 to 1024, or 0 for maximum).
38 struct hwrng {
39 const char *name;
40 int (*init)(struct hwrng *rng);
41 void (*cleanup)(struct hwrng *rng);
42 int (*data_present)(struct hwrng *rng, int wait);
43 int (*data_read)(struct hwrng *rng, u32 *data);
44 int (*read)(struct hwrng *rng, void *data, size_t max, bool wait);
45 unsigned long priv;
46 unsigned short quality;
48 /* internal. */
49 struct list_head list;
50 struct kref ref;
51 struct completion cleanup_done;
52 struct completion dying;
55 struct device;
57 /** Register a new Hardware Random Number Generator driver. */
58 extern int hwrng_register(struct hwrng *rng);
59 extern int devm_hwrng_register(struct device *dev, struct hwrng *rng);
60 /** Unregister a Hardware Random Number Generator driver. */
61 extern void hwrng_unregister(struct hwrng *rng);
62 extern void devm_hwrng_unregister(struct device *dve, struct hwrng *rng);
64 extern long hwrng_msleep(struct hwrng *rng, unsigned int msecs);
65 extern long hwrng_yield(struct hwrng *rng);
67 #endif /* LINUX_HWRANDOM_H_ */