1 From eef7f012d480142a3eccff91e0ae73ecb13220b3 Mon Sep 17 00:00:00 2001
2 From: =?utf-8?q?Arve=20Hj=C3=B8nnev=C3=A5g?= <arve@android.com>
3 Date: Tue, 9 Sep 2008 22:14:34 -0700
4 Subject: [PATCH 066/134] PM: Implement wakelock api.
6 Content-Type: text/plain; charset=utf-8
7 Content-Transfer-Encoding: 8bit
9 PM: wakelock: Replace expire work with a timer
11 The expire work function did not work in the normal case.
13 Signed-off-by: Arve Hjønnevåg <arve@android.com>
15 kernel/power/Kconfig | 19 ++
16 kernel/power/Makefile | 1 +
17 kernel/power/power.h | 7 +
18 kernel/power/wakelock.c | 598 +++++++++++++++++++++++++++++++++++++++++++++++
19 4 files changed, 625 insertions(+), 0 deletions(-)
20 create mode 100644 kernel/power/wakelock.c
22 --- a/kernel/power/Kconfig
23 +++ b/kernel/power/Kconfig
24 @@ -116,6 +116,25 @@ config SUSPEND_FREEZER
26 Turning OFF this setting is NOT recommended! If in doubt, say Y.
33 + depends on PM && RTC_CLASS
37 + Enable wakelocks. When user space request a sleep state the
38 + sleep request will be delayed until no wake locks are held.
41 + bool "Wake lock stats"
45 + Report wake lock stats in /proc/wakelocks
48 bool "Hibernation (aka 'suspend to disk')"
49 depends on PM && SWAP && ARCH_HIBERNATION_POSSIBLE
50 --- a/kernel/power/Makefile
51 +++ b/kernel/power/Makefile
53 obj-$(CONFIG_PM) += main.o
54 obj-$(CONFIG_PM_SLEEP) += console.o
55 obj-$(CONFIG_FREEZER) += process.o
56 +obj-$(CONFIG_WAKELOCK) += wakelock.o
57 obj-$(CONFIG_HIBERNATION) += swsusp.o disk.o snapshot.o swap.o user.o
59 obj-$(CONFIG_MAGIC_SYSRQ) += poweroff.o
60 --- a/kernel/power/power.h
61 +++ b/kernel/power/power.h
62 @@ -223,3 +223,10 @@ static inline void suspend_thaw_processe
67 +#ifdef CONFIG_WAKELOCK
68 +/* kernel/power/wakelock.c */
69 +extern struct workqueue_struct *suspend_work_queue;
70 +extern struct wake_lock main_wake_lock;
71 +extern suspend_state_t requested_suspend_state;
74 +++ b/kernel/power/wakelock.c
76 +/* kernel/power/wakelock.c
78 + * Copyright (C) 2005-2008 Google, Inc.
80 + * This software is licensed under the terms of the GNU General Public
81 + * License version 2, as published by the Free Software Foundation, and
82 + * may be copied, distributed, and modified under those terms.
84 + * This program is distributed in the hope that it will be useful,
85 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
86 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
87 + * GNU General Public License for more details.
91 +#include <linux/module.h>
92 +#include <linux/platform_device.h>
93 +#include <linux/rtc.h>
94 +#include <linux/suspend.h>
95 +#include <linux/syscalls.h> /* sys_sync */
96 +#include <linux/wakelock.h>
97 +#ifdef CONFIG_WAKELOCK_STAT
98 +#include <linux/proc_fs.h>
103 + DEBUG_EXIT_SUSPEND = 1U << 0,
104 + DEBUG_WAKEUP = 1U << 1,
105 + DEBUG_SUSPEND = 1U << 2,
106 + DEBUG_EXPIRE = 1U << 3,
107 + DEBUG_WAKE_LOCK = 1U << 4,
109 +static int debug_mask = DEBUG_EXIT_SUSPEND | DEBUG_WAKEUP;
110 +module_param_named(debug_mask, debug_mask, int, S_IRUGO | S_IWUSR | S_IWGRP);
112 +#define WAKE_LOCK_TYPE_MASK (0x0f)
113 +#define WAKE_LOCK_INITIALIZED (1U << 8)
114 +#define WAKE_LOCK_ACTIVE (1U << 9)
115 +#define WAKE_LOCK_AUTO_EXPIRE (1U << 10)
116 +#define WAKE_LOCK_PREVENTING_SUSPEND (1U << 11)
118 +static DEFINE_SPINLOCK(list_lock);
119 +static LIST_HEAD(inactive_locks);
120 +static struct list_head active_wake_locks[WAKE_LOCK_TYPE_COUNT];
121 +static int current_event_num;
122 +struct workqueue_struct *suspend_work_queue;
123 +struct wake_lock main_wake_lock;
124 +suspend_state_t requested_suspend_state = PM_SUSPEND_MEM;
125 +static struct wake_lock unknown_wakeup;
127 +#ifdef CONFIG_WAKELOCK_STAT
128 +static struct wake_lock deleted_wake_locks;
129 +static ktime_t last_sleep_time_update;
130 +static int wait_for_wakeup;
132 +int get_expired_time(struct wake_lock *lock, ktime_t *expire_time)
134 + struct timespec ts;
135 + struct timespec kt;
136 + struct timespec tomono;
137 + struct timespec delta;
141 + if (!(lock->flags & WAKE_LOCK_AUTO_EXPIRE))
144 + seq = read_seqbegin(&xtime_lock);
145 + timeout = lock->expires - jiffies;
148 + kt = current_kernel_time();
149 + tomono = wall_to_monotonic;
150 + } while (read_seqretry(&xtime_lock, seq));
151 + jiffies_to_timespec(-timeout, &delta);
152 + set_normalized_timespec(&ts, kt.tv_sec + tomono.tv_sec - delta.tv_sec,
153 + kt.tv_nsec + tomono.tv_nsec - delta.tv_nsec);
154 + *expire_time = timespec_to_ktime(ts);
159 +static int print_lock_stat(char *buf, struct wake_lock *lock)
161 + int lock_count = lock->stat.count;
162 + int expire_count = lock->stat.expire_count;
163 + ktime_t active_time = ktime_set(0, 0);
164 + ktime_t total_time = lock->stat.total_time;
165 + ktime_t max_time = lock->stat.max_time;
166 + ktime_t prevent_suspend_time = lock->stat.prevent_suspend_time;
167 + if (lock->flags & WAKE_LOCK_ACTIVE) {
168 + ktime_t now, add_time;
169 + int expired = get_expired_time(lock, &now);
172 + add_time = ktime_sub(now, lock->stat.last_time);
175 + active_time = add_time;
178 + total_time = ktime_add(total_time, add_time);
179 + if (lock->flags & WAKE_LOCK_PREVENTING_SUSPEND)
180 + prevent_suspend_time = ktime_add(prevent_suspend_time,
181 + ktime_sub(now, last_sleep_time_update));
182 + if (add_time.tv64 > max_time.tv64)
183 + max_time = add_time;
186 + return sprintf(buf, "\"%s\"\t%d\t%d\t%d\t%lld\t%lld\t%lld\t%lld\t"
187 + "%lld\n", lock->name, lock_count, expire_count,
188 + lock->stat.wakeup_count, ktime_to_ns(active_time),
189 + ktime_to_ns(total_time),
190 + ktime_to_ns(prevent_suspend_time), ktime_to_ns(max_time),
191 + ktime_to_ns(lock->stat.last_time));
195 +static int wakelocks_read_proc(char *page, char **start, off_t off,
196 + int count, int *eof, void *data)
198 + unsigned long irqflags;
199 + struct wake_lock *lock;
204 + spin_lock_irqsave(&list_lock, irqflags);
206 + p += sprintf(p, "name\tcount\texpire_count\twake_count\tactive_since"
207 + "\ttotal_time\tsleep_time\tmax_time\tlast_change\n");
208 + list_for_each_entry(lock, &inactive_locks, link) {
209 + p += print_lock_stat(p, lock);
211 + for (type = 0; type < WAKE_LOCK_TYPE_COUNT; type++) {
212 + list_for_each_entry(lock, &active_wake_locks[type], link)
213 + p += print_lock_stat(p, lock);
215 + spin_unlock_irqrestore(&list_lock, irqflags);
217 + *start = page + off;
225 + return len < count ? len : count;
228 +static void wake_unlock_stat_locked(struct wake_lock *lock, int expired)
232 + if (!(lock->flags & WAKE_LOCK_ACTIVE))
234 + if (get_expired_time(lock, &now))
238 + lock->stat.count++;
240 + lock->stat.expire_count++;
241 + duration = ktime_sub(now, lock->stat.last_time);
242 + lock->stat.total_time = ktime_add(lock->stat.total_time, duration);
243 + if (ktime_to_ns(duration) > ktime_to_ns(lock->stat.max_time))
244 + lock->stat.max_time = duration;
245 + lock->stat.last_time = ktime_get();
246 + if (lock->flags & WAKE_LOCK_PREVENTING_SUSPEND) {
247 + duration = ktime_sub(now, last_sleep_time_update);
248 + lock->stat.prevent_suspend_time = ktime_add(
249 + lock->stat.prevent_suspend_time, duration);
250 + lock->flags &= ~WAKE_LOCK_PREVENTING_SUSPEND;
254 +static void update_sleep_wait_stats_locked(int done)
256 + struct wake_lock *lock;
257 + ktime_t now, etime, elapsed, add;
261 + elapsed = ktime_sub(now, last_sleep_time_update);
262 + list_for_each_entry(lock, &active_wake_locks[WAKE_LOCK_SUSPEND], link) {
263 + expired = get_expired_time(lock, &etime);
264 + if (lock->flags & WAKE_LOCK_PREVENTING_SUSPEND) {
266 + add = ktime_sub(etime, last_sleep_time_update);
269 + lock->stat.prevent_suspend_time = ktime_add(
270 + lock->stat.prevent_suspend_time, add);
272 + if (done || expired)
273 + lock->flags &= ~WAKE_LOCK_PREVENTING_SUSPEND;
275 + lock->flags |= WAKE_LOCK_PREVENTING_SUSPEND;
277 + last_sleep_time_update = now;
282 +static void expire_wake_lock(struct wake_lock *lock)
284 +#ifdef CONFIG_WAKELOCK_STAT
285 + wake_unlock_stat_locked(lock, 1);
287 + lock->flags &= ~(WAKE_LOCK_ACTIVE | WAKE_LOCK_AUTO_EXPIRE);
288 + list_del(&lock->link);
289 + list_add(&lock->link, &inactive_locks);
290 + if (debug_mask & (DEBUG_WAKE_LOCK | DEBUG_EXPIRE))
291 + pr_info("expired wake lock %s\n", lock->name);
294 +static void print_active_locks(int type)
296 + unsigned long irqflags;
297 + struct wake_lock *lock;
299 + BUG_ON(type >= WAKE_LOCK_TYPE_COUNT);
300 + spin_lock_irqsave(&list_lock, irqflags);
301 + list_for_each_entry(lock, &active_wake_locks[type], link) {
302 + if (lock->flags & WAKE_LOCK_AUTO_EXPIRE) {
303 + long timeout = lock->expires - jiffies;
305 + pr_info("wake lock %s, expired\n", lock->name);
307 + pr_info("active wake lock %s, time left %ld\n",
308 + lock->name, timeout);
310 + pr_info("active wake lock %s\n", lock->name);
312 + spin_unlock_irqrestore(&list_lock, irqflags);
315 +static long has_wake_lock_locked(int type)
317 + struct wake_lock *lock, *n;
318 + long max_timeout = 0;
320 + BUG_ON(type >= WAKE_LOCK_TYPE_COUNT);
321 + list_for_each_entry_safe(lock, n, &active_wake_locks[type], link) {
322 + if (lock->flags & WAKE_LOCK_AUTO_EXPIRE) {
323 + long timeout = lock->expires - jiffies;
325 + expire_wake_lock(lock);
326 + else if (timeout > max_timeout)
327 + max_timeout = timeout;
331 + return max_timeout;
334 +long has_wake_lock(int type)
337 + unsigned long irqflags;
338 + spin_lock_irqsave(&list_lock, irqflags);
339 + ret = has_wake_lock_locked(type);
340 + spin_unlock_irqrestore(&list_lock, irqflags);
344 +static void suspend(struct work_struct *work)
347 + int entry_event_num;
349 + if (has_wake_lock(WAKE_LOCK_SUSPEND)) {
350 + if (debug_mask & DEBUG_SUSPEND)
351 + pr_info("suspend: abort suspend\n");
355 + entry_event_num = current_event_num;
357 + if (debug_mask & DEBUG_SUSPEND)
358 + pr_info("suspend: enter suspend\n");
359 + ret = pm_suspend(requested_suspend_state);
360 + if (debug_mask & DEBUG_EXIT_SUSPEND) {
361 + struct timespec ts;
362 + struct rtc_time tm;
363 + getnstimeofday(&ts);
364 + rtc_time_to_tm(ts.tv_sec, &tm);
365 + pr_info("suspend: exit suspend, ret = %d "
366 + "(%d-%02d-%02d %02d:%02d:%02d.%09lu UTC)\n", ret,
367 + tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
368 + tm.tm_hour, tm.tm_min, tm.tm_sec, ts.tv_nsec);
370 + if (current_event_num == entry_event_num) {
371 + if (debug_mask & DEBUG_SUSPEND)
372 + pr_info("suspend: pm_suspend returned with no event\n");
373 + wake_lock_timeout(&unknown_wakeup, HZ / 2);
376 +static DECLARE_WORK(suspend_work, suspend);
378 +static void expire_wake_locks(unsigned long data)
381 + unsigned long irqflags;
382 + if (debug_mask & DEBUG_EXPIRE)
383 + pr_info("expire_wake_locks: start\n");
384 + if (debug_mask & DEBUG_SUSPEND)
385 + print_active_locks(WAKE_LOCK_SUSPEND);
386 + spin_lock_irqsave(&list_lock, irqflags);
387 + has_lock = has_wake_lock_locked(WAKE_LOCK_SUSPEND);
388 + if (debug_mask & DEBUG_EXPIRE)
389 + pr_info("expire_wake_locks: done, has_lock %ld\n", has_lock);
391 + queue_work(suspend_work_queue, &suspend_work);
392 + spin_unlock_irqrestore(&list_lock, irqflags);
394 +static DEFINE_TIMER(expire_timer, expire_wake_locks, 0, 0);
396 +static int power_suspend_late(struct platform_device *pdev, pm_message_t state)
398 + int ret = has_wake_lock(WAKE_LOCK_SUSPEND) ? -EAGAIN : 0;
399 +#ifdef CONFIG_WAKELOCK_STAT
400 + wait_for_wakeup = 1;
402 + if (debug_mask & DEBUG_SUSPEND)
403 + pr_info("power_suspend_late return %d\n", ret);
407 +static struct platform_driver power_driver = {
408 + .driver.name = "power",
409 + .suspend_late = power_suspend_late,
411 +static struct platform_device power_device = {
415 +void wake_lock_init(struct wake_lock *lock, int type, const char *name)
417 + unsigned long irqflags = 0;
421 + BUG_ON(!lock->name);
423 + if (debug_mask & DEBUG_WAKE_LOCK)
424 + pr_info("wake_lock_init name=%s\n", lock->name);
425 +#ifdef CONFIG_WAKELOCK_STAT
426 + lock->stat.count = 0;
427 + lock->stat.expire_count = 0;
428 + lock->stat.wakeup_count = 0;
429 + lock->stat.total_time = ktime_set(0, 0);
430 + lock->stat.prevent_suspend_time = ktime_set(0, 0);
431 + lock->stat.max_time = ktime_set(0, 0);
432 + lock->stat.last_time = ktime_set(0, 0);
434 + lock->flags = (type & WAKE_LOCK_TYPE_MASK) | WAKE_LOCK_INITIALIZED;
436 + INIT_LIST_HEAD(&lock->link);
437 + spin_lock_irqsave(&list_lock, irqflags);
438 + list_add(&lock->link, &inactive_locks);
439 + spin_unlock_irqrestore(&list_lock, irqflags);
441 +EXPORT_SYMBOL(wake_lock_init);
443 +void wake_lock_destroy(struct wake_lock *lock)
445 + unsigned long irqflags;
446 + if (debug_mask & DEBUG_WAKE_LOCK)
447 + pr_info("wake_lock_destroy name=%s\n", lock->name);
448 + spin_lock_irqsave(&list_lock, irqflags);
449 + lock->flags &= ~WAKE_LOCK_INITIALIZED;
450 +#ifdef CONFIG_WAKELOCK_STAT
451 + if (lock->stat.count) {
452 + deleted_wake_locks.stat.count += lock->stat.count;
453 + deleted_wake_locks.stat.expire_count += lock->stat.expire_count;
454 + deleted_wake_locks.stat.total_time =
455 + ktime_add(deleted_wake_locks.stat.total_time,
456 + lock->stat.total_time);
457 + deleted_wake_locks.stat.prevent_suspend_time =
458 + ktime_add(deleted_wake_locks.stat.prevent_suspend_time,
459 + lock->stat.prevent_suspend_time);
460 + deleted_wake_locks.stat.max_time =
461 + ktime_add(deleted_wake_locks.stat.max_time,
462 + lock->stat.max_time);
465 + list_del(&lock->link);
466 + spin_unlock_irqrestore(&list_lock, irqflags);
468 +EXPORT_SYMBOL(wake_lock_destroy);
470 +static void wake_lock_internal(
471 + struct wake_lock *lock, long timeout, int has_timeout)
474 + unsigned long irqflags;
477 + spin_lock_irqsave(&list_lock, irqflags);
478 + type = lock->flags & WAKE_LOCK_TYPE_MASK;
479 + BUG_ON(type >= WAKE_LOCK_TYPE_COUNT);
480 + BUG_ON(!(lock->flags & WAKE_LOCK_INITIALIZED));
481 +#ifdef CONFIG_WAKELOCK_STAT
482 + if (type == WAKE_LOCK_SUSPEND && wait_for_wakeup) {
483 + if (debug_mask & DEBUG_WAKEUP)
484 + pr_info("wakeup wake lock: %s\n", lock->name);
485 + wait_for_wakeup = 0;
486 + lock->stat.wakeup_count++;
488 + if ((lock->flags & WAKE_LOCK_AUTO_EXPIRE) &&
489 + (long)(lock->expires - jiffies) <= 0) {
490 + wake_unlock_stat_locked(lock, 0);
491 + lock->stat.last_time = ktime_get();
494 + if (!(lock->flags & WAKE_LOCK_ACTIVE)) {
495 + lock->flags |= WAKE_LOCK_ACTIVE;
496 +#ifdef CONFIG_WAKELOCK_STAT
497 + lock->stat.last_time = ktime_get();
500 + list_del(&lock->link);
502 + if (debug_mask & DEBUG_WAKE_LOCK)
503 + pr_info("wake_lock: %s, type %d, timeout %ld.%03lu\n",
504 + lock->name, type, timeout / HZ,
505 + (timeout % HZ) * MSEC_PER_SEC / HZ);
506 + lock->expires = jiffies + timeout;
507 + lock->flags |= WAKE_LOCK_AUTO_EXPIRE;
508 + list_add_tail(&lock->link, &active_wake_locks[type]);
510 + if (debug_mask & DEBUG_WAKE_LOCK)
511 + pr_info("wake_lock: %s, type %d\n", lock->name, type);
512 + lock->expires = LONG_MAX;
513 + lock->flags &= ~WAKE_LOCK_AUTO_EXPIRE;
514 + list_add(&lock->link, &active_wake_locks[type]);
516 + if (type == WAKE_LOCK_SUSPEND) {
517 + current_event_num++;
518 +#ifdef CONFIG_WAKELOCK_STAT
519 + if (lock == &main_wake_lock)
520 + update_sleep_wait_stats_locked(1);
521 + else if (!wake_lock_active(&main_wake_lock))
522 + update_sleep_wait_stats_locked(0);
525 + expire_in = has_wake_lock_locked(type);
528 + if (expire_in > 0) {
529 + if (debug_mask & DEBUG_EXPIRE)
530 + pr_info("wake_lock: %s, start expire timer, "
531 + "%ld\n", lock->name, expire_in);
532 + mod_timer(&expire_timer, jiffies + expire_in);
534 + if (del_timer(&expire_timer))
535 + if (debug_mask & DEBUG_EXPIRE)
536 + pr_info("wake_lock: %s, stop expire timer\n",
538 + if (expire_in == 0)
539 + queue_work(suspend_work_queue, &suspend_work);
542 + spin_unlock_irqrestore(&list_lock, irqflags);
545 +void wake_lock(struct wake_lock *lock)
547 + wake_lock_internal(lock, 0, 0);
549 +EXPORT_SYMBOL(wake_lock);
551 +void wake_lock_timeout(struct wake_lock *lock, long timeout)
553 + wake_lock_internal(lock, timeout, 1);
555 +EXPORT_SYMBOL(wake_lock_timeout);
557 +void wake_unlock(struct wake_lock *lock)
560 + unsigned long irqflags;
561 + spin_lock_irqsave(&list_lock, irqflags);
562 + type = lock->flags & WAKE_LOCK_TYPE_MASK;
563 +#ifdef CONFIG_WAKELOCK_STAT
564 + wake_unlock_stat_locked(lock, 0);
566 + if (debug_mask & DEBUG_WAKE_LOCK)
567 + pr_info("wake_unlock: %s\n", lock->name);
568 + lock->flags &= ~(WAKE_LOCK_ACTIVE | WAKE_LOCK_AUTO_EXPIRE);
569 + list_del(&lock->link);
570 + list_add(&lock->link, &inactive_locks);
571 + if (type == WAKE_LOCK_SUSPEND) {
572 + long has_lock = has_wake_lock_locked(type);
573 + if (has_lock > 0) {
574 + if (debug_mask & DEBUG_EXPIRE)
575 + pr_info("wake_unlock: %s, start expire timer, "
576 + "%ld\n", lock->name, has_lock);
577 + mod_timer(&expire_timer, jiffies + has_lock);
579 + if (del_timer(&expire_timer))
580 + if (debug_mask & DEBUG_EXPIRE)
581 + pr_info("wake_unlock: %s, stop expire "
582 + "timer\n", lock->name);
584 + queue_work(suspend_work_queue, &suspend_work);
586 + if (lock == &main_wake_lock) {
587 + if (debug_mask & DEBUG_SUSPEND)
588 + print_active_locks(WAKE_LOCK_SUSPEND);
589 +#ifdef CONFIG_WAKELOCK_STAT
590 + update_sleep_wait_stats_locked(0);
594 + spin_unlock_irqrestore(&list_lock, irqflags);
596 +EXPORT_SYMBOL(wake_unlock);
598 +int wake_lock_active(struct wake_lock *lock)
600 + return !!(lock->flags & WAKE_LOCK_ACTIVE);
602 +EXPORT_SYMBOL(wake_lock_active);
604 +static int __init wakelocks_init(void)
609 + for (i = 0; i < ARRAY_SIZE(active_wake_locks); i++)
610 + INIT_LIST_HEAD(&active_wake_locks[i]);
612 +#ifdef CONFIG_WAKELOCK_STAT
613 + wake_lock_init(&deleted_wake_locks, WAKE_LOCK_SUSPEND,
614 + "deleted_wake_locks");
616 + wake_lock_init(&main_wake_lock, WAKE_LOCK_SUSPEND, "main");
617 + wake_lock(&main_wake_lock);
618 + wake_lock_init(&unknown_wakeup, WAKE_LOCK_SUSPEND, "unknown_wakeups");
620 + ret = platform_device_register(&power_device);
622 + pr_err("wakelocks_init: platform_device_register failed\n");
623 + goto err_platform_device_register;
625 + ret = platform_driver_register(&power_driver);
627 + pr_err("wakelocks_init: platform_driver_register failed\n");
628 + goto err_platform_driver_register;
631 + suspend_work_queue = create_singlethread_workqueue("suspend");
632 + if (suspend_work_queue == NULL) {
634 + goto err_suspend_work_queue;
637 +#ifdef CONFIG_WAKELOCK_STAT
638 + create_proc_read_entry("wakelocks", S_IRUGO, NULL,
639 + wakelocks_read_proc, NULL);
644 +err_suspend_work_queue:
645 + platform_driver_unregister(&power_driver);
646 +err_platform_driver_register:
647 + platform_device_unregister(&power_device);
648 +err_platform_device_register:
649 + wake_lock_destroy(&unknown_wakeup);
650 + wake_lock_destroy(&main_wake_lock);
651 +#ifdef CONFIG_WAKELOCK_STAT
652 + wake_lock_destroy(&deleted_wake_locks);
657 +static void __exit wakelocks_exit(void)
659 +#ifdef CONFIG_WAKELOCK_STAT
660 + remove_proc_entry("wakelocks", NULL);
662 + destroy_workqueue(suspend_work_queue);
663 + platform_driver_unregister(&power_driver);
664 + platform_device_unregister(&power_device);
665 + wake_lock_destroy(&unknown_wakeup);
666 + wake_lock_destroy(&main_wake_lock);
667 +#ifdef CONFIG_WAKELOCK_STAT
668 + wake_lock_destroy(&deleted_wake_locks);
672 +core_initcall(wakelocks_init);
673 +module_exit(wakelocks_exit);