Skip to content

Commit 4123398

Browse files
andy-shevrafaeljw
authored andcommitted
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: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent a879058 commit 4123398

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

drivers/acpi/x86/s2idle.c

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@ static struct lpi_constraints *lpi_constraints_table;
9494
static int lpi_constraints_table_size;
9595
static int rev_id;
9696

97+
#define for_each_lpi_constraint(entry) \
98+
for (int i = 0; \
99+
entry = &lpi_constraints_table[i], i < lpi_constraints_table_size; \
100+
i++)
101+
97102
static void lpi_device_get_constraints_amd(void)
98103
{
99104
union acpi_object *out_obj;
@@ -296,30 +301,29 @@ static void lpi_device_get_constraints(void)
296301

297302
static void lpi_check_constraints(void)
298303
{
299-
int i;
304+
struct lpi_constraints *entry;
300305

301-
for (i = 0; i < lpi_constraints_table_size; ++i) {
302-
acpi_handle handle = lpi_constraints_table[i].handle;
303-
struct acpi_device *adev = acpi_fetch_acpi_dev(handle);
306+
for_each_lpi_constraint(entry) {
307+
struct acpi_device *adev = acpi_fetch_acpi_dev(entry->handle);
304308

305309
if (!adev)
306310
continue;
307311

308-
acpi_handle_debug(handle,
312+
acpi_handle_debug(entry->handle,
309313
"LPI: required min power state:%s current power state:%s\n",
310-
acpi_power_state_string(lpi_constraints_table[i].min_dstate),
314+
acpi_power_state_string(entry->min_dstate),
311315
acpi_power_state_string(adev->power.state));
312316

313317
if (!adev->flags.power_manageable) {
314-
acpi_handle_info(handle, "LPI: Device not power manageable\n");
315-
lpi_constraints_table[i].handle = NULL;
318+
acpi_handle_info(entry->handle, "LPI: Device not power manageable\n");
319+
entry->handle = NULL;
316320
continue;
317321
}
318322

319-
if (adev->power.state < lpi_constraints_table[i].min_dstate)
320-
acpi_handle_info(handle,
323+
if (adev->power.state < entry->min_dstate)
324+
acpi_handle_info(entry->handle,
321325
"LPI: Constraint not met; min power state:%s current power state:%s\n",
322-
acpi_power_state_string(lpi_constraints_table[i].min_dstate),
326+
acpi_power_state_string(entry->min_dstate),
323327
acpi_power_state_string(adev->power.state));
324328
}
325329
}

0 commit comments

Comments
 (0)