From: Armin Wolf <W_Armin@gmx.de>
To: hdegoede@redhat.com, markgross@kernel.org
Cc: Mario.Limonciello@amd.com, prasanth.ksr@dell.com,
jorgealtxwork@gmail.com, james@equiv.tech,
Dell.Client.Kernel@dell.com, platform-driver-x86@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [RFC v2 2/2] platform/x86: dell-sysman: Improve instance detection
Date: Wed, 26 Apr 2023 23:28:48 +0200 [thread overview]
Message-ID: <20230426212848.108562-3-W_Armin@gmx.de> (raw)
In-Reply-To: <20230426212848.108562-1-W_Armin@gmx.de>
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>
---
.../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
prev parent reply other threads:[~2023-04-26 21:29 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-26 21:28 [RFC v2 0/2] platform/x86: Allow retrieving the number of WMI object instances Armin Wolf
2023-04-26 21:28 ` [RFC v2 1/2] platform/x86: wmi: " Armin Wolf
2023-04-27 6:19 ` James Seo
2023-04-27 9:43 ` Hans de Goede
2023-04-27 16:26 ` Armin Wolf
2023-04-29 9:27 ` Hans de Goede
2023-04-26 21:28 ` Armin Wolf [this message]
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=20230426212848.108562-3-W_Armin@gmx.de \
--to=w_armin@gmx.de \
--cc=Dell.Client.Kernel@dell.com \
--cc=Mario.Limonciello@amd.com \
--cc=hdegoede@redhat.com \
--cc=james@equiv.tech \
--cc=jorgealtxwork@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=markgross@kernel.org \
--cc=platform-driver-x86@vger.kernel.org \
--cc=prasanth.ksr@dell.com \
/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