Following patch enables UDMA on ALL IDE devices. The current code enables it only...
[coreboot.git] / src / lib / clog2.c
index 092b49c821f6ee2365116905d460e248865477a9..c6fe6f6cc87f81ac062f24c5fb07dd3f325dd93d 100644 (file)
@@ -1,14 +1,25 @@
+#undef DEBUG_LOG2
+
+#ifdef DEBUG_LOG2
 #include <console/console.h>
+#endif
+
+#include <lib.h>
+
+/* Assume 8 bits per byte */
+#define CHAR_BIT 8
 
 unsigned long log2(unsigned long x)
 {
         // assume 8 bits per byte.
-        unsigned long i = 1 << (sizeof(x)*8 - 1);
-        unsigned long pow = sizeof(x) * 8 - 1;
+        unsigned long i = 1ULL << (sizeof(x)* CHAR_BIT - 1ULL);
+        unsigned long pow = sizeof(x) * CHAR_BIT - 1ULL;
 
         if (! x) {
-                printk_warning("%s called with invalid parameter of 0\n",
-                       __FUNCTION__);
+#ifdef DEBUG_LOG2
+                printk(BIOS_WARNING, "%s called with invalid parameter of 0\n",
+                       __func__);
+#endif
                 return -1;
         }
         for(; i > x; i >>= 1, pow--)