2023-07-31 16:45:24

by Jorge Lopez

[permalink] [raw]
Subject: [PATCH] Fixes for ordered_list_elements_from_package

Address latest comments and requested changes to
ordered_list_elements_from_package

Signed-off-by: Jorge Lopez <[email protected]>

---
Based on the latest platform-drivers-x86.git/for-next
---
.../x86/hp/hp-bioscfg/order-list-attributes.c | 44 +++++++++----------
1 file changed, 21 insertions(+), 23 deletions(-)

diff --git a/drivers/platform/x86/hp/hp-bioscfg/order-list-attributes.c b/drivers/platform/x86/hp/hp-bioscfg/order-list-attributes.c
index 89e67db733eb..98e51759134c 100644
--- a/drivers/platform/x86/hp/hp-bioscfg/order-list-attributes.c
+++ b/drivers/platform/x86/hp/hp-bioscfg/order-list-attributes.c
@@ -134,8 +134,9 @@ static int hp_populate_ordered_list_elements_from_package(union acpi_object *ord
int value_len = 0;
int ret;
u32 size;
- u32 int_value = 0;
+ u32 type_int_value = 0;
int elem;
+ int ord_list_elem;
int reqs;
int eloc;
char *tmpstr = NULL;
@@ -147,10 +148,7 @@ static int hp_populate_ordered_list_elements_from_package(union acpi_object *ord
if (!order_obj)
return -EINVAL;

- for (elem = 1, eloc = 1; elem < order_obj_count; elem++, eloc++) {
- /* ONLY look at the first ORDERED_ELEM_CNT elements */
- if (eloc == ORD_ELEM_CNT)
- goto exit_list;
+ for (elem = 1, eloc = 1; eloc < ORD_ELEM_CNT; elem++, eloc++) {

switch (order_obj[elem].type) {
case ACPI_TYPE_STRING:
@@ -163,7 +161,7 @@ static int hp_populate_ordered_list_elements_from_package(union acpi_object *ord
}
break;
case ACPI_TYPE_INTEGER:
- int_value = (u32)order_obj[elem].integer.value;
+ type_int_value = (u32)order_obj[elem].integer.value;
break;
default:
pr_warn("Unsupported object type [%d]\n", order_obj[elem].type);
@@ -190,30 +188,30 @@ static int hp_populate_ordered_list_elements_from_package(union acpi_object *ord
sizeof(ordered_list_data->common.path));
break;
case IS_READONLY:
- ordered_list_data->common.is_readonly = int_value;
+ ordered_list_data->common.is_readonly = type_int_value;
break;
case DISPLAY_IN_UI:
- ordered_list_data->common.display_in_ui = int_value;
+ ordered_list_data->common.display_in_ui = type_int_value;
break;
case REQUIRES_PHYSICAL_PRESENCE:
- ordered_list_data->common.requires_physical_presence = int_value;
+ ordered_list_data->common.requires_physical_presence = type_int_value;
break;
case SEQUENCE:
- ordered_list_data->common.sequence = int_value;
+ ordered_list_data->common.sequence = type_int_value;
break;
case PREREQUISITES_SIZE:
- ordered_list_data->common.prerequisites_size = int_value;
- if (int_value > MAX_PREREQUISITES_SIZE)
+ ordered_list_data->common.prerequisites_size = type_int_value;
+ if (type_int_value > MAX_PREREQUISITES_SIZE)
pr_warn("Prerequisites size value exceeded the maximum number of elements supported or data may be malformed\n");

/*
- * This HACK is needed to keep the expected
+ * This step is needed to keep the expected
* element list pointing to the right obj[elem].type
* when the size is zero. PREREQUISITES
* object is omitted by BIOS when the size is
* zero.
*/
- if (int_value == 0)
+ if (type_int_value == 0)
eloc++;
break;
case PREREQUISITES:
@@ -237,21 +235,21 @@ static int hp_populate_ordered_list_elements_from_package(union acpi_object *ord
break;

case SECURITY_LEVEL:
- ordered_list_data->common.security_level = int_value;
+ ordered_list_data->common.security_level = type_int_value;
break;

case ORD_LIST_SIZE:
- ordered_list_data->elements_size = int_value;
- if (int_value > MAX_ELEMENTS_SIZE)
+ ordered_list_data->elements_size = type_int_value;
+ if (type_int_value > MAX_ELEMENTS_SIZE)
pr_warn("Ordered List size value exceeded the maximum number of elements supported or data may be malformed\n");
/*
- * This HACK is needed to keep the expected
+ * This step is needed to keep the expected
* element list pointing to the right obj[elem].type
* when the size is zero. ORD_LIST_ELEMENTS
* object is omitted by BIOS when the size is
* zero.
*/
- if (int_value == 0)
+ if (type_int_value == 0)
eloc++;
break;
case ORD_LIST_ELEMENTS:
@@ -261,7 +259,7 @@ static int hp_populate_ordered_list_elements_from_package(union acpi_object *ord
* Ordered list data is stored in hex and comma separated format
* Convert the data and split it to show each element
*/
- ret = hp_convert_hexstr_to_str(str_value, value_len, &tmpstr, &tmp_len);
+ ret = hp_convert_hexstr_to_str(str_value, size, &tmpstr, &tmp_len);
if (ret)
goto exit_list;

@@ -272,10 +270,10 @@ static int hp_populate_ordered_list_elements_from_package(union acpi_object *ord
tmpstr,
sizeof(ordered_list_data->elements[0]));

- for (elem = 1; elem < MAX_ELEMENTS_SIZE && part; elem++) {
- strscpy(ordered_list_data->elements[elem],
+ for (ord_list_elem = 1; ord_list_elem < MAX_ELEMENTS_SIZE && part; ord_list_elem++) {
+ strscpy(ordered_list_data->elements[ord_list_elem],
part,
- sizeof(ordered_list_data->elements[elem]));
+ sizeof(ordered_list_data->elements[ord_list_elem]));
part = strsep(&part_tmp, SEMICOLON_SEP);
}

--
2.34.1