[kernel] backport r21373 to 2.4 kernel
[openwrt.git] / target / linux / generic-2.4 / patches / 901-ocf-20100325.patch
1 --- a/drivers/char/random.c
2 +++ b/drivers/char/random.c
3 @@ -901,6 +901,65 @@ void add_blkdev_randomness(int major)
4 #define subRound(a, b, c, d, e, f, k, data) \
5 ( e += ROTL( 5, a ) + f( b, c, d ) + k + data, b = ROTL( 30, b ) )
6
7 +/*
8 + * random_input_words - add bulk entropy to pool
9 + *
10 + * @buf: buffer to add
11 + * @wordcount: number of __u32 words to add
12 + * @ent_count: total amount of entropy (in bits) to credit
13 + *
14 + * this provides bulk input of entropy to the input pool
15 + *
16 + */
17 +void random_input_words(__u32 *buf, size_t wordcount, int ent_count)
18 +{
19 + if (!random_state)
20 + return;
21 + add_entropy_words(random_state, buf, wordcount);
22 +
23 + credit_entropy_store(random_state, ent_count);
24 +
25 + DEBUG_ENT("credited %d bits => %d\n",
26 + ent_count, random_state->entropy_count);
27 + /*
28 + * Wake up waiting processes if we have enough
29 + * entropy.
30 + */
31 + if (random_state->entropy_count >= random_read_wakeup_thresh)
32 + wake_up_interruptible(&random_read_wait);
33 +}
34 +EXPORT_SYMBOL(random_input_words);
35 +
36 +/*
37 + * random_input_wait - wait until random needs entropy
38 + *
39 + * this function sleeps until the /dev/random subsystem actually
40 + * needs more entropy, and then return the amount of entropy
41 + * that it would be nice to have added to the system.
42 + */
43 +int random_input_wait(void)
44 +{
45 + int count;
46 +
47 + if (!random_state)
48 + return -1;
49 +
50 + wait_event_interruptible(random_write_wait,
51 + random_state->entropy_count < random_write_wakeup_thresh);
52 +
53 + count = random_write_wakeup_thresh - random_state->entropy_count;
54 +
55 + /* likely we got woken up due to a signal */
56 + if (count <= 0) count = random_read_wakeup_thresh;
57 +
58 + DEBUG_ENT("requesting %d bits from input_wait()er %d<%d\n",
59 + count,
60 + random_state->entropy_count, random_write_wakeup_thresh);
61 +
62 + return count;
63 +}
64 +EXPORT_SYMBOL(random_input_wait);
65 +
66
67 static void SHATransform(__u32 digest[85], __u32 const data[16])
68 {
69 --- a/fs/Makefile
70 +++ b/fs/Makefile
71 @@ -10,6 +10,8 @@ O_TARGET := fs.o
72 export-objs := filesystems.o open.o dcache.o buffer.o dquot.o
73 mod-subdirs := nls
74
75 +export-objs += fcntl.o
76 +
77 obj-y := open.o read_write.o devices.o file_table.o buffer.o \
78 super.o block_dev.o char_dev.o stat.o exec.o pipe.o namei.o \
79 fcntl.o ioctl.o readdir.o select.o fifo.o locks.o \
80 --- a/fs/fcntl.c
81 +++ b/fs/fcntl.c
82 @@ -12,6 +12,7 @@
83 #include <linux/slab.h>
84 #include <linux/iobuf.h>
85 #include <linux/ptrace.h>
86 +#include <linux/module.h>
87
88 #include <asm/poll.h>
89 #include <asm/siginfo.h>
90 @@ -199,6 +200,7 @@ asmlinkage long sys_dup(unsigned int fil
91 ret = dupfd(file, 0);
92 return ret;
93 }
94 +EXPORT_SYMBOL(sys_dup);
95
96 #define SETFL_MASK (O_APPEND | O_NONBLOCK | O_NDELAY | FASYNC | O_DIRECT)
97
98 --- a/include/linux/miscdevice.h
99 +++ b/include/linux/miscdevice.h
100 @@ -15,6 +15,7 @@
101 #define ADB_MOUSE_MINOR 10
102 #define MK712_MINOR 15 /* MK712 touch screen */
103 #define SYNTH_MINOR 25
104 +#define CRYPTODEV_MINOR 70 /* OpenBSD cryptographic framework */
105 #define WATCHDOG_MINOR 130 /* Watchdog timer */
106 #define TEMP_MINOR 131 /* Temperature Sensor */
107 #define RTC_MINOR 135
108 --- a/include/linux/random.h
109 +++ b/include/linux/random.h
110 @@ -53,6 +53,10 @@ extern void add_mouse_randomness(__u32 m
111 extern void add_interrupt_randomness(int irq);
112 extern void add_blkdev_randomness(int major);
113
114 +extern void random_input_words(__u32 *buf, size_t wordcount, int ent_count);
115 +extern int random_input_wait(void);
116 +#define HAS_RANDOM_INPUT_WAIT 1
117 +
118 extern void get_random_bytes(void *buf, int nbytes);
119 void generate_random_uuid(unsigned char uuid_out[16]);
120
This page took 0.048768 seconds and 5 git commands to generate.