1 From e93bd714c424d9fe907cb1d8ec5ce784767a3b16 Mon Sep 17 00:00:00 2001
2 From: =?utf-8?q?Arve=20Hj=C3=B8nnev=C3=A5g?= <arve@android.com>
3 Date: Fri, 26 Sep 2008 22:10:56 -0700
4 Subject: [PATCH 064/134] PM: Add wake lock api.
7 include/linux/wakelock.h | 91 ++++++++++++++++++++++++++++++++++++++++++++++
8 1 files changed, 91 insertions(+), 0 deletions(-)
9 create mode 100755 include/linux/wakelock.h
12 +++ b/include/linux/wakelock.h
14 +/* include/linux/wakelock.h
16 + * Copyright (C) 2007-2008 Google, Inc.
18 + * This software is licensed under the terms of the GNU General Public
19 + * License version 2, as published by the Free Software Foundation, and
20 + * may be copied, distributed, and modified under those terms.
22 + * This program is distributed in the hope that it will be useful,
23 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 + * GNU General Public License for more details.
29 +#ifndef _LINUX_WAKELOCK_H
30 +#define _LINUX_WAKELOCK_H
32 +#include <linux/list.h>
33 +#include <linux/ktime.h>
35 +/* A wake_lock prevents the system from entering suspend or other low power
36 + * states when active. If the type is set to WAKE_LOCK_SUSPEND, the wake_lock
37 + * prevents a full system suspend. If the type is WAKE_LOCK_IDLE, low power
38 + * states that cause large interrupt latencies or that disable a set of
39 + * interrupts will not entered from idle until the wake_locks are released.
43 + WAKE_LOCK_SUSPEND, /* Prevent suspend */
44 + WAKE_LOCK_IDLE, /* Prevent low power idle */
45 + WAKE_LOCK_TYPE_COUNT
49 +#ifdef CONFIG_HAS_WAKELOCK
50 + struct list_head link;
53 + unsigned long expires;
54 +#ifdef CONFIG_WAKELOCK_STAT
60 + ktime_t prevent_suspend_time;
68 +#ifdef CONFIG_HAS_WAKELOCK
70 +void wake_lock_init(struct wake_lock *lock, int type, const char *name);
71 +void wake_lock_destroy(struct wake_lock *lock);
72 +void wake_lock(struct wake_lock *lock);
73 +void wake_lock_timeout(struct wake_lock *lock, long timeout);
74 +void wake_unlock(struct wake_lock *lock);
76 +/* wake_lock_active returns a non-zero value if the wake_lock is currently
77 + * locked. If the wake_lock has a timeout, it does not check the timeout
78 + * but if the timeout had aready been checked it will return 0.
80 +int wake_lock_active(struct wake_lock *lock);
82 +/* has_wake_lock returns 0 if no wake locks of the specified type are active,
83 + * and non-zero if one or more wake locks are held. Specifically it returns
84 + * -1 if one or more wake locks with no timeout are active or the
85 + * number of jiffies until all active wake locks time out.
87 +long has_wake_lock(int type);
91 +static inline void wake_lock_init(struct wake_lock *lock, int type,
92 + const char *name) {}
93 +static inline void wake_lock_destroy(struct wake_lock *lock) {}
94 +static inline void wake_lock(struct wake_lock *lock) {}
95 +static inline void wake_lock_timeout(struct wake_lock *lock, long timeout) {}
96 +static inline void wake_unlock(struct wake_lock *lock) {}
98 +static inline int wake_lock_active(struct wake_lock *lock) { return 0; }
99 +static inline long has_wake_lock(int type) { return 0; }