From 8395d0d68b9e51c9e659bb2dae9a9cc839cc7e02 Mon Sep 17 00:00:00 2001
From: nikita <nikita>
Date: Mon, 11 Aug 2008 11:39:47 +0000
Subject: [PATCH] libcfs: fix mutex interface for sles10.

---
 libcfs/include/libcfs/linux/linux-lock.h | 54 ++++++++++++------------
 1 file changed, 28 insertions(+), 26 deletions(-)

diff --git a/libcfs/include/libcfs/linux/linux-lock.h b/libcfs/include/libcfs/linux/linux-lock.h
index 0ada733bc7..8c984d57db 100644
--- a/libcfs/include/libcfs/linux/linux-lock.h
+++ b/libcfs/include/libcfs/linux/linux-lock.h
@@ -50,6 +50,7 @@
 #endif
 
 #include <linux/smp_lock.h>
+#include <linux/mutex.h>
 
 /*
  * IMPORTANT !!!!!!!!
@@ -121,21 +122,7 @@ static inline void spin_lock_nested(spinlock_t *lock, unsigned subclass)
  * - wait_for_completion(c)
  */
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)
-
-/**************************************************************************
- *
- * Lockdep "implementation". Also see liblustre.h
- *
- **************************************************************************/
-
-struct lock_class_key {
-        ;
-};
-
-static inline void lockdep_set_class(void *lock, struct lock_class_key *key)
-{
-}
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16)
 
 /**************************************************************************
  *
@@ -145,14 +132,7 @@ static inline void lockdep_set_class(void *lock, struct lock_class_key *key)
  *
  **************************************************************************/
 
-#ifndef mutex
-# define mutex semaphore
-#endif
-
-static inline void mutex_lock_nested(struct mutex *mutex, unsigned int subclass)
-{
-        return down(mutex);
-}
+struct mutex;
 
 static inline void mutex_destroy(struct mutex *lock)
 {
@@ -168,8 +148,30 @@ static inline void mutex_destroy(struct mutex *lock)
  */
 static inline int mutex_is_locked(struct mutex *lock)
 {
-        return !!down_trylock(lock);
+        return 1;
 }
-#endif
+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16) */
 
-#endif
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)
+
+/**************************************************************************
+ *
+ * Lockdep "implementation". Also see liblustre.h
+ *
+ **************************************************************************/
+
+struct lock_class_key {
+        ;
+};
+
+static inline void lockdep_set_class(void *lock, struct lock_class_key *key)
+{
+}
+
+/* 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)
+
+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18) */
+
+#endif /* __LIBCFS_LINUX_CFS_LOCK_H__ */
-- 
GitLab