summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward O'Callaghan <eocallaghan@alterapraxis.com>2014-06-17 18:53:36 +1000
committerKyösti Mälkki <kyosti.malkki@gmail.com>2014-06-20 08:06:51 +0200
commit8fac0b3e904138f0642d7ab29c5867002aebf686 (patch)
tree8ae4a61ffc8225195e949b8898aa1ad5f79799b5
parent669cb2f0c4af8f01ac1d83d854258287077bbe95 (diff)
downloadcoreboot-8fac0b3e904138f0642d7ab29c5867002aebf686.tar.xz
src/lib/clog2.c: Fix style and clarity, remove some cruft
Change-Id: I6b37cf945db12d2cf8096c9f49fff9e0bec139d6 Signed-off-by: Edward O'Callaghan <eocallaghan@alterapraxis.com> Reviewed-on: http://review.coreboot.org/6058 Tested-by: build bot (Jenkins) Reviewed-by: Idwer Vollering <vidwer@gmail.com>
-rw-r--r--src/lib/clog2.c29
1 files changed, 11 insertions, 18 deletions
diff --git a/src/lib/clog2.c b/src/lib/clog2.c
index b908762917..5e0d591de4 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,28 +6,26 @@
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)
{
unsigned long pow;
- if (! x)
+ if (!x)
return -1;
pow = log2(x);