Skip to contentSkip to conversation

drivers/char/random.c: constify poolinfo_table

PATCH Applied Rasmus Villemoes 2 participants 6 messages Nov 2, 2018 – Nov 7, 2018 Random number driver

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 drivers/char/random.c: constify poolinfo_table

Never modified, might as well be put in .rodata.

---
 drivers/char/random.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/char/random.c +1 -1
index 2eb70e76ed35..320108df04c1 100644
@@ -359,7 +359,7 @@ static int random_write_wakeup_bits = 28 * OUTPUT_POOL_WORDS;
  * polynomial which improves the resulting TGFSR polynomial to be
  * irreducible, which we have made here.
  */
-static struct poolinfo {
+static const struct poolinfo {
 	int poolbitshift, poolwords, poolbytes, poolbits, poolfracbits;
 #define S(x) ilog2(x)+5, (x), (x)*4, (x)*32, (x) << (ENTROPY_SHIFT+5)
 	int tap1, tap2, tap3, tap4, tap5;
Signature · 1 line
2.19.1.6.gbde171bbf5
#1 lore raw

PATCH 2/3 drivers/char/random.c: remove unused stuct poolinfo::poolbits

This field is never used, might as well remove it.

---
 drivers/char/random.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/char/random.c +3 -3
index 320108df04c1..1b2e1580b4b5 100644
@@ -295,7 +295,7 @@
  * To allow fractional bits to be tracked, the entropy_count field is
  * denominated in units of 1/8th bits.
  *
- * 2*(ENTROPY_SHIFT + log2(poolbits)) must <= 31, or the multiply in
+ * 2*(ENTROPY_SHIFT + poolbitshift) must <= 31, or the multiply in
  * credit_entropy_bits() needs to be 64 bits wide.
  */
 #define ENTROPY_SHIFT 3
@@ -360,8 +360,8 @@ static int random_write_wakeup_bits = 28 * OUTPUT_POOL_WORDS;
  * irreducible, which we have made here.
  */
 static const struct poolinfo {
-	int poolbitshift, poolwords, poolbytes, poolbits, poolfracbits;
-#define S(x) ilog2(x)+5, (x), (x)*4, (x)*32, (x) << (ENTROPY_SHIFT+5)
+	int poolbitshift, poolwords, poolbytes, poolfracbits;
+#define S(x) ilog2(x)+5, (x), (x)*4, (x) << (ENTROPY_SHIFT+5)
 	int tap1, tap2, tap3, tap4, tap5;
 } poolinfo_table[] = {
 	/* was: x^128 + x^103 + x^76 + x^51 +x^25 + x + 1 */
Signature · 1 line
2.19.1.6.gbde171bbf5
#3 lore raw

PATCH 3/3 drivers/char/random.c: make primary_crng static

In reply to Rasmus Villemoes

Since the definition of struct crng_state is private to random.c, and primary_crng is neither declared or used elsewhere, there's no reason for that symbol to have external linkage.

---
 drivers/char/random.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/char/random.c +1 -1
index 1b2e1580b4b5..0a381897e4a5 100644
@@ -415,7 +415,7 @@ struct crng_state {
 	spinlock_t	lock;
 };
 
-struct crng_state primary_crng = {
+static struct crng_state primary_crng = {
 	.lock = __SPIN_LOCK_UNLOCKED(primary_crng.lock),
 };
 
Signature · 1 line
2.19.1.6.gbde171bbf5
maintainer Applied
#4 lore raw

Re: [PATCH 3/3] drivers/char/random.c: make primary_crng static

Quoted 5 lines · Rasmus Villemoes

Since the definition of struct crng_state is private to random.c, and primary_crng is neither declared or used elsewhere, there's no reason for that symbol to have external linkage.

Thanks, applied.

- Ted