summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorShaun Ruffell <sruffell@digium.com>2011-06-02 20:01:24 +0000
committerShaun Ruffell <sruffell@digium.com>2011-06-02 20:01:24 +0000
commitb2b5fdd4e80044f06426c29d6167535c79881777 (patch)
treef87d0fe4ced4dd7c1295b2a9d2d6e69ea32c9ecd /include
parentd47c063f42197ae1aa59a8f8512a4b52cb611aff (diff)
dahdi: Support "struct mutex" on pre 2.6.16 kernels.
'struct mutex' was introduced in 2.6.16. While DAHDI previously allowed statically allocated mutexes, this change is required in order to allow mutexes to be embedded in dynamically allocated structures on older kernels. Signed-off-by: Shaun Ruffell <sruffell@digium.com> Acked-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com> git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@9938 a0bf4364-ded3-4de4-8d8a-66a801d63aff
Diffstat (limited to 'include')
-rw-r--r--include/dahdi/kernel.h13
1 files changed, 10 insertions, 3 deletions
diff --git a/include/dahdi/kernel.h b/include/dahdi/kernel.h
index 69f883e..33b19cd 100644
--- a/include/dahdi/kernel.h
+++ b/include/dahdi/kernel.h
@@ -1381,9 +1381,16 @@ typedef u32 __bitwise pm_message_t;
#endif
#ifndef DEFINE_MUTEX
-#define DEFINE_MUTEX DEFINE_SEMAPHORE
-#define mutex_lock(_x) down(_x)
-#define mutex_unlock(_x) up(_x)
+struct mutex {
+ struct semaphore sem;
+};
+#define DEFINE_MUTEX(name) \
+ struct mutex name = { \
+ .sem = __SEMAPHORE_INITIALIZER((name).sem, 1), \
+ }
+#define mutex_lock(_x) down(&(_x)->sem)
+#define mutex_unlock(_x) up(&(_x)->sem)
+#define mutex_init(_x) sema_init(&(_x)->sem, 1)
#endif
#ifndef DEFINE_PCI_DEVICE_TABLE