summaryrefslogtreecommitdiffstats
path: root/drivers/char/random.c
diff options
context:
space:
mode:
authorRasmus Villemoes <linux@rasmusvillemoes.dk>2018-02-28 18:22:47 -0500
committerTheodore Ts'o <tytso@mit.edu>2018-02-28 19:03:19 -0500
commit5e747dd9be54be190dd6ebeebf4a4a01ba765625 (patch)
tree43d66c53cb93bd12976d8059653eb74ff7bebb11 /drivers/char/random.c
parente8e8a2e47db6bb85bb0cb21e77b5c6aaedf864b4 (diff)
drivers/char/random.c: remove unused dont_count_entropy
Ever since "random: kill dead extract_state struct" [1], the dont_count_entropy member of struct timer_rand_state has been effectively unused. Since it hasn't found a new use in 12 years, it's probably safe to finally kill it. [1] Pre-git, https://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git/commit/?id=c1c48e61c251f57e7a3f1bf11b3c462b2de9dcb5 Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'drivers/char/random.c')
-rw-r--r--drivers/char/random.c53
1 files changed, 25 insertions, 28 deletions
diff --git a/drivers/char/random.c b/drivers/char/random.c
index ee0c0d18f1eb..e027e7fa1472 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -964,7 +964,6 @@ static ssize_t extract_crng_user(void __user *buf, size_t nbytes)
964struct timer_rand_state { 964struct timer_rand_state {
965 cycles_t last_time; 965 cycles_t last_time;
966 long last_delta, last_delta2; 966 long last_delta, last_delta2;
967 unsigned dont_count_entropy:1;
968}; 967};
969 968
970#define INIT_TIMER_RAND_STATE { INITIAL_JIFFIES, }; 969#define INIT_TIMER_RAND_STATE { INITIAL_JIFFIES, };
@@ -1030,35 +1029,33 @@ static void add_timer_randomness(struct timer_rand_state *state, unsigned num)
1030 * We take into account the first, second and third-order deltas 1029 * We take into account the first, second and third-order deltas
1031 * in order to make our estimate. 1030 * in order to make our estimate.
1032 */ 1031 */
1032 delta = sample.jiffies - state->last_time;
1033 state->last_time = sample.jiffies;
1034
1035 delta2 = delta - state->last_delta;
1036 state->last_delta = delta;
1037
1038 delta3 = delta2 - state->last_delta2;
1039 state->last_delta2 = delta2;
1040
1041 if (delta < 0)
1042 delta = -delta;
1043 if (delta2 < 0)
1044 delta2 = -delta2;
1045 if (delta3 < 0)
1046 delta3 = -delta3;
1047 if (delta > delta2)
1048 delta = delta2;
1049 if (delta > delta3)
1050 delta = delta3;
1033 1051
1034 if (!state->dont_count_entropy) { 1052 /*
1035 delta = sample.jiffies - state->last_time; 1053 * delta is now minimum absolute delta.
1036 state->last_time = sample.jiffies; 1054 * Round down by 1 bit on general principles,
1037 1055 * and limit entropy entimate to 12 bits.
1038 delta2 = delta - state->last_delta; 1056 */
1039 state->last_delta = delta; 1057 credit_entropy_bits(r, min_t(int, fls(delta>>1), 11));
1040
1041 delta3 = delta2 - state->last_delta2;
1042 state->last_delta2 = delta2;
1043
1044 if (delta < 0)
1045 delta = -delta;
1046 if (delta2 < 0)
1047 delta2 = -delta2;
1048 if (delta3 < 0)
1049 delta3 = -delta3;
1050 if (delta > delta2)
1051 delta = delta2;
1052 if (delta > delta3)
1053 delta = delta3;
1054 1058
1055 /*
1056 * delta is now minimum absolute delta.
1057 * Round down by 1 bit on general principles,
1058 * and limit entropy entimate to 12 bits.
1059 */
1060 credit_entropy_bits(r, min_t(int, fls(delta>>1), 11));
1061 }
1062 preempt_enable(); 1059 preempt_enable();
1063} 1060}
1064 1061