Commit | Line | Data |
---|---|---|
15a4bc17 GKH |
1 | /* |
2 | * OSKA Linux implementation -- mutexes | |
3 | * | |
4 | * Copyright (C) 2007 Cambridge Silicon Radio Ltd. | |
5 | * | |
6 | * Refer to LICENSE.txt included with this source code for details on | |
7 | * the license terms. | |
8 | */ | |
9 | #ifndef __OSKA_LINUX_MUTEX_H | |
10 | #define __OSKA_LINUX_MUTEX_H | |
11 | ||
12 | #include <linux/kernel.h> | |
13 | #include <linux/mutex.h> | |
7a72e416 | 14 | #include <linux/semaphore.h> |
15a4bc17 | 15 | |
15a4bc17 GKH |
16 | |
17 | /* Real mutexes were only added to 2.6.16 so use semaphores | |
18 | instead. */ | |
19 | typedef struct semaphore os_mutex_t; | |
20 | ||
21 | static inline void os_mutex_init(os_mutex_t *mutex) | |
22 | { | |
23 | //init_MUTEX(mutex); | |
24 | sema_init(mutex, 1); | |
25 | } | |
26 | ||
27 | static inline void os_mutex_destroy(os_mutex_t *mutex) | |
28 | { | |
29 | /* no op */ | |
30 | } | |
31 | ||
32 | static inline void os_mutex_lock(os_mutex_t *mutex) | |
33 | { | |
34 | down(mutex); | |
35 | } | |
36 | ||
37 | static inline void os_mutex_unlock(os_mutex_t *mutex) | |
38 | { | |
39 | up(mutex); | |
40 | } | |
41 | ||
42 | #endif /* __OSKA_LINUX_MUTEX_H */ |