Index: kernel/generic/include/print.h
===================================================================
--- kernel/generic/include/print.h	(revision bc7d44c8c94c3e6939ba5054dd1878bd7e3674f7)
+++ kernel/generic/include/print.h	(revision 90c8b8debd741b2a29ed7955b99cd5ea34956065)
@@ -37,9 +37,5 @@
 
 #include <arch/types.h>
-#include <synch/spinlock.h>
 #include <arch/arg.h>
-
-/* We need this address in spinlock to avoid deadlock in deadlock detection */
-SPINLOCK_EXTERN(printf_lock);
 
 #define EOF (-1)
Index: kernel/generic/include/synch/spinlock.h
===================================================================
--- kernel/generic/include/synch/spinlock.h	(revision bc7d44c8c94c3e6939ba5054dd1878bd7e3674f7)
+++ kernel/generic/include/synch/spinlock.h	(revision 90c8b8debd741b2a29ed7955b99cd5ea34956065)
@@ -43,9 +43,11 @@
 
 #ifdef CONFIG_SMP
+
 typedef struct {
+	atomic_t val;
+	
 #ifdef CONFIG_DEBUG_SPINLOCK
 	char *name;
 #endif
-	atomic_t val;
 } spinlock_t;
 
@@ -54,6 +56,6 @@
  * where the lock gets initialized in run time.
  */
-#define SPINLOCK_DECLARE(slname) 	spinlock_t slname
-#define SPINLOCK_EXTERN(slname)		extern spinlock_t slname
+#define SPINLOCK_DECLARE(lock_name)  spinlock_t lock_name
+#define SPINLOCK_EXTERN(lock_name)   extern spinlock_t lock_name
 
 /*
@@ -62,25 +64,44 @@
  */
 #ifdef CONFIG_DEBUG_SPINLOCK
