summaryrefslogtreecommitdiffstats
path: root/include/debug_ll.h
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2013-08-25 17:14:57 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2013-09-05 10:15:48 +0200
commit4960dc9db00fcf5058196dbcb94c2f139999bd2e (patch)
tree9d61a2eab6283efb10dc7fc57a8578d7189609ee /include/debug_ll.h
parentabd545d2f9b91268ed90879d929b0e5e055d574d (diff)
downloadbarebox-4960dc9db00fcf5058196dbcb94c2f139999bd2e.tar.gz
barebox-4960dc9db00fcf5058196dbcb94c2f139999bd2e.tar.xz
rework debug_ll
Convert to static inline functions and use lower case letters for function names. Also, include mach/debug_ll.h when an architecture provides support for debug_ll, not only when it's actually enabled. This allows architecures to put some UART initialization code into mach/debug_ll.h which is compiled out when debug_ll is disabled. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include/debug_ll.h')
-rw-r--r--include/debug_ll.h61
1 files changed, 43 insertions, 18 deletions
diff --git a/include/debug_ll.h b/include/debug_ll.h
index f0034ba06a..288aa256e5 100644
--- a/include/debug_ll.h
+++ b/include/debug_ll.h
@@ -20,8 +20,7 @@
#ifndef __INCLUDE_DEBUG_LL_H__
#define __INCLUDE_DEBUG_LL_H__
-#if defined (CONFIG_DEBUG_LL)
-
+#ifdef CONFIG_HAS_DEBUG_LL
/*
* mach/debug_ll.h should implement PUTC_LL. This can be a macro or a static
* inline function. Note that several SoCs expect the UART to be initialized
@@ -29,35 +28,61 @@
* this initialization. Depending on the PUTC_LL implementation the board might
* also hang in PUTC_LL without proper initialization.
*/
-# include <mach/debug_ll.h>
+#include <mach/debug_ll.h>
+#endif
-# define PUTHEX_LL(value) ({ unsigned long v = (unsigned long) (value); \
- int i; unsigned char ch; \
- for (i = 8; i--; ) {\
- ch = ((v >> (i*4)) & 0xf);\
- ch += (ch >= 10) ? 'a' - 10 : '0';\
- PUTC_LL (ch); }})
+#if defined (CONFIG_DEBUG_LL)
+
+static inline void putc_ll(unsigned char value)
+{
+ PUTC_LL(value);
+}
+
+static inline void puthex_ll(unsigned long value)
+{
+ int i; unsigned char ch;
+
+ for (i = 8; i--; ) {
+ ch = ((value >> (i * 4)) & 0xf);
+ ch += (ch >= 10) ? 'a' - 10 : '0';
+ putc_ll(ch);
+ }
+}
/*
- * Be careful with PUTS_LL, it only works if the binary is running at the
+ * Be careful with puts_ll, it only works if the binary is running at the
* link address which often is not the case during early startup. If in doubt
* don't use it.
*/
-static __inline__ void PUTS_LL(const char * str)
+static inline void puts_ll(const char * str)
{
while (*str) {
- if (*str == '\n') {
- PUTC_LL('\r');
- }
- PUTC_LL(*str);
+ if (*str == '\n')
+ putc_ll('\r');
+
+ putc_ll(*str);
str++;
}
}
#else
-# define PUTC_LL(c) do {} while (0)
-# define PUTHEX_LL(v) do {} while (0)
-# define PUTS_LL(c) do {} while (0)
+
+static inline void putc_ll(unsigned char value)
+{
+}
+
+static inline void puthex_ll(unsigned long value)
+{
+}
+
+/*
+ * Be careful with puts_ll, it only works if the binary is running at the
+ * link address which often is not the case during early startup. If in doubt
+ * don't use it.
+ */
+static inline void puts_ll(const char * str)
+{
+}
#endif