Commit 41233988 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Rafael J. Wysocki

ACPI: x86: s2idle: Add for_each_lpi_constraint() helper

We have one existing and one coming user of this macro.
Introduce a helper.
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: default avatarMario Limonciello <mario.limonciello@amd.com>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent a879058d
...@@ -94,6 +94,11 @@ static struct lpi_constraints *lpi_constraints_table; ...@@ -94,6 +94,11 @@ static struct lpi_constraints *lpi_constraints_table;
static int lpi_constraints_table_size; static int lpi_constraints_table_size;
static int rev_id; static int rev_id;
#define for_each_lpi_constraint(entry) \
for (int i = 0; \
entry = &lpi_constraints_table[i], i < lpi_constraints_table_size; \
i++)
static void lpi_device_get_constraints_amd(void) static void lpi_device_get_constraints_amd(void)
{ {
union acpi_object *out_obj; union acpi_object *out_obj;
...@@ -296,30 +301,29 @@ static void lpi_device_get_constraints(void) ...@@ -296,30 +301,29 @@ static void lpi_device_get_constraints(void)
static void lpi_check_constraints(void) static void lpi_check_constraints(void)
{ {
int i; struct lpi_constraints *entry;
for (i = 0; i < lpi_constraints_table_size; ++i) { for_each_lpi_constraint(entry) {
acpi_handle handle = lpi_constraints_table[i].handle; struct acpi_device *adev = acpi_fetch_acpi_dev(entry->handle);
struct acpi_device *adev = acpi_fetch_acpi_dev(handle);
if (!adev) if (!adev)
continue; continue;
acpi_handle_debug(handle, acpi_handle_debug(entry->handle,
"LPI: required min power state:%s current power state:%s\n", "LPI: required min power state:%s current power state:%s\n",
acpi_power_state_string(lpi_constraints_table[i].min_dstate), acpi_power_state_string(entry->min_dstate),
acpi_power_state_string(adev->power.state)); acpi_power_state_string(adev->power.state));
if (!adev->flags.power_manageable) { if (!adev->flags.power_manageable) {
acpi_handle_info(handle, "LPI: Device not power manageable\n"); acpi_handle_info(entry->handle, "LPI: Device not power manageable\n");
lpi_constraints_table[i].handle = NULL; entry->handle = NULL;
continue; continue;
} }
if (adev->power.state < lpi_constraints_table[i].min_dstate) if (adev->power.state < entry->min_dstate)
acpi_handle_info(handle, acpi_handle_info(entry->handle,
"LPI: Constraint not met; min power state:%s current power state:%s\n", "LPI: Constraint not met; min power state:%s current power state:%s\n",
acpi_power_state_string(lpi_constraints_table[i].min_dstate), acpi_power_state_string(entry->min_dstate),
acpi_power_state_string(adev->power.state)); acpi_power_state_string(adev->power.state));
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment