Skip to content

Commit 5b87adf

Browse files
committed
random: de-duplicate INPUT_POOL constants
We already had the POOL_* constants, so deduplicate the older INPUT_POOL ones. As well, fold EXTRACT_SIZE into the poolinfo enum, since it's related. Reviewed-by: Dominik Brodowski <[email protected]> Signed-off-by: Jason A. Donenfeld <[email protected]>
1 parent 0f63702 commit 5b87adf

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

drivers/char/random.c

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -358,13 +358,6 @@
358358

359359
/* #define ADD_INTERRUPT_BENCH */
360360

361-
/*
362-
* Configuration information
363-
*/
364-
#define INPUT_POOL_SHIFT 12
365-
#define INPUT_POOL_WORDS (1 << (INPUT_POOL_SHIFT-5))
366-
#define EXTRACT_SIZE (BLAKE2S_HASH_SIZE / 2)
367-
368361
/*
369362
* To allow fractional bits to be tracked, the entropy_count field is
370363
* denominated in units of 1/8th bits.
@@ -440,7 +433,9 @@ enum poolinfo {
440433
POOL_TAP2 = 76,
441434
POOL_TAP3 = 51,
442435
POOL_TAP4 = 25,
443-
POOL_TAP5 = 1
436+
POOL_TAP5 = 1,
437+
438+
EXTRACT_SIZE = BLAKE2S_HASH_SIZE / 2
444439
};
445440

446441
/*
@@ -503,7 +498,7 @@ MODULE_PARM_DESC(ratelimit_disable, "Disable random ratelimit suppression");
503498
*
504499
**********************************************************************/
505500

506-
static u32 input_pool_data[INPUT_POOL_WORDS] __latent_entropy;
501+
static u32 input_pool_data[POOL_WORDS] __latent_entropy;
507502

508503
static struct {
509504
/* read-only data: */
@@ -1961,7 +1956,7 @@ SYSCALL_DEFINE3(getrandom, char __user *, buf, size_t, count,
19611956
#include <linux/sysctl.h>
19621957

19631958
static int min_write_thresh;
1964-
static int max_write_thresh = INPUT_POOL_WORDS * 32;
1959+
static int max_write_thresh = POOL_BITS;
19651960
static int random_min_urandom_seed = 60;
19661961
static char sysctl_bootid[16];
19671962

@@ -2018,7 +2013,7 @@ static int proc_do_entropy(struct ctl_table *table, int write,
20182013
return proc_dointvec(&fake_table, write, buffer, lenp, ppos);
20192014
}
20202015

2021-
static int sysctl_poolsize = INPUT_POOL_WORDS * 32;
2016+
static int sysctl_poolsize = POOL_BITS;
20222017
extern struct ctl_table random_table[];
20232018
struct ctl_table random_table[] = {
20242019
{

0 commit comments

Comments
 (0)