From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: ACPI Devel Maling List <linux-acpi@vger.kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH 8/12] ACPI / scan: Move power state initialization to a separate routine
Date: Fri, 04 Jan 2013 01:07:05 +0100 [thread overview]
Message-ID: <3426685.zRWDP3qKqq@vostro.rjw.lan> (raw)
In-Reply-To: <1418767.4KIZOTK1lk@vostro.rjw.lan>
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
To reduce indentation level and improve code readability, move the
initialization code related to device power states from
acpi_bus_get_power_flags() to a new routine,
acpi_bus_init_power_state().
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
drivers/acpi/scan.c | 87 +++++++++++++++++++++++++++-------------------------
1 file changed, 46 insertions(+), 41 deletions(-)
Index: linux/drivers/acpi/scan.c
===================================================================
--- linux.orig/drivers/acpi/scan.c
+++ linux/drivers/acpi/scan.c
@@ -1045,6 +1045,50 @@ static void acpi_bus_get_wakeup_device_f
"error in _DSW or _PSW evaluation\n"));
}
+static void acpi_bus_init_power_state(struct acpi_device *device, int state)
+{
+ struct acpi_device_power_state *ps = &device->power.states[state];
+ char object_name[5] = { '_', 'P', 'R', '0' + state, '\0' };
+ struct acpi_handle_list resources;
+ acpi_handle handle;
+ acpi_status status;
+
+ INIT_LIST_HEAD(&ps->resources);
+
+ /* Evaluate "_PRx" to se if power resources are referenced */
+ acpi_evaluate_reference(device->handle, object_name, NULL, &resources);
+ if (resources.count) {
+ int j;
+
+ device->power.flags.power_resources = 1;
+ for (j = 0; j < resources.count; j++) {
+ acpi_handle rhandle = resources.handles[j];
+
+ acpi_add_power_resource(rhandle);
+ acpi_power_resources_list_add(rhandle, &ps->resources);
+ }
+ }
+
+ /* Evaluate "_PSx" to see if we can do explicit sets */
+ object_name[2] = 'S';
+ status = acpi_get_handle(device->handle, object_name, &handle);
+ if (ACPI_SUCCESS(status))
+ ps->flags.explicit_set = 1;
+
+ /*
+ * State is valid if there are means to put the device into it.
+ * D3hot is only valid if _PR3 present.
+ */
+ if (resources.count
+ || (ps->flags.explicit_set && state < 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 */
+}
+
static void acpi_bus_get_power_flags(struct acpi_device *device)
{
acpi_status status = 0;
@@ -1074,47 +1118,8 @@ static void acpi_bus_get_power_flags(str
/*
* Enumerate supported power management states
*/
- for (i = ACPI_STATE_D0; i <= ACPI_STATE_D3_HOT; i++) {
- struct acpi_device_power_state *ps = &device->power.states[i];
- char object_name[5] = { '_', 'P', 'R', '0' + i, '\0' };
- struct acpi_handle_list resources;
-
- INIT_LIST_HEAD(&ps->resources);
- /* Evaluate "_PRx" to se if power resources are referenced */
- acpi_evaluate_reference(device->handle, object_name, NULL,
- &resources);
- if (resources.count) {
- int j;
-
- device->power.flags.power_resources = 1;
- for (j = 0; j < resources.count; j++) {
- acpi_handle rhandle = resources.handles[j];
-
- acpi_add_power_resource(rhandle);
- acpi_power_resources_list_add(rhandle,
- &ps->resources);
- }
- }
-
- /* Evaluate "_PSx" to see if we can do explicit sets */
- object_name[2] = 'S';
- status = acpi_get_handle(device->handle, object_name, &handle);
- if (ACPI_SUCCESS(status))
- ps->flags.explicit_set = 1;
-
- /*
- * State is valid if there are means to put the device into it.
- * D3hot is only valid if _PR3 present.
- */
- if (resources.count ||
- (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 */
- }
+ for (i = ACPI_STATE_D0; i <= ACPI_STATE_D3_HOT; i++)
+ acpi_bus_init_power_state(device, i);
INIT_LIST_HEAD(&device->power.states[ACPI_STATE_D3_COLD].resources);
next prev parent reply other threads:[~2013-01-04 0:07 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-03 23:16 [PATCH 0/12] ACPI: Rework the handling of power resources Rafael J. Wysocki
2013-01-04 0:01 ` [PATCH 1/12] ACPI / PM: Rework the handling of devices depending on " Rafael J. Wysocki
2013-01-04 0:02 ` [PATCH 2/12] ACPI / scan: More straightforward preparation of ACPI device objects Rafael J. Wysocki
2013-01-04 0:03 ` [PATCH 3/12] ACPI / scan: Treat power resources in a special way Rafael J. Wysocki
2013-01-04 0:03 ` [PATCH 4/12] ACPI: Drop power resources driver Rafael J. Wysocki
2013-01-04 0:04 ` [PATCH 5/12] ACPI: Do not use device power states of power resources Rafael J. Wysocki
2013-01-04 0:05 ` [PATCH 6/12] ACPI / PM: Take order attribute of power resources into account Rafael J. Wysocki
2013-01-04 0:06 ` [PATCH 7/12] ACPI / PM: Take order attribute of wakeup " Rafael J. Wysocki
2013-01-04 0:07 ` Rafael J. Wysocki [this message]
2013-01-04 0:07 ` [PATCH 9/12] ACPI / scan: Remove unnecessary initialization of local variables Rafael J. Wysocki
2013-01-04 0:08 ` [PATCH 10/12] ACPI / scan: Consolidate extraction of power resources lists Rafael J. Wysocki
2013-01-04 0:09 ` [PATCH 11/12] ACPI: Take power resource initialization errors into account Rafael J. Wysocki
2013-01-04 0:10 ` [PATCH 12/12] ACPI: Use system level attribute of wakeup power resources Rafael J. Wysocki
2013-01-11 21:57 ` [PATCH 0/12] ACPI: Rework the handling of " Rafael J. Wysocki
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=3426685.zRWDP3qKqq@vostro.rjw.lan \
--to=rjw@sisk.pl \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.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).