summaryrefslogtreecommitdiff
path: root/drivers/platform/x86/dell/dell-wmi-sysman
diff options
context:
space:
mode:
authorArmin Wolf <W_Armin@gmx.de>2023-04-30 22:31:53 +0200
committerHans de Goede <hdegoede@redhat.com>2023-05-09 12:07:40 +0200
commitd7296af803337a0a5b8edb2dd78b23cf1f68d56f (patch)
tree0122e4aabfe46f735af59531b7c8ddbd853afc66 /drivers/platform/x86/dell/dell-wmi-sysman
parent2a2b13ae50cf70e07b471301ff50299f31d81c1d (diff)
downloadlwn-d7296af803337a0a5b8edb2dd78b23cf1f68d56f.tar.gz
lwn-d7296af803337a0a5b8edb2dd78b23cf1f68d56f.zip
platform/x86: dell-sysman: Improve instance detection
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> Link: https://lore.kernel.org/r/20230430203153.5587-3-W_Armin@gmx.de Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Diffstat (limited to 'drivers/platform/x86/dell/dell-wmi-sysman')
-rw-r--r--drivers/platform/x86/dell/dell-wmi-sysman/sysman.c13
1 files changed, 5 insertions, 8 deletions
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;
}
/**