From: "Mark Pearson" <mpearson-lenovo@squebb.ca>
To: "Rong Zhang" <i@rong.moe>
Cc: "Derek J . Clark" <derekjohn.clark@gmail.com>,
"Hans de Goede" <hansg@kernel.org>,
"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
"platform-driver-x86@vger.kernel.org"
<platform-driver-x86@vger.kernel.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 08/13] platform/x86: lenovo: Move TLMI helper functions into wmi-helpers
Date: Fri, 04 Dec 2026 10:50:45 -0500 [thread overview]
Message-ID: <9ee2aa49-ca99-4508-b016-6af733930682@app.fastmail.com> (raw)
In-Reply-To: <88914ac8c8bd4469ab2e1f13205c62d969dc26b8.camel@rong.moe>
On Fri, Dec 4, 2026, at 8:49 AM, Rong Zhang wrote:
> Hi Mark,
>
> On Thu, 2026-12-03 at 21:20 -0500, Mark Pearson wrote:
>> The tlmi_populate_string_buffer and tlmi_request are going to be
>> needed in the upcoming tlmi-auth module, as well as the current
>> tlmi-config module.
>>
>> As we can't have circular dependencies they need to move out of
>> tlmi-config.
>>
>> The wmi-helpers module already provides helper functions for the
>> Lenovo Legion platforms, and seems a logical place for these to
>> move too.
>>
>> Signed-off-by: Mark Pearson <mpearson-lenovo@squebb.ca>
>> ---
>> drivers/platform/x86/lenovo/Kconfig | 1 +
>> drivers/platform/x86/lenovo/tlmi-config.c | 59 +-------------------
>> drivers/platform/x86/lenovo/wmi-helpers.c | 65 ++++++++++++++++++++++-
>> drivers/platform/x86/lenovo/wmi-helpers.h | 5 ++
>> 4 files changed, 72 insertions(+), 58 deletions(-)
>>
>> diff --git a/drivers/platform/x86/lenovo/Kconfig b/drivers/platform/x86/lenovo/Kconfig
>> index 16569406c946..c59461cf5f4a 100644
>> --- a/drivers/platform/x86/lenovo/Kconfig
>> +++ b/drivers/platform/x86/lenovo/Kconfig
>> @@ -218,6 +218,7 @@ config THINKPAD_LMI
>> depends on ACPI_WMI
>> depends on DMI
>> select FW_ATTR_CLASS
>> + select LENOVO_WMI_HELPERS
>
> Ba aware of
> https://msgid.link/f8815e94ddc161495ca80b04d7e3388549edafeb.camel@rong.moe
> if you'd need to rebase on top of David's series.
>
Ack - I figured the review process was going to be a rough ride for this series. I'm sure I'll be rebasing a few times before we're done.
I actually wonder if I'll need to move this whole driver....
>> help
>> This driver allows changing BIOS settings on Lenovo machines whose
>> BIOS support the WMI interface.
>> diff --git a/drivers/platform/x86/lenovo/tlmi-config.c b/drivers/platform/x86/lenovo/tlmi-config.c
>> index ddbf0307f810..bb9c5f720c24 100644
>> --- a/drivers/platform/x86/lenovo/tlmi-config.c
>> +++ b/drivers/platform/x86/lenovo/tlmi-config.c
>> @@ -22,6 +22,7 @@
>> #include <linux/types.h>
>> #include <linux/wmi.h>
>> #include "think-lmi.h"
>> +#include "wmi-helpers.h"
>>
>> #define TLMI_CONFIG_GUID "816E5C9E-3E99-4385-AA5A-7353E14B781B"
>>
>> @@ -33,63 +34,6 @@ static DEFINE_MUTEX(tlmi_config_lock);
>>
>> /* ---- Helper functions---- */
>>
>> -static ssize_t tlmi_populate_string_buffer(char *buffer, size_t buffer_len, const char *str)
>> -{
>> - struct wmi_string *wmistr = (struct wmi_string *)buffer;
>> - u16 len;
>> - int ret;
>> -
>> - if (!str || !buffer)
>> - return -EINVAL;
>> -
>> - ret = wmi_string_from_utf8s((struct wmi_string *)buffer, buffer_len, str, strlen(str));
>> - if (ret < 0)
>> - return ret;
>> -
>> - len = le16_to_cpu(wmistr->length);
>> - wmistr->length = cpu_to_le16(len - 2); /* Remove the extra null added */
>> - return len; /* minus extra null and + the length field */
>> -}
>> -
>> -/* Send request to BIOS and scan return buffer for error codes */
>> -static int tlmi_request(struct wmi_device *wdev, u8 instance, u32 method_id,
>> - struct wmi_buffer *wmibuf)
>> -{
>> - struct wmi_buffer wmibuf_return = {0, NULL};
>> - char errstr[32];
>> - int ret;
>> -
>> - ret = wmidev_invoke_method(wdev, instance, method_id, wmibuf, &wmibuf_return,
>> - sizeof(struct wmi_string));
>> - if (!ret && wmibuf_return.data) {
>> - /* extract error string */
>> - if (wmibuf_return.length < 2 || wmibuf_return.length > sizeof(errstr) * 2)
>> - ret = -EINVAL;
>> - else
>> - ret = wmi_string_to_utf8s((struct wmi_string *)wmibuf_return.data, errstr,
>> - sizeof(errstr));
>> - kfree(wmibuf_return.data);
>> - if (ret < 0)
>> - return ret;
>> -
>> - if (!strcmp("Success", errstr))
>> - return 0;
>> - else if (!strcmp("Not Supported", errstr))
>> - return -EOPNOTSUPP;
>> - else if (!strcmp("Invalid Parameter", errstr))
>> - return -EINVAL;
>> - else if (!strcmp("Access Denied", errstr))
>> - return -EACCES;
>> - else if (!strcmp("System Busy", errstr))
>> - return -EBUSY;
>> - else if (!strcmp("System Locked", errstr))
>> - return -EACCES;
>> - dev_warn(&wdev->dev, "Unknown error condition %s\n", errstr);
>> - return -EIO;
>> - }
>> - return ret;
>> -}
>> -
>
> What? Wasn't these just introduced before? Could you add them to the
> right place from the beginning?
>
Probably a bad call on my part - a little bit part of how I went about developing the driver and building up the patchset.
I'll move this up much earlier in the series and get rid of the move if that helps.
>> static ssize_t common_type_show(char *possible_values, char *buf)
>> {
>> if (possible_values) {
>> @@ -477,6 +421,7 @@ static struct wmi_driver tlmi_config_driver = {
>>
>> module_wmi_driver(tlmi_config_driver);
>>
>> +MODULE_IMPORT_NS("LENOVO_WMI_HELPERS");
>> MODULE_IMPORT_NS("TLMI-ATTR");
>> MODULE_IMPORT_NS("TLMI-AUTHDATA");
>> MODULE_DEVICE_TABLE(wmi, tlmi_config_id_table);
>> diff --git a/drivers/platform/x86/lenovo/wmi-helpers.c b/drivers/platform/x86/lenovo/wmi-helpers.c
>> index 687caa226263..e735771bb8d7 100644
>> --- a/drivers/platform/x86/lenovo/wmi-helpers.c
>> +++ b/drivers/platform/x86/lenovo/wmi-helpers.c
>> @@ -1,6 +1,6 @@
>> // SPDX-License-Identifier: GPL-2.0-or-later
>> /*
>> - * Lenovo Legion WMI helpers driver.
>> + * Lenovo Legion and TLMI WMI helpers driver.
>> *
>> * The Lenovo Legion WMI interface is broken up into multiple GUID interfaces
>> * that require cross-references between GUID's for some functionality. The
>> @@ -13,6 +13,10 @@
>> * drivers uses a common procedure to get data from the WMI interface,
>> * enumerated here.
>> *
>> + * TLMI interface uses multiple GUID interfaces for BIOS settings and
>> + * authentication settings. A common procedure is used to get data from the
>> + * WMI interface and check for return error strings.
>> + *
>> * Copyright (C) 2025 Derek J. Clark <derekjohn.clark@gmail.com>
>> */
>>
>> @@ -33,6 +37,65 @@
>> /* Thermal mode notifier chain. */
>> static BLOCKING_NOTIFIER_HEAD(tm_chain_head);
>>
>> +ssize_t tlmi_populate_string_buffer(char *buffer, size_t buffer_len, const char *str)
>
> Why not void *buffer?
>
>> +{
>> + struct wmi_string *wmistr = (struct wmi_string *)buffer;
>> + u16 len;
>> + int ret;
>> +
>> + if (!str || !buffer)
>> + return -EINVAL;
>> +
>> + ret = wmi_string_from_utf8s((struct wmi_string *)buffer, buffer_len, str, strlen(str));
>> + if (ret < 0)
>> + return ret;
>> +
>> + len = le16_to_cpu(wmistr->length);
>> + wmistr->length = cpu_to_le16(len - 2); /* Remove the extra null added */
>> + return len; /* minus extra null and + the length field */
>> +}
>> +EXPORT_SYMBOL_NS_GPL(tlmi_populate_string_buffer, "LENOVO_WMI_HELPERS");
>
> I believe this helper can be named lwmi_* as it's not coupled with
> thinklmi...
>
Sure
>> +
>> +/* Send request to BIOS and scan return buffer for error codes */
>> +int tlmi_request(struct wmi_device *wdev, u8 instance, u32 method_id,
>> + struct wmi_buffer *wmibuf)
>
> ...while this is coupled with thinklmi, so this can be named tlmi_*.
>
Thanks
Mark
next prev parent reply other threads:[~2026-12-04 15:51 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 2:20 [PATCH 00/13] New Lenovo common WMI driver - tlmi Mark Pearson
2026-12-04 2:20 ` [PATCH 01/13] platform/x86: lenovo: think-lmi: Convert name arrays to pointers Mark Pearson
2026-12-04 2:20 ` [PATCH 02/13] platform/x86: lenovo: think-lmi: Clean up attributes if not added to list Mark Pearson
2026-12-04 13:20 ` Rong Zhang
2026-12-04 15:09 ` Mark Pearson
2026-12-04 2:20 ` [PATCH 03/13] platform/x86: lenovo: think-lmi: cache current value at init Mark Pearson
2026-12-04 13:28 ` Rong Zhang
2026-12-04 15:14 ` Mark Pearson
2026-12-04 2:20 ` [PATCH 04/13] platform/x86: lenovo: think-lmi: store attributes as linked list Mark Pearson
2026-12-04 13:30 ` Rong Zhang
2026-12-04 15:21 ` Mark Pearson
2026-12-04 16:10 ` Rong Zhang
2026-12-04 2:20 ` [PATCH 05/13] platform/x86: lenovo: tlmi: New tlmi driver for common WMI implementation Mark Pearson
2026-12-04 13:41 ` Rong Zhang
2026-12-04 15:27 ` Mark Pearson
2026-12-05 9:54 ` kernel test robot
2026-12-05 9:55 ` kernel test robot
2026-12-04 2:20 ` [PATCH 06/13] platform/x86: lenovo: tlmi: Add BIOS attributes sysfs entries Mark Pearson
2026-12-04 13:44 ` Rong Zhang
2026-12-04 15:41 ` Mark Pearson
2026-12-04 17:02 ` Rong Zhang
2026-12-04 2:20 ` [PATCH 07/13] platform/x86: lenovo: tlmi: Retrieve auth information Mark Pearson
2026-12-04 13:48 ` Rong Zhang
2026-12-04 15:44 ` Mark Pearson
2026-12-04 17:14 ` Rong Zhang
2026-12-04 17:26 ` Mark Pearson
2026-12-04 2:20 ` [PATCH 08/13] platform/x86: lenovo: Move TLMI helper functions into wmi-helpers Mark Pearson
2026-12-04 13:49 ` Rong Zhang
2026-12-04 15:50 ` Mark Pearson [this message]
2026-12-04 17:19 ` Rong Zhang
2026-12-04 17:27 ` Mark Pearson
2026-12-04 2:20 ` [PATCH 09/13] platform/x86: lenovo: tlmi: Add authentication sysfs entries Mark Pearson
2026-12-04 13:52 ` Rong Zhang
2026-12-05 9:55 ` kernel test robot
2026-12-04 2:20 ` [PATCH 10/13] platform/x86: lenovo: tlmi: Add platform attribute support Mark Pearson
2026-12-04 2:20 ` [PATCH 11/13] platform/x86: lenovo: tlmi: Add function attributes support Mark Pearson
2026-12-04 2:20 ` [PATCH 12/13] platform/x86: lenovo: tlmi: Add method identifier Mark Pearson
2026-12-04 2:20 ` [PATCH 13/13] docs: ABI: sysfs-class-firmware-attributes: Update Lenovo sections Mark Pearson
2026-12-04 13:19 ` [PATCH 00/13] New Lenovo common WMI driver - tlmi Rong Zhang
2026-12-04 14:42 ` Mark Pearson
2026-12-04 17:49 ` Rong Zhang
2026-12-04 18:22 ` Mark Pearson
2026-12-04 20:04 ` Rong Zhang
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=9ee2aa49-ca99-4508-b016-6af733930682@app.fastmail.com \
--to=mpearson-lenovo@squebb.ca \
--cc=derekjohn.clark@gmail.com \
--cc=hansg@kernel.org \
--cc=i@rong.moe \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®