29 #ifndef __EC_LOCKS_H__ 30 #define __EC_LOCKS_H__ 33 #include <linux/version.h> 35 #include <linux/semaphore.h> 41 #include <linux/rtmutex.h> 43 typedef struct rt_mutex ec_lock_t;
45 static inline void ec_lock_init(ec_lock_t *sem) { rt_mutex_init(sem); }
46 static inline void ec_lock_down(ec_lock_t *sem) { rt_mutex_lock(sem); }
47 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 34) 48 static inline int ec_lock_down_interruptible(ec_lock_t *sem) {
49 return rt_mutex_lock_interruptible(sem);
52 static inline int ec_lock_down_interruptible(ec_lock_t *sem) {
53 return rt_mutex_lock_interruptible(sem, 1);
56 static inline void ec_lock_up(ec_lock_t *sem) { rt_mutex_unlock(sem); }
60 typedef struct semaphore ec_lock_t;
62 static inline void ec_lock_init(ec_lock_t *sem) { sema_init(sem, 1); }
63 static inline void ec_lock_down(ec_lock_t *sem) { down(sem); }
64 static inline int ec_lock_down_interruptible(ec_lock_t *sem) {
65 return down_interruptible(sem);
67 static inline void ec_lock_up(ec_lock_t *sem) { up(sem); }
Global definitions and macros.