summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorVarun Wadekar <vwadekar@nvidia.com>2012-07-23 13:32:23 +0530
committerVarun Wadekar <vwadekar@nvidia.com>2012-07-23 13:32:23 +0530
commit775625961b9578e347058b998e6088f45f9d1d9e (patch)
tree8721833b6c42b2bdaaf17433a92f2c8dee0533c6 /kernel
parentbe6e8ac6d2ede39e3cff5b53686095cd74e4c9bd (diff)
Revert "HACK: PM: Port early suspend functionality"
This reverts commit 228af00b84919ab817b619b13327fe36027ccdaf. Change-Id: I2ec45ca0bf42fac6d2ac754f1a1b2019ce90f20f Signed-off-by: Varun Wadekar <vwadekar@nvidia.com>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/power/Kconfig38
-rw-r--r--kernel/power/Makefile5
-rw-r--r--kernel/power/consoleearlysuspend.c78
-rw-r--r--kernel/power/earlysuspend.c190
-rw-r--r--kernel/power/fbearlysuspend.c39
-rw-r--r--kernel/power/main.c41
-rw-r--r--kernel/power/power.h15
-rw-r--r--kernel/power/suspend.c5
8 files changed, 11 insertions, 400 deletions
diff --git a/kernel/power/Kconfig b/kernel/power/Kconfig
index b5e1098d9cbc..3fe601b9db0e 100644
--- a/kernel/power/Kconfig
+++ b/kernel/power/Kconfig
@@ -26,9 +26,6 @@ config WAKELOCK
bool
default y
-config HAS_EARLYSUSPEND
- bool
-
config USER_WAKELOCK
bool "Userspace wake locks"
depends on PM_SLEEP
@@ -39,41 +36,6 @@ config USER_WAKELOCK
Write "lockname" to /sys/power/wake_unlock to unlock a user wake
lock.
-config EARLYSUSPEND
- bool "Early suspend"
- depends on WAKELOCK
- default y
- select HAS_EARLYSUSPEND
- ---help---
- Call early suspend handlers when the user requested sleep state
- changes.
-
-choice
- prompt "User-space screen access"
- default FB_EARLYSUSPEND if !FRAMEBUFFER_CONSOLE
- default CONSOLE_EARLYSUSPEND
- depends on HAS_EARLYSUSPEND
-
- config NO_USER_SPACE_SCREEN_ACCESS_CONTROL
- bool "None"
-
- config CONSOLE_EARLYSUSPEND
- bool "Console switch on early-suspend"
- depends on HAS_EARLYSUSPEND && VT
- ---help---
- Register early suspend handler to perform a console switch to
- when user-space should stop drawing to the screen and a switch
- back when it should resume.
-
- config FB_EARLYSUSPEND
- bool "Sysfs interface"
- depends on HAS_EARLYSUSPEND
- ---help---
- Register early suspend handler that notifies and waits for
- user-space through sysfs when user-space should stop drawing
- to the screen and notifies user-space when it should resume.
-endchoice
-
config HIBERNATE_CALLBACKS
bool
diff --git a/kernel/power/Makefile b/kernel/power/Makefile
index d09d10203056..06f947284ce7 100644
--- a/kernel/power/Makefile
+++ b/kernel/power/Makefile
@@ -10,8 +10,7 @@ obj-$(CONFIG_PM_TEST_SUSPEND) += suspend_test.o
obj-$(CONFIG_HIBERNATION) += hibernate.o snapshot.o swap.o user.o \
block_io.o
obj-$(CONFIG_USER_WAKELOCK) += userwakelock.o
-obj-$(CONFIG_EARLYSUSPEND) += earlysuspend.o
-obj-$(CONFIG_CONSOLE_EARLYSUSPEND) += consoleearlysuspend.o
-obj-$(CONFIG_FB_EARLYSUSPEND) += fbearlysuspend.o
+obj-$(CONFIG_SUSPEND_TIME) += suspend_time.o
+obj-y += fbearlysuspend.o
obj-$(CONFIG_MAGIC_SYSRQ) += poweroff.o
diff --git a/kernel/power/consoleearlysuspend.c b/kernel/power/consoleearlysuspend.c
deleted file mode 100644
index a3edcb267389..000000000000
--- a/kernel/power/consoleearlysuspend.c
+++ /dev/null
@@ -1,78 +0,0 @@
-/* kernel/power/consoleearlysuspend.c
- *
- * Copyright (C) 2005-2008 Google, Inc.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- */
-
-#include <linux/console.h>
-#include <linux/earlysuspend.h>
-#include <linux/kbd_kern.h>
-#include <linux/module.h>
-#include <linux/vt_kern.h>
-#include <linux/wait.h>
-
-#define EARLY_SUSPEND_CONSOLE (MAX_NR_CONSOLES-1)
-
-static int orig_fgconsole;
-static void console_early_suspend(struct early_suspend *h)
-{
- acquire_console_sem();
- orig_fgconsole = fg_console;
- if (vc_allocate(EARLY_SUSPEND_CONSOLE))
- goto err;
- if (set_console(EARLY_SUSPEND_CONSOLE))
- goto err;
- release_console_sem();
-
- if (vt_waitactive(EARLY_SUSPEND_CONSOLE + 1))
- pr_warning("console_early_suspend: Can't switch VCs.\n");
- return;
-err:
- pr_warning("console_early_suspend: Can't set console\n");
- release_console_sem();
-}
-
-static void console_late_resume(struct early_suspend *h)
-{
- int ret;
- acquire_console_sem();
- ret = set_console(orig_fgconsole);
- release_console_sem();
- if (ret) {
- pr_warning("console_late_resume: Can't set console.\n");
- return;
- }
-
- if (vt_waitactive(orig_fgconsole + 1))
- pr_warning("console_late_resume: Can't switch VCs.\n");
-}
-
-static struct early_suspend console_early_suspend_desc = {
- .level = EARLY_SUSPEND_LEVEL_STOP_DRAWING,
- .suspend = console_early_suspend,
- .resume = console_late_resume,
-};
-
-static int __init console_early_suspend_init(void)
-{
- register_early_suspend(&console_early_suspend_desc);
- return 0;
-}
-
-static void __exit console_early_suspend_exit(void)
-{
- unregister_early_suspend(&console_early_suspend_desc);
-}
-
-module_init(console_early_suspend_init);
-module_exit(console_early_suspend_exit);
-
diff --git a/kernel/power/earlysuspend.c b/kernel/power/earlysuspend.c
deleted file mode 100644
index cff3281ccc53..000000000000
--- a/kernel/power/earlysuspend.c
+++ /dev/null
@@ -1,190 +0,0 @@
-/* kernel/power/earlysuspend.c
- *
- * Copyright (C) 2005-2008 Google, Inc.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- */
-
-#include <linux/earlysuspend.h>
-#include <linux/module.h>
-#include <linux/mutex.h>
-#include <linux/rtc.h>
-#include <linux/syscalls.h> /* sys_sync */
-#include <linux/wakelock.h>
-#include <linux/workqueue.h>
-
-#include "power.h"
-
-enum {
- DEBUG_USER_STATE = 1U << 0,
- DEBUG_SUSPEND = 1U << 2,
- DEBUG_VERBOSE = 1U << 3,
-};
-static int debug_mask = DEBUG_USER_STATE;
-module_param_named(debug_mask, debug_mask, int, S_IRUGO | S_IWUSR | S_IWGRP);
-
-suspend_state_t requested_suspend_state = PM_SUSPEND_MEM;
-static DEFINE_MUTEX(early_suspend_lock);
-static LIST_HEAD(early_suspend_handlers);
-static void early_suspend(struct work_struct *work);
-static void late_resume(struct work_struct *work);
-static void suspend(struct work_struct *work);
-static DECLARE_WORK(early_suspend_work, early_suspend);
-static DECLARE_WORK(late_resume_work, late_resume);
-static DECLARE_WORK(suspend_work, suspend);
-static DEFINE_SPINLOCK(state_lock);
-enum {
- SUSPEND_REQUESTED = 0x1,
- SUSPENDED = 0x2,
- SUSPEND_REQUESTED_AND_SUSPENDED = SUSPEND_REQUESTED | SUSPENDED,
-};
-static int state;
-
-void register_early_suspend(struct early_suspend *handler)
-{
- struct list_head *pos;
-
- mutex_lock(&early_suspend_lock);
- list_for_each(pos, &early_suspend_handlers) {
- struct early_suspend *e;
- e = list_entry(pos, struct early_suspend, link);
- if (e->level > handler->level)
- break;
- }
- list_add_tail(&handler->link, pos);
- if ((state & SUSPENDED) && handler->suspend)
- handler->suspend(handler);
- mutex_unlock(&early_suspend_lock);
-}
-EXPORT_SYMBOL(register_early_suspend);
-
-void unregister_early_suspend(struct early_suspend *handler)
-{
- mutex_lock(&early_suspend_lock);
- list_del(&handler->link);
- mutex_unlock(&early_suspend_lock);
-}
-EXPORT_SYMBOL(unregister_early_suspend);
-
-static void suspend(struct work_struct *work)
-{
- pm_suspend(requested_suspend_state);
-}
-
-static void early_suspend(struct work_struct *work)
-{
- struct early_suspend *pos;
- unsigned long irqflags;
- int abort = 0;
-
- mutex_lock(&early_suspend_lock);
- spin_lock_irqsave(&state_lock, irqflags);
- if (state == SUSPEND_REQUESTED)
- state |= SUSPENDED;
- else
- abort = 1;
- spin_unlock_irqrestore(&state_lock, irqflags);
-
- if (abort) {
- if (debug_mask & DEBUG_SUSPEND)
- pr_info("early_suspend: abort, state %d\n", state);
- mutex_unlock(&early_suspend_lock);
- return;
- }
-
- if (debug_mask & DEBUG_SUSPEND)
- pr_info("early_suspend: call handlers\n");
- list_for_each_entry(pos, &early_suspend_handlers, link) {
- if (pos->suspend != NULL) {
- if (debug_mask & DEBUG_VERBOSE)
- pr_info("early_suspend: calling %pf\n", pos->suspend);
- pos->suspend(pos);
- }
- }
- mutex_unlock(&early_suspend_lock);
-
- if (debug_mask & DEBUG_SUSPEND)
- pr_info("early_suspend: sync\n");
-
- sys_sync();
- queue_work(suspend_work_queue, &suspend_work);
-}
-
-static void late_resume(struct work_struct *work)
-{
- struct early_suspend *pos;
- unsigned long irqflags;
- int abort = 0;
-
- mutex_lock(&early_suspend_lock);
- spin_lock_irqsave(&state_lock, irqflags);
- if (state == SUSPENDED)
- state &= ~SUSPENDED;
- else
- abort = 1;
- spin_unlock_irqrestore(&state_lock, irqflags);
-
- if (abort) {
- if (debug_mask & DEBUG_SUSPEND)
- pr_info("late_resume: abort, state %d\n", state);
- goto abort;
- }
- if (debug_mask & DEBUG_SUSPEND)
- pr_info("late_resume: call handlers\n");
- list_for_each_entry_reverse(pos, &early_suspend_handlers, link) {
- if (pos->resume != NULL) {
- if (debug_mask & DEBUG_VERBOSE)
- pr_info("late_resume: calling %pf\n", pos->resume);
-
- pos->resume(pos);
- }
- }
- if (debug_mask & DEBUG_SUSPEND)
- pr_info("late_resume: done\n");
-abort:
- mutex_unlock(&early_suspend_lock);
-}
-
-void request_suspend_state(suspend_state_t new_state)
-{
- unsigned long irqflags;
- int old_sleep;
-
- spin_lock_irqsave(&state_lock, irqflags);
- old_sleep = state & SUSPEND_REQUESTED;
- if (debug_mask & DEBUG_USER_STATE) {
- struct timespec ts;
- struct rtc_time tm;
- getnstimeofday(&ts);
- rtc_time_to_tm(ts.tv_sec, &tm);
- pr_info("request_suspend_state: %s (%d->%d) at %lld "
- "(%d-%02d-%02d %02d:%02d:%02d.%09lu UTC)\n",
- new_state != PM_SUSPEND_ON ? "sleep" : "wakeup",
- requested_suspend_state, new_state,
- ktime_to_ns(ktime_get()),
- tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
- tm.tm_hour, tm.tm_min, tm.tm_sec, ts.tv_nsec);
- }
- if (!old_sleep && new_state != PM_SUSPEND_ON) {
- state |= SUSPEND_REQUESTED;
- queue_work(suspend_work_queue, &early_suspend_work);
- } else if (old_sleep && new_state == PM_SUSPEND_ON) {
- state &= ~SUSPEND_REQUESTED;
- queue_work(suspend_work_queue, &late_resume_work);
- }
- requested_suspend_state = new_state;
- spin_unlock_irqrestore(&state_lock, irqflags);
-}
-
-suspend_state_t get_suspend_state(void)
-{
- return requested_suspend_state;
-}
diff --git a/kernel/power/fbearlysuspend.c b/kernel/power/fbearlysuspend.c
index 15137650149c..571b51a51175 100644
--- a/kernel/power/fbearlysuspend.c
+++ b/kernel/power/fbearlysuspend.c
@@ -13,7 +13,6 @@
*
*/
-#include <linux/earlysuspend.h>
#include <linux/module.h>
#include <linux/wait.h>
@@ -27,42 +26,6 @@ static enum {
FB_STATE_DRAWING_OK,
} fb_state;
-/* tell userspace to stop drawing, wait for it to stop */
-static void stop_drawing_early_suspend(struct early_suspend *h)
-{
- int ret;
- unsigned long irq_flags;
-
- spin_lock_irqsave(&fb_state_lock, irq_flags);
- fb_state = FB_STATE_REQUEST_STOP_DRAWING;
- spin_unlock_irqrestore(&fb_state_lock, irq_flags);
-
- wake_up_all(&fb_state_wq);
- ret = wait_event_timeout(fb_state_wq,
- fb_state == FB_STATE_STOPPED_DRAWING,
- HZ);
- if (unlikely(fb_state != FB_STATE_STOPPED_DRAWING))
- pr_warning("stop_drawing_early_suspend: timeout waiting for "
- "userspace to stop drawing\n");
-}
-
-/* tell userspace to start drawing */
-static void start_drawing_late_resume(struct early_suspend *h)
-{
- unsigned long irq_flags;
-
- spin_lock_irqsave(&fb_state_lock, irq_flags);
- fb_state = FB_STATE_DRAWING_OK;
- spin_unlock_irqrestore(&fb_state_lock, irq_flags);
- wake_up(&fb_state_wq);
-}
-
-static struct early_suspend stop_drawing_early_suspend_desc = {
- .level = EARLY_SUSPEND_LEVEL_STOP_DRAWING,
- .suspend = stop_drawing_early_suspend,
- .resume = start_drawing_late_resume,
-};
-
static ssize_t wait_for_fb_sleep_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf)
{
@@ -138,13 +101,11 @@ static int __init android_power_init(void)
return ret;
}
- register_early_suspend(&stop_drawing_early_suspend_desc);
return 0;
}
static void __exit android_power_exit(void)
{
- unregister_early_suspend(&stop_drawing_early_suspend_desc);
sysfs_remove_group(power_kobj, &attr_group);
}
diff --git a/kernel/power/main.c b/kernel/power/main.c
index c8a4b77764b3..7f3c91a634cd 100644
--- a/kernel/power/main.c
+++ b/kernel/power/main.c
@@ -21,7 +21,6 @@
DEFINE_MUTEX(pm_mutex);
#ifdef CONFIG_PM_SLEEP
-struct workqueue_struct *suspend_work_queue;
/* Routines for PM-transition notifications */
@@ -274,11 +273,7 @@ static ssize_t state_store(struct kobject *kobj, struct kobj_attribute *attr,
const char *buf, size_t n)
{
#ifdef CONFIG_SUSPEND
-#ifdef CONFIG_EARLYSUSPEND
- suspend_state_t state = PM_SUSPEND_ON;
-#else
suspend_state_t state = PM_SUSPEND_STANDBY;
-#endif
const char * const *s;
#endif
char *p;
@@ -296,18 +291,11 @@ static ssize_t state_store(struct kobject *kobj, struct kobj_attribute *attr,
#ifdef CONFIG_SUSPEND
for (s = &pm_states[state]; state < PM_SUSPEND_MAX; s++, state++) {
- if (*s && len == strlen(*s) && !strncmp(buf, *s, len))
+ if (*s && len == strlen(*s) && !strncmp(buf, *s, len)) {
+ error = pm_suspend(state);
break;
- }
- if (state < PM_SUSPEND_MAX && *s)
-#ifdef CONFIG_EARLYSUSPEND
- if (state == PM_SUSPEND_ON || valid_state(state)) {
- error = 0;
- request_suspend_state(state);
}
-#else
- error = enter_state(state);
-#endif
+ }
#endif
Exit:
@@ -457,28 +445,15 @@ static inline int pm_start_workqueue(void) { return 0; }
static int __init pm_init(void)
{
- int ret;
-
- suspend_work_queue = create_singlethread_workqueue("suspend");
- if (suspend_work_queue == NULL)
- return -ENOMEM;
-
- ret = pm_start_workqueue();
- if (ret)
- goto error;
-
+ int error = pm_start_workqueue();
+ if (error)
+ return error;
hibernate_image_size_init();
hibernate_reserved_size_init();
power_kobj = kobject_create_and_add("power", NULL);
- if (!power_kobj) {
- ret = -ENOMEM;
- goto error;
- }
+ if (!power_kobj)
+ return -ENOMEM;
return sysfs_create_group(power_kobj, &attr_group);
-
-error:
- destroy_workqueue(suspend_work_queue);
- return ret;
}
core_initcall(pm_init);
diff --git a/kernel/power/power.h b/kernel/power/power.h
index 39444230208a..c4ecb81cb4fe 100644
--- a/kernel/power/power.h
+++ b/kernel/power/power.h
@@ -177,13 +177,11 @@ extern const char *const pm_states[];
extern bool valid_state(suspend_state_t state);
extern int suspend_devices_and_enter(suspend_state_t state);
-extern int enter_state(suspend_state_t state);
#else /* !CONFIG_SUSPEND */
static inline int suspend_devices_and_enter(suspend_state_t state)
{
return -ENOSYS;
}
-static inline int enter_state(suspend_state_t state) { return -ENOSYS; }
static inline bool valid_state(suspend_state_t state) { return false; }
#endif /* !CONFIG_SUSPEND */
@@ -267,13 +265,6 @@ static inline void suspend_thaw_processes(void)
}
#endif
-#ifdef CONFIG_WAKELOCK
-/* kernel/power/wakelock.c */
-extern struct workqueue_struct *suspend_work_queue;
-extern struct wake_lock main_wake_lock;
-extern suspend_state_t requested_suspend_state;
-#endif
-
#ifdef CONFIG_USER_WAKELOCK
ssize_t wake_lock_show(struct kobject *kobj, struct kobj_attribute *attr,
char *buf);
@@ -284,9 +275,3 @@ ssize_t wake_unlock_show(struct kobject *kobj, struct kobj_attribute *attr,
ssize_t wake_unlock_store(struct kobject *kobj, struct kobj_attribute *attr,
const char *buf, size_t n);
#endif
-
-#ifdef CONFIG_EARLYSUSPEND
-/* kernel/power/earlysuspend.c */
-void request_suspend_state(suspend_state_t state);
-suspend_state_t get_suspend_state(void);
-#endif
diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c
index 384730264515..9bb2f077e3b3 100644
--- a/kernel/power/suspend.c
+++ b/kernel/power/suspend.c
@@ -30,9 +30,6 @@
#include "power.h"
const char *const pm_states[PM_SUSPEND_MAX] = {
-#ifdef CONFIG_EARLYSUSPEND
- [PM_SUSPEND_ON] = "on",
-#endif
[PM_SUSPEND_STANDBY] = "standby",
[PM_SUSPEND_MEM] = "mem",
};
@@ -269,7 +266,7 @@ static void suspend_finish(void)
* Fail if that's not the case. Otherwise, prepare for system suspend, make the
* system enter the given sleep state and clean up after wakeup.
*/
-int enter_state(suspend_state_t state)
+static int enter_state(suspend_state_t state)
{
int error;