2023-04-26 21:31:14

by Armin Wolf

[permalink] [raw]
Subject: [RFC v2 0/2] platform/x86: Allow retrieving the number of WMI object instances

This experimental patch series allows WMI drivers to retrieve
the number of WMI object instances. This functionallity benefits
several current and upcoming WMI drivers, the dell-wmi-sysman driver
is converted to use this new API as an example.

The changes are compile-tested only, the change to the dell-wmi-sysman
driver also needs to be tested on real hardware.

Armin Wolf (2):
platform/x86: wmi: Allow retrieving the number of WMI object instances
platform/x86: dell-sysman: Improve instance detection

.../x86/dell/dell-wmi-sysman/sysman.c | 15 ++++---
drivers/platform/x86/wmi.c | 40 +++++++++++++++++++
include/linux/acpi.h | 2 +
include/linux/wmi.h | 2 +
4 files changed, 51 insertions(+), 8 deletions(-)

--
2.30.2


2023-04-26 21:31:17

by Armin Wolf

[permalink] [raw]
Subject: [RFC v2 2/2] 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 <[email protected]>
---
.../platform/x86/dell/dell-wmi-sysman/sysman.c | 15 +++++++--------
1 file changed, 7 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..526d60b510bb 100644
--- a/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c
+++ b/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c
@@ -7,6 +7,7 @@

#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

+#include <linux/acpi.h>
#include <linux/fs.h>
#include <linux/dmi.h>
#include <linux/module.h>
@@ -303,16 +304,14 @@ 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;
+ acpi_status status;
+ u8 instance_count;

- do {
- kfree(wmi_obj);
- wmi_obj = get_wmiobj_pointer(i, guid_string);
- i++;
- } while (wmi_obj);
+ status = wmi_instance_count(guid_string, &instance_count);
+ if (ACPI_FAILURE(status))
+ return 0;

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

/**
--
2.30.2