[coreboot-gerrit] New patch to review for coreboot: 71287bb src/lib/clog2.c: Fix style and clarity, remove some cruft
Edward O'Callaghan (eocallaghan@alterapraxis.com)
gerrit at coreboot.org
Tue Jun 17 10:56:00 CEST 2014
Edward O'Callaghan (eocallaghan at alterapraxis.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/6058
-gerrit
commit 71287bb16cd9254da5b8efb0c4faa6322f7b7243
Author: Edward O'Callaghan <eocallaghan at alterapraxis.com>
Date: Tue Jun 17 18:53:36 2014 +1000
src/lib/clog2.c: Fix style and clarity, remove some cruft
Change-Id: I6b37cf945db12d2cf8096c9f49fff9e0bec139d6
Signed-off-by: Edward O'Callaghan <eocallaghan at alterapraxis.com>
---
src/lib/clog2.c | 27 ++++++++++-----------------
1 file changed, 10 insertions(+), 17 deletions(-)
diff --git a/src/lib/clog2.c b/src/lib/clog2.c
index b908762..29021f1 100644
--- a/src/lib/clog2.c
+++ b/src/lib/clog2.c
@@ -1,9 +1,4 @@
-#undef DEBUG_LOG2
-
-#ifdef DEBUG_LOG2
#include <console/console.h>
-#endif
-
#include <lib.h>
/* Assume 8 bits per byte */
@@ -11,21 +6,19 @@
unsigned long log2(unsigned long x)
{
- // assume 8 bits per byte.
- unsigned long i = 1ULL << (sizeof(x)* CHAR_BIT - 1ULL);
- unsigned long pow = sizeof(x) * CHAR_BIT - 1ULL;
+ /* assume 8 bits per byte. */
+ unsigned long pow = sizeof(x) * CHAR_BIT - 1ULL;
+ unsigned long i = 1ULL << pow;
- if (! x) {
-#ifdef DEBUG_LOG2
- printk(BIOS_WARNING, "%s called with invalid parameter of 0\n",
+ if (!x) {
+ printk(BIOS_WARNING, "%s called with invalid parameter of 0\n",
__func__);
-#endif
- return -1;
- }
- for(; i > x; i >>= 1, pow--)
- ;
+ return -1;
+ }
- return pow;
+ for(; i > x; i >>= 1, pow--);
+
+ return pow;
}
unsigned long log2_ceil(unsigned long x)
More information about the coreboot-gerrit
mailing list