[PATCH 18/22] /dev/random: bitop cleanup

From: Matt Mackall
Date: Thu Mar 25 2004 - 19:32:53 EST



/dev/random bitop cleanup

Remove incorrectly named ln and x86 asm function and replace with fls
bitop.


tiny-mpm/drivers/char/random.c | 42 -----------------------------------------
1 files changed, 1 insertion(+), 41 deletions(-)

diff -puN drivers/char/random.c~ln-to-fls drivers/char/random.c
--- tiny/drivers/char/random.c~ln-to-fls 2004-03-20 13:38:38.000000000 -0600
+++ tiny-mpm/drivers/char/random.c 2004-03-20 13:38:38.000000000 -0600
@@ -420,43 +420,6 @@ static inline __u32 rotate_left(int i, _
}
#endif

-/*
- * More asm magic....
- *
- * For entropy estimation, we need to do an integral base 2
- * logarithm.
- *
- * Note the "12bits" suffix - this is used for numbers between
- * 0 and 4095 only. This allows a few shortcuts.
- */
-#if 0 /* Slow but clear version */
-static inline __u32 int_ln_12bits(__u32 word)
-{
- __u32 nbits = 0;
-
- while (word >>= 1)
- nbits++;
- return nbits;
-}
-#else /* Faster (more clever) version, courtesy Colin Plumb */
-static inline __u32 int_ln_12bits(__u32 word)
-{
- /* Smear msbit right to make an n-bit mask */
- word |= word >> 8;
- word |= word >> 4;
- word |= word >> 2;
- word |= word >> 1;
- /* Remove one bit to make this a logarithm */
- word >>= 1;
- /* Count the bits set in the word */
- word -= (word >> 1) & 0x555;
- word = (word & 0x333) + ((word >> 2) & 0x333);
- word += (word >> 4);
- word += (word >> 8);
- return word & 15;
-}
-#endif
-
#if 0
#define DEBUG_ENT(fmt, arg...) \
printk(KERN_DEBUG "random %04d %04d %04d: " fmt,\
@@ -800,10 +763,7 @@ static void add_timer_randomness(struct
* Round down by 1 bit on general principles,
* and limit entropy entimate to 12 bits.
*/
- delta >>= 1;
- delta &= (1 << 12) - 1;
-
- entropy = int_ln_12bits(delta);
+ entropy = min_t(int, fls(delta>>1), 11);
}
batch_entropy_store(num, time, entropy);
}

_
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/