From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: Len Brown <lenb@kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
Matthew Garrett <mjg59@srcf.ucam.org>,
ACPI Devel Maling List <linux-acpi@vger.kernel.org>,
Linux-pm mailing list <linux-pm@lists.linux-foundation.org>
Subject: [PATCH 3/11] ACPI / PM: Use device wakeup flags for handling ACPI wakeup devices
Date: Thu, 6 Jan 2011 23:34:22 +0100 [thread overview]
Message-ID: <201101062334.22792.rjw@sisk.pl> (raw)
In-Reply-To: <201101062331.17079.rjw@sisk.pl>
From: Rafael J. Wysocki <rjw@sisk.pl>
There are ACPI devices (buttons and the laptop lid) that can wake up
the system from sleep states and have no "physical" companion
devices. The ACPI subsystem uses two flags, wakeup.state.enabled and
wakeup.flags.always_enabled, for handling those devices, but they
are not accessible through the standard device wakeup infrastructure.
User space can only control them via the /proc/acpi/wakeup interface
that is not really convenient (e.g. the way in which devices are
enabled to wake up the system is not portable between different
systems, because it requires one to know the devices' "names" used in
the system's ACPI tables).
To address this problem, use standard device wakeup flags instead of
the special ACPI flags for handling those devices. In particular,
use device_set_wakeup_capable() to mark the ACPI wakeup devices
during initialization and use device_set_wakeup_enable() to allow
or disallow them to wake up the system from sleep states. Rework
the /proc/acpi/wakeup interface to take these changes into account.
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
---
drivers/acpi/button.c | 4 ++--
drivers/acpi/proc.c | 19 +++++++++++++------
drivers/acpi/scan.c | 2 +-
drivers/acpi/wakeup.c | 18 ++++++++++--------
4 files changed, 26 insertions(+), 17 deletions(-)
Index: linux-2.6/drivers/acpi/wakeup.c
===================================================================
--- linux-2.6.orig/drivers/acpi/wakeup.c
+++ linux-2.6/drivers/acpi/wakeup.c
@@ -37,11 +37,12 @@ void acpi_enable_wakeup_devices(u8 sleep
container_of(node, struct acpi_device, wakeup_list);
if (!dev->wakeup.flags.valid
- || !(dev->wakeup.state.enabled || dev->wakeup.prepare_count)
- || sleep_state > (u32) dev->wakeup.sleep_state)
+ || sleep_state > (u32) dev->wakeup.sleep_state
+ || !(device_may_wakeup(&dev->dev)
+ || dev->wakeup.prepare_count))
continue;
- if (dev->wakeup.state.enabled)
+ if (device_may_wakeup(&dev->dev))
acpi_enable_wakeup_device_power(dev, sleep_state);
/* The wake-up power should have been enabled already. */
@@ -63,14 +64,15 @@ void acpi_disable_wakeup_devices(u8 slee
container_of(node, struct acpi_device, wakeup_list);
if (!dev->wakeup.flags.valid
- || !(dev->wakeup.state.enabled || dev->wakeup.prepare_count)
- || (sleep_state > (u32) dev->wakeup.sleep_state))
+ || sleep_state > (u32) dev->wakeup.sleep_state
+ || !(device_may_wakeup(&dev->dev)
+ || dev->wakeup.prepare_count))
continue;
acpi_gpe_wakeup(dev->wakeup.gpe_device, dev->wakeup.gpe_number,
ACPI_GPE_DISABLE);
- if (dev->wakeup.state.enabled)
+ if (device_may_wakeup(&dev->dev))
acpi_disable_wakeup_device_power(dev);
}
}
@@ -84,8 +86,8 @@ int __init acpi_wakeup_device_init(void)
struct acpi_device *dev = container_of(node,
struct acpi_device,
wakeup_list);
- if (dev->wakeup.flags.always_enabled)
- dev->wakeup.state.enabled = 1;
+ if (device_can_wakeup(&dev->dev))
+ device_set_wakeup_enable(&dev->dev, true);
}
mutex_unlock(&acpi_device_lock);
return 0;
Index: linux-2.6/drivers/acpi/button.c
===================================================================
--- linux-2.6.orig/drivers/acpi/button.c
+++ linux-2.6/drivers/acpi/button.c
@@ -426,7 +426,7 @@ static int acpi_button_add(struct acpi_d
acpi_enable_gpe(device->wakeup.gpe_device,
device->wakeup.gpe_number);
device->wakeup.run_wake_count++;
- device->wakeup.state.enabled = 1;
+ device_set_wakeup_enable(&device->dev, true);
}
printk(KERN_INFO PREFIX "%s [%s]\n", name, acpi_device_bid(device));
@@ -449,7 +449,7 @@ static int acpi_button_remove(struct acp
acpi_disable_gpe(device->wakeup.gpe_device,
device->wakeup.gpe_number);
device->wakeup.run_wake_count--;
- device->wakeup.state.enabled = 0;
+ device_set_wakeup_enable(&device->dev, false);
}
acpi_button_remove_fs(device);
Index: linux-2.6/drivers/acpi/scan.c
===================================================================
--- linux-2.6.orig/drivers/acpi/scan.c
+++ linux-2.6/drivers/acpi/scan.c
@@ -803,7 +803,7 @@ static void acpi_bus_set_run_wake_flags(
/* Power button, Lid switch always enable wakeup */
if (!acpi_match_device_ids(device, button_device_ids)) {
device->wakeup.flags.run_wake = 1;
- device->wakeup.flags.always_enabled = 1;
+ device_set_wakeup_capable(&device->dev, true);
return;
}
Index: linux-2.6/drivers/acpi/proc.c
===================================================================
--- linux-2.6.orig/drivers/acpi/proc.c
+++ linux-2.6/drivers/acpi/proc.c
@@ -311,7 +311,9 @@ acpi_system_wakeup_device_seq_show(struc
dev->pnp.bus_id,
(u32) dev->wakeup.sleep_state,
dev->wakeup.flags.run_wake ? '*' : ' ',
- dev->wakeup.state.enabled ? "enabled" : "disabled");
+ (device_may_wakeup(&dev->dev)
+ || (ldev && device_may_wakeup(ldev))) ?
+ "enabled" : "disabled");
if (ldev)
seq_printf(seq, "%s:%s",
ldev->bus ? ldev->bus->name : "no-bus",
@@ -328,8 +330,10 @@ static void physical_device_enable_wakeu
{
struct device *dev = acpi_get_physical_device(adev->handle);
- if (dev && device_can_wakeup(dev))
- device_set_wakeup_enable(dev, adev->wakeup.state.enabled);
+ if (dev && device_can_wakeup(dev)) {
+ bool enable = !device_may_wakeup(dev);
+ device_set_wakeup_enable(dev, enable);
+ }
}
static ssize_t
@@ -360,9 +364,12 @@ acpi_system_write_wakeup_device(struct f
continue;
if (!strncmp(dev->pnp.bus_id, str, 4)) {
- dev->wakeup.state.enabled =
- dev->wakeup.state.enabled ? 0 : 1;
- physical_device_enable_wakeup(dev);
+ if (device_can_wakeup(&dev->dev)) {
+ bool enable = !device_may_wakeup(&dev->dev);
+ device_set_wakeup_enable(&dev->dev, enable);
+ } else {
+ physical_device_enable_wakeup(dev);
+ }
break;
}
}
next prev parent reply other threads:[~2011-01-06 22:34 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-06 22:31 [PATCH 0/11] Various ACPI patches for 2.6.38 Rafael J. Wysocki
2011-01-06 22:32 ` [PATCH 1/11] ACPI / ACPICA: Fix global lock acquisition Rafael J. Wysocki
2011-01-06 22:33 ` [PATCH 2/11] ACPI / PM: Do not enable multiple devices to wake up simultaneously Rafael J. Wysocki
2011-01-06 22:34 ` Rafael J. Wysocki [this message]
2011-01-06 22:35 ` [PATCH 4/11] ACPI / PM: Drop special ACPI wakeup flags Rafael J. Wysocki
2011-01-06 22:36 ` [PATCH 5/11] ACPI / PM: Report wakeup events from buttons Rafael J. Wysocki
2011-01-06 22:37 ` [PATCH 6/11] ACPI / PM: Blacklist Averatec machine known to require acpi_sleep=nonvs Rafael J. Wysocki
2011-01-06 22:38 ` [PATCH 7/11] ACPI / PM: Rename acpi_power_off_device() Rafael J. Wysocki
2011-01-06 22:38 ` [PATCH 8/11] ACPI / PM: Check status of power resources under mutexes Rafael J. Wysocki
2011-01-06 22:40 ` [PATCH 9/11] ACPI: Always check if _PRW is present before trying to evaluate it Rafael J. Wysocki
2011-01-06 22:41 ` [PATCH 10/11] ACPI: Drop device flag wake_capable Rafael J. Wysocki
2011-01-06 23:52 ` [linux-pm] " David Brownell
2011-01-07 0:22 ` Rafael J. Wysocki
2011-01-06 22:42 ` [PATCH 11/11] ACPI / Battery: Update information on info notification and resume Rafael J. Wysocki
2012-05-01 18:47 ` [bug?] Battery notifications produce flashing battery icon, syslog spam (Re: [PATCH 11/11] ACPI / Battery: Update information on info notification and resume) Jonathan Nieder
2012-05-01 19:00 ` Adrian Fita
2012-05-01 19:14 ` Jonathan Nieder
2012-05-01 19:42 ` Ralf Jung
2012-05-02 11:49 ` Paolo Scarabelli
2012-05-03 8:54 ` Andy Whitcroft
2012-05-03 12:47 ` Matthew Garrett
2012-05-03 13:48 ` [PATCH 1/1] battery: only refresh the sysfs files when pertinant information changes Andy Whitcroft
2012-05-04 13:29 ` Ralf Jung
2012-05-05 10:37 ` Adrian Fita
2012-05-08 5:50 ` Len Brown
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=201101062334.22792.rjw@sisk.pl \
--to=rjw@sisk.pl \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@lists.linux-foundation.org \
--cc=mjg59@srcf.ucam.org \
/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;
as well as URLs for NNTP newsgroup(s).