-#define SPINLOCK_INITIALIZE(slname) 	\
-	spinlock_t slname = { 		\
-		.name = #slname,	\
-		.val = { 0 }		\
+
+#define SPINLOCK_INITIALIZE_NAME(lock_name, desc_name) \
+	spinlock_t lock_name = { \
+		.name = desc_name, \
+		.val = { 0 } \
 	}
+
+#define SPINLOCK_STATIC_INITIALIZE_NAME(lock_name, desc_name) \
+	static spinlock_t lock_name = { \
+		.name = desc_name, \
+		.val = { 0 } \
+	}
+
+#define spinlock_lock(lock)  spinlock_lock_debug(lock)
+
 #else
-#define SPINLOCK_INITIALIZE(slname) 	\
-	spinlock_t slname = { 		\
-		.val = { 0 }		\
+
+#define SPINLOCK_INITIALIZE_NAME(lock_name, desc_name) \
+	spinlock_t lock_name = { \
+		.val = { 0 } \
 	}
+
+#define SPINLOCK_STATIC_INITIALIZE_NAME(lock_name, desc_name) \
+	static spinlock_t lock_name = { \
+		.val = { 0 } \
+	}
+
+#define spinlock_lock(lock)  atomic_lock_arch(&(lock)->val)
+
 #endif
 
-extern void spinlock_initialize(spinlock_t *sl, char *name);
-extern int spinlock_trylock(spinlock_t *sl);
-extern void spinlock_lock_debug(spinlock_t *sl);
+#define SPINLOCK_INITIALIZE(lock_name) \
+	SPINLOCK_INITIALIZE_NAME(lock_name, #lock_name)
 
-#ifdef CONFIG_DEBUG_SPINLOCK
-#  define spinlock_lock(x) spinlock_lock_debug(x)
-#else
-#  define spinlock_lock(x) atomic_lock_arch(&(x)->val)
-#endif
+#define SPINLOCK_STATIC_INITIALIZE(lock_name) \
+	SPINLOCK_STATIC_INITIALIZE_NAME(lock_name, #lock_name)
+
+extern void spinlock_initialize(spinlock_t *lock, char *name);
+extern int spinlock_trylock(spinlock_t *lock);
+extern void spinlock_lock_debug(spinlock_t *lock);
 
 /** Unlock spinlock
@@ -90,8 +111,8 @@
  * @param sl Pointer to spinlock_t structure.
  */
-static inline void spinlock_unlock(spinlock_t *sl)
+static inline void spinlock_unlock(spinlock_t *lock)
 {
-	ASSERT(atomic_get(&sl->val) != 0);
-
+	ASSERT(atomic_get(&lock->val) != 0);
+	
 	/*
 	 * Prevent critical section code from bleeding out this way down.
@@ -99,5 +120,5 @@
 	CS_LEAVE_BARRIER();
 	
-	atomic_set(&sl->val, 0);
+	atomic_set(&lock->val, 0);
 	preemption_enable();
 }
@@ -105,31 +126,43 @@
 #ifdef CONFIG_DEBUG_SPINLOCK
 
-extern int printf(const char *, ...);
+#include <print.h>
 
-#define DEADLOCK_THRESHOLD		100000000
-#define DEADLOCK_PROBE_INIT(pname)	size_t pname = 0
-#define DEADLOCK_PROBE(pname, value)					\
-	if ((pname)++ > (value)) {					\
-		(pname) = 0;						\
-		printf("Deadlock probe %s: exceeded threshold %u\n",	\
-		    "cpu%u: function=%s, line=%u\n",			\
-		    #pname, (value), CPU->id, __func__, __LINE__);	\
+#define DEADLOCK_THRESHOLD  100000000
+
+#define DEADLOCK_PROBE_INIT(pname)  size_t pname = 0
+
+#define DEADLOCK_PROBE(pname, value) \
+	if ((pname)++ > (value)) { \
+		(pname) = 0; \
+		printf("Deadlock probe %s: exceeded threshold %u\n", \
+		    "cpu%u: function=%s, line=%u\n", \
+		    #pname, (value), CPU->id, __func__, __LINE__); \
 	}
-#else
-#define DEADLOCK_PROBE_INIT(pname)
-#define DEADLOCK_PROBE(pname, value)
-#endif
 
 #else
 
+#define DEADLOCK_PROBE_INIT(pname)
+#define DEADLOCK_PROBE(pname, value)
+
+#endif
+
+#else /* CONFIG_SMP */
+
 /* On UP systems, spinlocks are effectively left out. */
+
 #define SPINLOCK_DECLARE(name)
 #define SPINLOCK_EXTERN(name)
+
 #define SPINLOCK_INITIALIZE(name)
+#define SPINLOCK_STATIC_INITIALIZE(name)
 
-#define spinlock_initialize(x, name)
-#define spinlock_lock(x)		preemption_disable()
-#define spinlock_trylock(x) 		(preemption_disable(), 1)
-#define spinlock_unlock(x)		preemption_enable()
+#define SPINLOCK_INITIALIZE_NAME(name, desc_name)
+#define SPINLOCK_STATIC_INITIALIZE_NAME(name, desc_name)
+
+#define spinlock_initialize(lock, name)
+
+#define spinlock_lock(lock)     preemption_disable()
+#define spinlock_trylock(lock)  (preemption_disable(), 1)
+#define spinlock_unlock(lock)   preemption_enable()
 
 #define DEADLOCK_PROBE_INIT(pname)
Index: kernel/generic/src/printf/vprintf.c
===================================================================
--- kernel/generic/src/printf/vprintf.c	(revision bc7d44c8c94c3e6939ba5054dd1878bd7e3674f7)
+++ kernel/generic/src/printf/vprintf.c	(revision 90c8b8debd741b2a29ed7955b99cd5ea34956065)
@@ -42,5 +42,5 @@
 #include <string.h>
 
-SPINLOCK_INITIALIZE(printf_lock);  /**< vprintf spinlock */
+SPINLOCK_STATIC_INITIALIZE_NAME(printf_lock, "*printf_lock");
 
 static int vprintf_str_write(const char *str, size_t size, void *data)
Index: kernel/generic/src/synch/spinlock.c
===================================================================
--- kernel/generic/src/synch/spinlock.c	(revision bc7d44c8c94c3e6939ba5054dd1878bd7e3674f7)
+++ kernel/generic/src/synch/spinlock.c	(revision 90c8b8debd741b2a29ed7955b99cd5ea34956065)
@@ -45,23 +45,20 @@
 #include <symtab.h>
 
-#ifdef CONFIG_FB
-#include <genarch/fb/fb.h>
-#endif
-
 #ifdef CONFIG_SMP
 
 /** Initialize spinlock
  *
- * Initialize spinlock.
+ * @param sl Pointer to spinlock_t structure.
  *
- * @param sl Pointer to spinlock_t structure.
  */
-void spinlock_initialize(spinlock_t *sl, char *name)
+void spinlock_initialize(spinlock_t *lock, char *name)
 {
-	atomic_set(&sl->val, 0);
+	atomic_set(&lock->val, 0);
 #ifdef CONFIG_DEBUG_SPINLOCK
-	sl->name = name;
-#endif	
+	lock->name = name;
+#endif
 }
+
+#ifdef CONFIG_DEBUG_SPINLOCK
 
 /** Lock spinlock
@@ -71,41 +68,40 @@
  * possible occurence of deadlock.
  *
- * @param sl Pointer to spinlock_t structure.
+ * @param lock Pointer to spinlock_t structure.
+ *
  */
-#ifdef CONFIG_DEBUG_SPINLOCK
-void spinlock_lock_debug(spinlock_t *sl)
+void spinlock_lock_debug(spinlock_t *lock)
 {
 	size_t i = 0;
 	bool deadlock_reported = false;
-
+	
 	preemption_disable();
-	while (test_and_set(&sl->val)) {
-
+	while (test_and_set(&lock->val)) {
 		/*
-		 * We need to be careful about printf_lock and fb_lock.
-		 * Both of them are used to report deadlocks via
-		 * printf() and fb_putchar().
+		 * We need to be careful about particular locks
+		 * which are directly used to report deadlocks
+		 * via printf() (and recursively other functions).
+		 * This conserns especially printf_lock and the
+		 * framebuffer lock.
 		 *
+		 * Any lock whose name is prefixed by "*" will be
+		 * ignored by this deadlock detection routine
+		 * as this might cause an infinite recursion.
 		 * We trust our code that there is no possible deadlock
-		 * caused by these two locks (except when an exception
-		 * is triggered for instance by printf() or fb_putchar()).
-		 * However, we encountered false positives caused by very
-		 * slow VESA framebuffer interaction (especially when
+		 * caused by these locks (except when an exception
+		 * is triggered for instance by printf()).
+		 *
+		 * We encountered false positives caused by very
+		 * slow framebuffer interaction (especially when
 		 * run in a simulator) that caused problems with both
-		 * printf_lock and fb_lock.
+		 * printf_lock and the framebuffer lock.
 		 *
-		 * Possible deadlocks on both printf_lock and fb_lock
-		 * are therefore not reported as they would cause an
-		 * infinite recursion.
 		 */
-		if (sl == &printf_lock)
+		if (lock->name[0] == '*')
 			continue;
-#ifdef CONFIG_FB
-		if (sl == &fb_lock)
-			continue;
-#endif
+		
 		if (i++ > DEADLOCK_THRESHOLD) {
 			printf("cpu%u: looping on spinlock %" PRIp ":%s, "
-			    "caller=%" PRIp "(%s)\n", CPU->id, sl, sl->name,
+			    "caller=%" PRIp "(%s)\n", CPU->id, lock, lock->name,
 			    CALLER, symtab_fmt_name_lookup(CALLER));
 			
@@ -114,8 +110,8 @@
 		}
 	}
-
+	
 	if (deadlock_reported)
 		printf("cpu%u: not deadlocked\n", CPU->id);
-
+	
 	/*
 	 * Prevent critical section code from bleeding out this way up.
@@ -123,4 +119,5 @@
 	CS_ENTER_BARRIER();
 }
+
 #endif
 
@@ -131,20 +128,19 @@
  * signal failure.
  *
- * @param sl Pointer to spinlock_t structure.
+ * @param lock Pointer to spinlock_t structure.
  *
  * @return Zero on failure, non-zero otherwise.
+ *
  */
-int spinlock_trylock(spinlock_t *sl)
+int spinlock_trylock(spinlock_t *lock)
 {
-	int rc;
+	preemption_disable();
+	int rc = !test_and_set(&lock->val);
 	
-	preemption_disable();
-	rc = !test_and_set(&sl->val);
-
 	/*
 	 * Prevent critical section code from bleeding out this way up.
 	 */
 	CS_ENTER_BARRIER();
-
+	
 	if (!rc)
 		preemption_enable();
