]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - include/linux/hw_random.h
crypto: octeon - enable OCTEON MD5 module selection
[mirror_ubuntu-artful-kernel.git] / include / linux / hw_random.h
CommitLineData
844dd05f
MB
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_
844dd05f
MB
14
15#include <linux/types.h>
16#include <linux/list.h>
3a2c0ba5 17#include <linux/kref.h>
844dd05f
MB
18
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
9996508b 26 * there is always data available. *OBSOLETE*
844dd05f
MB
27 * @data_read: Read data from the RNG device.
28 * Returns the number of lower random bytes in "data".
988acec9 29 * Must not be NULL. *OBSOLETE*
9996508b
IM
30 * @read: New API. drivers can fill up to max bytes of data
31 * into the buffer. The buffer is aligned for any type.
844dd05f 32 * @priv: Private data, for use by the RNG driver.
0f734e6e
TD
33 * @quality: Estimation of true entropy in RNG's bitstream
34 * (per mill).
844dd05f
MB
35 */
36struct hwrng {
37 const char *name;
38 int (*init)(struct hwrng *rng);
39 void (*cleanup)(struct hwrng *rng);
984e976f 40 int (*data_present)(struct hwrng *rng, int wait);
844dd05f 41 int (*data_read)(struct hwrng *rng, u32 *data);
9996508b 42 int (*read)(struct hwrng *rng, void *data, size_t max, bool wait);
844dd05f 43 unsigned long priv;
0f734e6e 44 unsigned short quality;
844dd05f
MB
45
46 /* internal. */
47 struct list_head list;
3a2c0ba5 48 struct kref ref;
a027f30d 49 bool cleanup_done;
844dd05f
MB
50};
51
52/** Register a new Hardware Random Number Generator driver. */
53extern int hwrng_register(struct hwrng *rng);
54/** Unregister a Hardware Random Number Generator driver. */
b844eba2 55extern void hwrng_unregister(struct hwrng *rng);
c84dbf61
TD
56/** Feed random bits into the pool. */
57extern void add_hwgenerator_randomness(const char *buffer, size_t count, size_t entropy);
844dd05f 58
844dd05f 59#endif /* LINUX_HWRANDOM_H_ */