From: Aaron Lu <aaron.lu@intel.com>
To: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: Len Brown <lenb@kernel.org>,
linux-acpi@vger.kernel.org, Aaron Lu <aaron.lwe@gmail.com>
Subject: [PATCH v2] acpi: introduce os_accessible flag for power_state
Date: Wed, 21 Nov 2012 20:24:20 +0800 [thread overview]
Message-ID: <50ACC7F4.7060401@intel.com> (raw)
In-Reply-To: <1488423.HT0sLzAmeT@vostro.rjw.lan>
Currently we have valid flag to represent if this ACPI device power
state is valid. A device power state is valid does not necessarily
mean we, as OSPM, has a mean to put the device into that power state,
e.g. D3 cold is always a valid power state for any ACPI device, but if
there is no _PS3 or _PRx for this device, we can't really put that
device into D3 cold power state. The same is true for D0 power state.
So here comes the os_accessible flag, which is only set if the device
has provided us the required means to put it into that power state,
e.g. if we have _PS3 or _PRx, we can put the device into D3 cold state
and thus, D3 cold power state's os_accessible flag will be set in this
case.
And a new wrapper inline function is added to be used to check if
firmware has provided us a way to power off the device during runtime.
Signed-off-by: Aaron Lu <aaron.lu@intel.com>
---
v2:
Rename swset to os_accessible as suggested by Rafael Wysocki.
Fold patch 2 into patch 1 as suggested by Rafael Wysocki.
drivers/acpi/scan.c | 9 ++++++++-
include/acpi/acpi_bus.h | 6 ++++++
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 3c646e6..f250c5b 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -1062,8 +1062,10 @@ static int acpi_bus_get_power_flags(struct acpi_device *device)
* D3hot is only valid if _PR3 present.
*/
if (ps->resources.count ||
- (ps->flags.explicit_set && i < ACPI_STATE_D3_HOT))
+ (ps->flags.explicit_set && i < ACPI_STATE_D3_HOT)) {
ps->flags.valid = 1;
+ ps->flags.os_accessible = 1;
+ }
ps->power = -1; /* Unknown - driver assigned */
ps->latency = -1; /* Unknown - driver assigned */
@@ -1079,6 +1081,11 @@ static int acpi_bus_get_power_flags(struct acpi_device *device)
if (device->power.states[ACPI_STATE_D3_HOT].flags.explicit_set)
device->power.states[ACPI_STATE_D3_COLD].flags.explicit_set = 1;
+ /* Presence of _PS3 or _PRx means we can put the device into D3 cold */
+ if (device->power.states[ACPI_STATE_D3_HOT].flags.explicit_set ||
+ device->power.flags.power_resources)
+ device->power.states[ACPI_STATE_D3_COLD].flags.os_accessible = 1;
+
acpi_bus_init_power(device);
return 0;
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index ce77cd7..644d941 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -201,6 +201,7 @@ struct acpi_device_power_flags {
struct acpi_device_power_state {
struct {
u8 valid:1;
+ u8 os_accessible:1;
u8 explicit_set:1; /* _PSx present? */
u8 reserved:6;
} flags;
@@ -500,6 +501,11 @@ static inline bool acpi_device_can_wakeup(struct acpi_device *adev)
return adev->wakeup.flags.valid;
}
+static inline bool acpi_device_can_poweroff(struct acpi_device *adev)
+{
+ return adev->power.states[ACPI_STATE_D3_COLD].flags.os_accessible;
+}
+
#else /* CONFIG_ACPI */
static inline int register_acpi_bus_type(void *bus) { return 0; }
--
1.7.12.4
next prev parent reply other threads:[~2012-11-21 12:24 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-09 1:54 [PATCH 0/2] Check ACPI device poweroff capability Aaron Lu
2012-11-09 1:54 ` [PATCH 1/2] acpi: introduce swset flag for power_state Aaron Lu
2012-11-21 0:11 ` Rafael J. Wysocki
2012-11-21 12:24 ` Aaron Lu [this message]
2012-11-22 0:16 ` [PATCH v2] acpi: introduce os_accessible " Rafael J. Wysocki
2012-11-09 1:54 ` [PATCH 2/2] acpi: add function to check if poweroff is possible Aaron Lu
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=50ACC7F4.7060401@intel.com \
--to=aaron.lu@intel.com \
--cc=aaron.lwe@gmail.com \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=rjw@sisk.pl \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.