| #ifndef _LINUX_WAKELOCK_H |
| #define _LINUX_WAKELOCK_H |
| |
| #include <linux/ktime.h> |
| #include <linux/device.h> |
| |
| struct wake_lock { |
| struct wakeup_source ws; |
| }; |
| |
| enum { |
| WAKE_LOCK_SUSPEND, |
| WAKE_LOCK_TYPE_COUNT |
| }; |
| |
| static inline void wake_lock_init(struct wake_lock *lock, int type, |
| const char *name) |
| { |
| wakeup_source_init(&lock->ws, name); |
| } |
| |
| static inline void wake_lock(struct wake_lock *lock) |
| { |
| __pm_stay_awake(&lock->ws); |
| } |
| |
| static inline void wake_unlock(struct wake_lock *lock) |
| { |
| __pm_relax(&lock->ws); |
| } |
| |
| static inline void wake_lock_timeout(struct wake_lock *lock, long timeout) |
| { |
| __pm_wakeup_event(&lock->ws, jiffies_to_msecs(timeout)); |
| } |
| |
| static inline int wake_lock_active(struct wake_lock *lock) |
| { |
| return lock->ws.active; |
| } |
| |
| static inline void wake_lock_destroy(struct wake_lock *lock) |
| { |
| wakeup_source_trash(&lock->ws); |
| } |
| |
| #endif |