add the 'goldfish' target, useful for experimenting with virtual phone hardware ...
[openwrt/openwrt.git] / target / linux / goldfish / patches-2.6.30 / 0064-PM-Add-wake-lock-api.patch
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.
5
6 ---
7 include/linux/wakelock.h | 91 ++++++++++++++++++++++++++++++++++++++++++++++
8 1 files changed, 91 insertions(+), 0 deletions(-)
9 create mode 100755 include/linux/wakelock.h
10
11 --- /dev/null
12 +++ b/include/linux/wakelock.h
13 @@ -0,0 +1,91 @@
14 +/* include/linux/wakelock.h
15 + *
16 + * Copyright (C) 2007-2008 Google, Inc.
17 + *
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.
21 + *
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.
26 + *
27 + */
28 +
29 +#ifndef _LINUX_WAKELOCK_H
30 +#define _LINUX_WAKELOCK_H
31 +
32 +#include <linux/list.h>
33 +#include <linux/ktime.h>
34 +
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.
40 + */
41 +
42 +enum {
43 + WAKE_LOCK_SUSPEND, /* Prevent suspend */
44 + WAKE_LOCK_IDLE, /* Prevent low power idle */
45 + WAKE_LOCK_TYPE_COUNT
46 +};
47 +
48 +struct wake_lock {
49 +#ifdef CONFIG_HAS_WAKELOCK
50 + struct list_head link;
51 + int flags;
52 + const char *name;
53 + unsigned long expires;
54 +#ifdef CONFIG_WAKELOCK_STAT
55 + struct {
56 + int count;
57 + int expire_count;
58 + int wakeup_count;
59 + ktime_t total_time;
60 + ktime_t prevent_suspend_time;
61 + ktime_t max_time;
62 + ktime_t last_time;
63 + } stat;
64 +#endif
65 +#endif
66 +};
67 +
68 +#ifdef CONFIG_HAS_WAKELOCK
69 +
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);
75 +
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.
79 + */
80 +int wake_lock_active(struct wake_lock *lock);
81 +
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.
86 + */
87 +long has_wake_lock(int type);
88 +
89 +#else
90 +
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) {}
97 +
98 +static inline int wake_lock_active(struct wake_lock *lock) { return 0; }
99 +static inline long has_wake_lock(int type) { return 0; }
100 +
101 +#endif
102 +
103 +#endif
104 +