mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jorge Lopez <jorgealtxwork@gmail.com>
To: hdegoede@redhat.com, platform-driver-x86@vger.kernel.org,
	linux-kernel@vger.kernel.org, thomas@t-8ch.de,
	ilpo.jarvinen@linux.intel.com
Subject: [PATCH] Fixes for ordered_list_elements_from_package
Date: Mon, 31 Jul 2023 11:22:31 -0500	[thread overview]
Message-ID: <20230731162231.15814-1-jorge.lopez2@hp.com> (raw)

Address latest comments and requested changes to
ordered_list_elements_from_package

Signed-off-by: Jorge Lopez <jorge.lopez2@hp.com>

---
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


                 reply	other threads:[~2023-07-31 16:22 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20230731162231.15814-1-jorge.lopez2@hp.com \
    --to=jorgealtxwork@gmail.com \
    --cc=hdegoede@redhat.com \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=thomas@t-8ch.de \
    /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

all inboxes | Powered by JetHome®