From: "Arve Hjønnevåg" <arve@android.com>
To: linux-pm@lists.linux-foundation.org
Cc: ncunningham@crca.org.au, u.luckas@road.de, swetland@google.com
Subject: [PATCH 02/10] PM: wakelock: Override wakelocks when not using /sys/power/request_state
Date: Tue, 10 Feb 2009 17:49:07 -0800 [thread overview]
Message-ID: <1234316955-31304-3-git-send-email-arve@android.com> (raw)
In-Reply-To: <1234316955-31304-2-git-send-email-arve@android.com>
This preserves existing functionality when CONFIG_WAKELOCK is set.
Signed-off-by: Arve Hjønnevåg <arve@android.com>
---
include/linux/wakelock.h | 4 ++++
kernel/power/wakelock.c | 10 +++++++++-
2 files changed, 13 insertions(+), 1 deletions(-)
diff --git a/include/linux/wakelock.h b/include/linux/wakelock.h
index ec878d2..af74b65 100755
--- a/include/linux/wakelock.h
+++ b/include/linux/wakelock.h
@@ -72,6 +72,10 @@ int wake_lock_active(struct wake_lock *lock);
* and non-zero if one or more wake locks are held. Specifically it returns
* -1 if one or more wake locks with no timeout are active or the
* number of jiffies until all active wake locks time out.
+ *
+ * To preserve backward compatibility, when the type is WAKE_LOCK_SUSPEND, this
+ * function returns 0 unless it is called during suspend initiated from the
+ * wakelock code.
*/
long has_wake_lock(int type);
diff --git a/kernel/power/wakelock.c b/kernel/power/wakelock.c
index 13f5d03..c396b58 100644
--- a/kernel/power/wakelock.c
+++ b/kernel/power/wakelock.c
@@ -49,6 +49,7 @@ static int current_event_num;
struct workqueue_struct *suspend_work_queue;
struct wake_lock main_wake_lock;
static suspend_state_t requested_suspend_state = PM_SUSPEND_MEM;
+static bool enable_suspend_wakelocks;
static struct wake_lock unknown_wakeup;
#ifdef CONFIG_WAKELOCK_STAT
@@ -317,6 +318,9 @@ long has_wake_lock(int type)
{
long ret;
unsigned long irqflags;
+ if (WARN_ONCE(type == WAKE_LOCK_SUSPEND && !enable_suspend_wakelocks,
+ "ignoring wakelocks\n"))
+ return 0;
spin_lock_irqsave(&list_lock, irqflags);
ret = has_wake_lock_locked(type);
spin_unlock_irqrestore(&list_lock, irqflags);
@@ -328,10 +332,12 @@ static void suspend_worker(struct work_struct *work)
int ret;
int entry_event_num;
+ enable_suspend_wakelocks = 1;
+
if (has_wake_lock(WAKE_LOCK_SUSPEND)) {
if (debug_mask & DEBUG_SUSPEND)
pr_info("suspend: abort suspend\n");
- return;
+ goto abort;
}
entry_event_num = current_event_num;
@@ -353,6 +359,8 @@ static void suspend_worker(struct work_struct *work)
pr_info("suspend: pm_suspend returned with no event\n");
wake_lock_timeout(&unknown_wakeup, HZ / 2);
}
+abort:
+ enable_suspend_wakelocks = 0;
}
static DECLARE_WORK(suspend_work, suspend_worker);
--
1.6.1
_______________________________________________
linux-pm mailing list
linux-pm@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/linux-pm
next prev parent reply other threads:[~2009-02-11 1:49 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-11 1:49 [RFC][PATCH 00/11] Android PM extensions (version 3) Arve Hjønnevåg
2009-02-11 1:49 ` [PATCH 01/10] PM: Add wake lock api Arve Hjønnevåg
2009-02-11 1:49 ` Arve Hjønnevåg [this message]
2009-02-11 1:49 ` [PATCH 03/10] PM: wakelock: Add driver to access wakelocks from user-space Arve Hjønnevåg
2009-02-11 1:49 ` [PATCH 04/10] PM: wakelock: Abort task freezing if a wakelock is locked Arve Hjønnevåg
2009-02-11 1:49 ` [PATCH 05/10] PM: Add option to disable /sys/power/state interface Arve Hjønnevåg
2009-02-11 1:49 ` [PATCH 06/10] PM: Add early suspend api Arve Hjønnevåg
2009-02-11 1:49 ` [PATCH 07/10] PM: earlysuspend: Add console switch when user requested sleep state changes Arve Hjønnevåg
2009-02-11 1:49 ` [PATCH 08/10] PM: earlysuspend: Removing dependence on console Arve Hjønnevåg
2009-02-11 1:49 ` [PATCH 09/10] Input: Hold wake lock while event queue is not empty Arve Hjønnevåg
2009-02-11 1:49 ` [PATCH 10/10] ledtrig-sleep: Add led trigger for sleep debugging Arve Hjønnevåg
2009-02-12 11:31 ` [PATCH 09/10] Input: Hold wake lock while event queue is not empty Matthew Garrett
2009-02-13 0:27 ` Arve Hjønnevåg
2009-02-13 0:34 ` Matthew Garrett
2009-02-13 0:38 ` Arve Hjønnevåg
2009-02-13 0:40 ` Matthew Garrett
2009-02-13 0:52 ` Arve Hjønnevåg
2009-02-13 0:57 ` Matthew Garrett
2009-02-13 23:06 ` Rafael J. Wysocki
2009-02-13 23:51 ` Arve Hjønnevåg
2009-02-14 0:09 ` Matthew Garrett
2009-02-14 0:13 ` Arve Hjønnevåg
2009-02-14 0:18 ` Matthew Garrett
2009-02-12 11:28 ` [PATCH 07/10] PM: earlysuspend: Add console switch when user requested sleep state changes Matthew Garrett
2009-02-12 11:34 ` [PATCH 06/10] PM: Add early suspend api Matthew Garrett
2009-02-12 22:00 ` [PATCH 01/10] PM: Add wake lock api mark gross
2009-02-12 23:06 ` Arve Hjønnevåg
2009-02-17 21:05 ` [RFC][PATCH 00/11] Android PM extensions (version 3) Pavel Machek
2009-02-19 1:43 ` Arve Hjønnevåg
2009-02-19 12:54 ` Rafael J. Wysocki
2009-02-22 13:48 ` Pavel Machek
2009-02-23 23:31 ` Arve Hjønnevåg
2009-02-23 23:54 ` Rafael J. Wysocki
2009-02-25 13:23 ` Pavel Machek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1234316955-31304-3-git-send-email-arve@android.com \
--to=arve@android.com \
--cc=linux-pm@lists.linux-foundation.org \
--cc=ncunningham@crca.org.au \
--cc=swetland@google.com \
--cc=u.luckas@road.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox