<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">
From: Matt Mackall &lt;mpm@selenic.com&gt;

Remove incorrectly named ln (it's log2!) and x86 asm function and replace with
fls bitop.

Signed-off-by: Matt Mackall &lt;mpm@selenic.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@osdl.org&gt;
---

 25-akpm/drivers/char/random.c |   48 ------------------------------------------
 1 files changed, 1 insertion(+), 47 deletions(-)

diff -puN drivers/char/random.c~random-pt2-kill-misnamed-log2 drivers/char/random.c
--- 25/drivers/char/random.c~random-pt2-kill-misnamed-log2	2005-01-16 00:53:38.426167224 -0800
+++ 25-akpm/drivers/char/random.c	2005-01-16 00:53:38.432166312 -0800
@@ -395,54 +395,11 @@ static DECLARE_WAIT_QUEUE_HEAD(random_wr
 static void sysctl_init_random(struct entropy_store *random_state);
 #endif
 
-/*****************************************************************
- *
- * Utility functions, with some ASM defined functions for speed
- * purposes
- *
- *****************************************************************/
 static inline __u32 rol32(__u32 word, int shift)
 {
 	return (word &lt;&lt; shift) | (word &gt;&gt; (32 - shift));
 }
 
-/*
- * 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 &gt;&gt;= 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 &gt;&gt; 8;
-	word |= word &gt;&gt; 4;
-	word |= word &gt;&gt; 2;
-	word |= word &gt;&gt; 1;
-	/* Remove one bit to make this a logarithm */
-	word &gt;&gt;= 1;
-	/* Count the bits set in the word */
-	word -= (word &gt;&gt; 1) &amp; 0x555;
-	word = (word &amp; 0x333) + ((word &gt;&gt; 2) &amp; 0x333);
-	word += (word &gt;&gt; 4);
-	word += (word &gt;&gt; 8);
-	return word &amp; 15;
-}
-#endif
-
 #if 0
 static int debug = 0;
 module_param(debug, bool, 0644);
@@ -808,10 +765,7 @@ static void add_timer_randomness(struct 
 		 * Round down by 1 bit on general principles,
 		 * and limit entropy entimate to 12 bits.
 		 */
-		delta &gt;&gt;= 1;
-		delta &amp;= (1 &lt;&lt; 12) - 1;
-
-		entropy = int_ln_12bits(delta);
+		entropy = min_t(int, fls(delta&gt;&gt;1), 11);
 	}
 
 	/*
_
</pre></body></html>