From 1345cbaf09ee89fb75f568143747dc3a32fa44dc Mon Sep 17 00:00:00 2001
From: nikita <nikita>
Date: Wed, 20 Aug 2008 09:46:32 +0000
Subject: [PATCH] rhel4 2.6.9-67 kernel has (nonfunctional)
 drivers/infiniband/include/linux/lockdep.h header, defining lockdep
 interfaces. Update libcfs headers to check for this.

Build-tested at rhel4, rhel5, sles10, 2.6.18-vanilla.
---
 libcfs/include/libcfs/linux/linux-lock.h | 33 ++++++++++++++----------
 1 file changed, 20 insertions(+), 13 deletions(-)

diff --git a/libcfs/include/libcfs/linux/linux-lock.h b/libcfs/include/libcfs/linux/linux-lock.h
index 8c984d57db..474132bdc7 100644
--- a/libcfs/include/libcfs/linux/linux-lock.h
+++ b/libcfs/include/libcfs/linux/linux-lock.h
@@ -73,13 +73,6 @@
  * - spin_unlock_irqrestore(x, f)
  */
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)
-static inline void spin_lock_nested(spinlock_t *lock, unsigned subclass)
-{
-        spin_lock(lock);
-}
-#endif
-
 /*
  * rw_semaphore (use Linux kernel's primitives)
  *
@@ -164,13 +157,27 @@ struct lock_class_key {
         ;
 };
 
-static inline void lockdep_set_class(void *lock, struct lock_class_key *key)
-{
-}
+#ifndef lockdep_set_class
+# define lockdep_set_class(lock, key) do {;} while (0)
+#endif
 
-/* This has to be a macro, so that can be undefined in kernels that do not
- * support lockdep. */
-#define mutex_lock_nested(mutex, subclass) mutex_lock(mutex)
+/* This has to be a macro, so that `subclass' can be undefined in kernels that
+ * do not support lockdep. */
+#ifndef mutex_lock_nested
+# define mutex_lock_nested(mutex, subclass) mutex_lock(mutex)
+#endif
+
+#ifndef spin_lock_nested
+# define spin_lock_nested(lock, subclass) spin_lock(lock)
+#endif
+
+#ifndef down_read_nested
+# define down_read_nested(lock, subclass) down_read(lock)
+#endif
+
+#ifndef down_write_nested
+# define down_write_nested(lock, subclass) down_write(lock)
+#endif
 
 #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18) */
 
-- 
GitLab