[PATCH v11 3/9] ACPI: x86: s2idle: Fix a logic error parsing AMD constraints table

From: Mario Limonciello
Date: Wed Aug 09 2023 - 15:47:45 EST


The constraints table should be resetting the `list` object
after running through all of `info_obj` iterations.

This adjusts whitespace as well as less code will now be included
with each loop.

Signed-off-by: Mario Limonciello <mario.limonciello@xxxxxxx>
---
v9->v10:
* split from other patches
---
drivers/acpi/x86/s2idle.c | 35 +++++++++++++++++------------------
1 file changed, 17 insertions(+), 18 deletions(-)

diff --git a/drivers/acpi/x86/s2idle.c b/drivers/acpi/x86/s2idle.c
index ce62e61a9605e..b566b3aa09388 100644
--- a/drivers/acpi/x86/s2idle.c
+++ b/drivers/acpi/x86/s2idle.c
@@ -129,12 +129,12 @@ static void lpi_device_get_constraints_amd(void)
struct lpi_constraints *list;
acpi_status status;

+ list = &lpi_constraints_table[lpi_constraints_table_size];
+ list->min_dstate = -EINVAL;
+
for (k = 0; k < info_obj->package.count; ++k) {
union acpi_object *obj = &info_obj->package.elements[k];

- list = &lpi_constraints_table[lpi_constraints_table_size];
- list->min_dstate = -1;
-
switch (k) {
case 0:
dev_info.enabled = obj->integer.value;
@@ -149,26 +149,25 @@ static void lpi_device_get_constraints_amd(void)
dev_info.min_dstate = obj->integer.value;
break;
}
+ }

- if (!dev_info.enabled || !dev_info.name ||
- !dev_info.min_dstate)
- continue;
+ if (!dev_info.enabled || !dev_info.name ||
+ !dev_info.min_dstate)
+ continue;

- status = acpi_get_handle(NULL, dev_info.name,
- &list->handle);
- if (ACPI_FAILURE(status))
- continue;
+ status = acpi_get_handle(NULL, dev_info.name, &list->handle);
+ if (ACPI_FAILURE(status))
+ continue;

- acpi_handle_debug(lps0_device_handle,
- "Name:%s\n", dev_info.name);
+ acpi_handle_debug(lps0_device_handle,
+ "Name:%s\n", dev_info.name);

- list->min_dstate = dev_info.min_dstate;
+ list->min_dstate = dev_info.min_dstate;

- if (list->min_dstate < 0) {
- acpi_handle_debug(lps0_device_handle,
- "Incomplete constraint defined\n");
- continue;
- }
+ if (list->min_dstate < 0) {
+ acpi_handle_debug(lps0_device_handle,
+ "Incomplete constraint defined\n");
+ continue;
}
lpi_constraints_table_size++;
}
--
2.34.1