]> git.openfabrics.org - ~emulex/for-vlad/old/compat.git/commitdiff
compat: Fixes missing sem member in struct device for RT PREEMPT prior to 2.6.34
authorBlaise Gassend <blaise@willowgarage.com>
Fri, 22 Oct 2010 09:32:04 +0000 (02:32 -0700)
committerLuis R. Rodriguez <lrodriguez@atheros.com>
Fri, 22 Oct 2010 09:32:04 +0000 (02:32 -0700)
The RT PREEMPT patch eliminates the sem member in struct device
breaking device_lock, device_unlock and device_trylock in kernels
prior to 2.6.34. The attached patch replaces the use of sem by a use
of mutex.

Signed-off-by: Blaise Gassend <blaise@willowgarage.com>
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
include/linux/compat-2.6.34.h

index 336c61b261695fc5014917e80c3f50c576dc3c0d..1cfd6e5cda1321217c728355c2325f6d87c51f27 100644 (file)
@@ -142,17 +142,32 @@ do {                                                              \
 
 static inline void device_lock(struct device *dev)
 {
+#if defined(CONFIG_NONE) || defined(CONFIG_PREEMPT_RT) || \
+    defined(CONFIG_PREEMPT_VOLUNTARY) || defined(CONFIG_PREEMPT_DESKTOP)
+        mutex_lock(&dev->parent->mutex);
+#else
        down(&dev->sem);
+#endif
 }
 
 static inline int device_trylock(struct device *dev)
 {
+#if defined(CONFIG_NONE) || defined(CONFIG_PREEMPT_RT) || \
+    defined(CONFIG_PREEMPT_VOLUNTARY) || defined(CONFIG_PREEMPT_DESKTOP)
+       return mutex_trylock(&dev->mutex);
+#else
        return down_trylock(&dev->sem);
+#endif
 }
 
 static inline void device_unlock(struct device *dev)
 {
+#if defined(CONFIG_NONE) || defined(CONFIG_PREEMPT_RT) || \
+    defined(CONFIG_PREEMPT_VOLUNTARY) || defined(CONFIG_PREEMPT_DESKTOP)
+        mutex_unlock(&dev->mutex);
+#else
        up(&dev->sem);
+#endif
 }
 
 #if defined(CONFIG_PCMCIA) || defined(CONFIG_PCMCIA_MODULE)