[2/2] platform/x86: dell-sysman: Improve instance detection

Message ID 20230430203153.5587-3-W_Armin@gmx.de
State New
Headers
Series platform/x86: Allow retrieving the number of WMI object instances |

Commit Message

Armin Wolf April 30, 2023, 8:31 p.m. UTC
  The WMI driver core already knows how many WMI object instances
are available, use this information instead of probing the WMI object
manually.

Compile-tested only.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
---
 drivers/platform/x86/dell/dell-wmi-sysman/sysman.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

--
2.30.2
  

Patch

diff --git a/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c b/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c
index 0285b47d99d1..b68dd11cb892 100644
--- a/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c
+++ b/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c
@@ -303,16 +303,13 @@  union acpi_object *get_wmiobj_pointer(int instance_id, const char *guid_string)
  */
 int get_instance_count(const char *guid_string)
 {
-	union acpi_object *wmi_obj = NULL;
-	int i = 0;
+	int ret;

-	do {
-		kfree(wmi_obj);
-		wmi_obj = get_wmiobj_pointer(i, guid_string);
-		i++;
-	} while (wmi_obj);
+	ret = wmi_instance_count(guid_string);
+	if (ret < 0)
+		return 0;

-	return (i-1);
+	return ret;
 }

 /**