From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Armin Wolf <W_Armin@gmx.de>
Cc: james@equiv.tech, markpearson@lenovo.com, jorge.lopez2@hp.com,
jdelvare@suse.com, linux@roeck-us.net,
linux-hwmon@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>,
Hans de Goede <hdegoede@redhat.com>,
platform-driver-x86@vger.kernel.org, corbet@lwn.net,
linux-doc@vger.kernel.org
Subject: Re: [PATCH 4/7] platform/x86: hp-bioscfg: Use wmi_instance_count()
Date: Tue, 4 Feb 2025 12:37:54 +0200 (EET) [thread overview]
Message-ID: <a02aa367-2ce8-ba6d-adc7-b91552566142@linux.intel.com> (raw)
In-Reply-To: <20250203182322.384883-5-W_Armin@gmx.de>
On Mon, 3 Feb 2025, Armin Wolf wrote:
> The WMI core already knows the instance count of a WMI guid.
> Use this information instead of querying all possible instances
> which is slow and might be unreliable.
>
> Signed-off-by: Armin Wolf <W_Armin@gmx.de>
> ---
> drivers/platform/x86/hp/hp-bioscfg/bioscfg.c | 13 +++++--------
> 1 file changed, 5 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/platform/x86/hp/hp-bioscfg/bioscfg.c b/drivers/platform/x86/hp/hp-bioscfg/bioscfg.c
> index 0b277b7e37dd..63c78b4d8258 100644
> --- a/drivers/platform/x86/hp/hp-bioscfg/bioscfg.c
> +++ b/drivers/platform/x86/hp/hp-bioscfg/bioscfg.c
> @@ -388,16 +388,13 @@ union acpi_object *hp_get_wmiobj_pointer(int instance_id, const char *guid_strin
> */
> int hp_get_instance_count(const char *guid_string)
> {
> - union acpi_object *wmi_obj = NULL;
> - int i = 0;
> + int ret;
>
> - do {
> - kfree(wmi_obj);
> - wmi_obj = hp_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;
> }
Hi Armin,
While it is the existing way of doing things, I don't like how the error
is not properly passed on here. And if the error handling is pushed
upwards to the calling sites, then this entire function becomes useless
and wmi_instance_count() could be used directly in the callers.
--
i.
next prev parent reply other threads:[~2025-02-04 10:38 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-03 18:23 [PATCH 0/7] platform/x86: wmi: Rework WMI device enabling Armin Wolf
2025-02-03 18:23 ` [PATCH 1/7] hwmon: (hp-wmi-sensors) Use the WMI bus API when accessing sensors Armin Wolf
2025-02-04 0:41 ` James Seo
2025-02-04 1:18 ` Guenter Roeck
2025-02-04 9:41 ` Armin Wolf
2025-02-03 18:23 ` [PATCH 2/7] platform/x86: think-lmi: Use ACPI object when extracting strings Armin Wolf
2025-02-10 0:31 ` Armin Wolf
2025-02-11 16:46 ` Mark Pearson
2025-02-03 18:23 ` [PATCH 3/7] platform/x86: think-lmi: Use WMI bus API when accessing BIOS settings Armin Wolf
2025-02-13 13:17 ` Ilpo Järvinen
2025-02-14 3:07 ` Armin Wolf
2025-02-03 18:23 ` [PATCH 4/7] platform/x86: hp-bioscfg: Use wmi_instance_count() Armin Wolf
2025-02-04 10:37 ` Ilpo Järvinen [this message]
2025-02-04 13:06 ` Armin Wolf
2025-02-04 14:27 ` Ilpo Järvinen
2025-02-03 18:23 ` [PATCH 5/7] platform/x86: wmi: Rework WCxx/WExx ACPI method handling Armin Wolf
2025-02-03 18:23 ` [PATCH 6/7] platform/x86: wmi: Call WCxx methods when setting data blocks Armin Wolf
2025-02-03 18:23 ` [PATCH 7/7] platform/x86: wmi: Update documentation regarding the GUID-based API Armin Wolf
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=a02aa367-2ce8-ba6d-adc7-b91552566142@linux.intel.com \
--to=ilpo.jarvinen@linux.intel.com \
--cc=W_Armin@gmx.de \
--cc=corbet@lwn.net \
--cc=hdegoede@redhat.com \
--cc=james@equiv.tech \
--cc=jdelvare@suse.com \
--cc=jorge.lopez2@hp.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=markpearson@lenovo.com \
--cc=platform-driver-x86@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.