• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/linux/linux-2.6/drivers/staging/dream/include/linux/
1/* drivers/staging/dream/include/linux/wakelock.h
2 *
3 * Copyright (C) 2007-2008 Google, Inc.
4 *
5 * This software is licensed under the terms of the GNU General Public
6 * License version 2, as published by the Free Software Foundation, and
7 * may be copied, distributed, and modified under those terms.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 * GNU General Public License for more details.
13 *
14 */
15
16#ifndef _LINUX_WAKELOCK_H
17#define _LINUX_WAKELOCK_H
18
19#include <linux/list.h>
20#include <linux/ktime.h>
21
22/* A wake_lock prevents the system from entering suspend or other low power
23 * states when active. If the type is set to WAKE_LOCK_SUSPEND, the wake_lock
24 * prevents a full system suspend. If the type is WAKE_LOCK_IDLE, low power
25 * states that cause large interrupt latencies or that disable a set of
26 * interrupts will not entered from idle until the wake_locks are released.
27 */
28
29enum {
30	WAKE_LOCK_SUSPEND, /* Prevent suspend */
31	WAKE_LOCK_IDLE,    /* Prevent low power idle */
32	WAKE_LOCK_TYPE_COUNT
33};
34
35struct wake_lock {
36#ifdef CONFIG_HAS_WAKELOCK
37	struct list_head    link;
38	int                 flags;
39	const char         *name;
40	unsigned long       expires;
41#ifdef CONFIG_WAKELOCK_STAT
42	struct {
43		int             count;
44		int             expire_count;
45		int             wakeup_count;
46		ktime_t         total_time;
47		ktime_t         prevent_suspend_time;
48		ktime_t         max_time;
49		ktime_t         last_time;
50	} stat;
51#endif
52#endif
53};
54
55#ifdef CONFIG_HAS_WAKELOCK
56
57void wake_lock_init(struct wake_lock *lock, int type, const char *name);
58void wake_lock_destroy(struct wake_lock *lock);
59void wake_lock(struct wake_lock *lock);
60void wake_lock_timeout(struct wake_lock *lock, long timeout);
61void wake_unlock(struct wake_lock *lock);
62
63/* wake_lock_active returns a non-zero value if the wake_lock is currently
64 * locked. If the wake_lock has a timeout, it does not check the timeout
65 * but if the timeout had aready been checked it will return 0.
66 */
67int wake_lock_active(struct wake_lock *lock);
68
69/* has_wake_lock returns 0 if no wake locks of the specified type are active,
70 * and non-zero if one or more wake locks are held. Specifically it returns
71 * -1 if one or more wake locks with no timeout are active or the
72 * number of jiffies until all active wake locks time out.
73 */
74long has_wake_lock(int type);
75
76#else
77
78static inline void wake_lock_init(struct wake_lock *lock, int type,
79					const char *name) {}
80static inline void wake_lock_destroy(struct wake_lock *lock) {}
81static inline void wake_lock(struct wake_lock *lock) {}
82static inline void wake_lock_timeout(struct wake_lock *lock, long timeout) {}
83static inline void wake_unlock(struct wake_lock *lock) {}
84
85static inline int wake_lock_active(struct wake_lock *lock) { return 0; }
86static inline long has_wake_lock(int type) { return 0; }
87
88#endif
89
90#endif
91