aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/random.c
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2013-09-21 19:42:41 -0400
committerTheodore Ts'o <tytso@mit.edu>2013-10-10 14:32:18 -0400
commitc59974aea43fd292a0784dbf7b3d7347e2caf4e9 (patch)
treedf60e718e97795838d2246aaa9ba63efdd08b6fb /drivers/char/random.c
parent3ef4cb2d65ee13d84140cbede8e1980c6ae49ffd (diff)
random: optimize the entropy_store structure
Use smaller types to slightly shrink the size of the entropy store structure. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'drivers/char/random.c')
-rw-r--r--drivers/char/random.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/drivers/char/random.c b/drivers/char/random.c
index 89eb5a8dec82..b8809d4ae186 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -436,16 +436,16 @@ struct entropy_store {
436 __u32 *pool; 436 __u32 *pool;
437 const char *name; 437 const char *name;
438 struct entropy_store *pull; 438 struct entropy_store *pull;
439 int limit;
440 439
441 /* read-write data: */ 440 /* read-write data: */
442 spinlock_t lock; 441 spinlock_t lock;
443 unsigned add_ptr; 442 unsigned short add_ptr;
444 unsigned input_rotate; 443 unsigned short input_rotate;
445 int entropy_count; 444 int entropy_count;
446 int entropy_total; 445 int entropy_total;
447 unsigned int initialized:1; 446 unsigned int initialized:1;
448 bool last_data_init; 447 unsigned int limit:1;
448 unsigned int last_data_init:1;
449 __u8 last_data[EXTRACT_SIZE]; 449 __u8 last_data[EXTRACT_SIZE];
450}; 450};
451 451
@@ -513,7 +513,7 @@ static void _mix_pool_bytes(struct entropy_store *r, const void *in,
513 513
514 /* mix one byte at a time to simplify size handling and churn faster */ 514 /* mix one byte at a time to simplify size handling and churn faster */
515 while (nbytes--) { 515 while (nbytes--) {
516 w = rol32(*bytes++, input_rotate & 31); 516 w = rol32(*bytes++, input_rotate);
517 i = (i - 1) & wordmask; 517 i = (i - 1) & wordmask;
518 518
519 /* XOR in the various taps */ 519 /* XOR in the various taps */
@@ -533,7 +533,7 @@ static void _mix_pool_bytes(struct entropy_store *r, const void *in,
533 * rotation, so that successive passes spread the 533 * rotation, so that successive passes spread the
534 * input bits across the pool evenly. 534 * input bits across the pool evenly.
535 */ 535 */
536 input_rotate += i ? 7 : 14; 536 input_rotate = (input_rotate + (i ? 7 : 14)) & 31;
537 } 537 }
538 538
539 ACCESS_ONCE(r->input_rotate) = input_rotate; 539 ACCESS_ONCE(r->input_rotate) = input_rotate;
@@ -1049,7 +1049,7 @@ static ssize_t extract_entropy(struct entropy_store *r, void *buf,
1049 if (fips_enabled) { 1049 if (fips_enabled) {
1050 spin_lock_irqsave(&r->lock, flags); 1050 spin_lock_irqsave(&r->lock, flags);
1051 if (!r->last_data_init) { 1051 if (!r->last_data_init) {
1052 r->last_data_init = true; 1052 r->last_data_init = 1;
1053 spin_unlock_irqrestore(&r->lock, flags); 1053 spin_unlock_irqrestore(&r->lock, flags);
1054 trace_extract_entropy(r->name, EXTRACT_SIZE, 1054 trace_extract_entropy(r->name, EXTRACT_SIZE,
1055 ENTROPY_BITS(r), _RET_IP_); 1055 ENTROPY_BITS(r), _RET_IP_);
@@ -1189,7 +1189,7 @@ static void init_std_data(struct entropy_store *r)
1189 1189
1190 r->entropy_count = 0; 1190 r->entropy_count = 0;
1191 r->entropy_total = 0; 1191 r->entropy_total = 0;
1192 r->last_data_init = false; 1192 r->last_data_init = 0;
1193 mix_pool_bytes(r, &now, sizeof(now), NULL); 1193 mix_pool_bytes(r, &now, sizeof(now), NULL);
1194 for (i = r->poolinfo->poolbytes; i > 0; i -= sizeof(rv)) { 1194 for (i = r->poolinfo->poolbytes; i > 0; i -= sizeof(rv)) {
1195 if (!arch_get_random_long(&rv)) 1195 if (!arch_get_random_long(&rv))