From: "Derek J. Clark" <derekjohn.clark@gmail.com>
To: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
Cc: Hans de Goede <hansg@kernel.org>,
Mark Pearson <mpearson-lenovo@squebb.ca>,
Armin Wolf <W_Armin@gmx.de>, Jonathan Corbet <corbet@lwn.net>,
Rong Zhang <i@rong.moe>, Kurt Borja <kuurtb@gmail.com>,
platform-driver-x86@vger.kernel.org,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v3 1/6] platform/x86: lenovo-wmi-other: Add LWMI_ATTR_ID Macro
Date: Wed, 25 Feb 2026 09:52:13 -0800 [thread overview]
Message-ID: <947F9B21-0300-4C2A-A8DB-DC190DCE7004@gmail.com> (raw)
In-Reply-To: <c8031935-0dab-59d0-a23f-b93c203ef95f@linux.intel.com>
On February 24, 2026 12:42:08 AM PST, "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com> wrote:
>On Tue, 24 Feb 2026, Derek J. Clark wrote:
>
>> Adds LWMI_ATTR_ID macro. In the same vein as LWMI_ATTR_ID_FAN_RPM,
>> but as a generic, to de-duplicate attribute_id assignment biolerplate.
>>
>> Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
>> Signed-off-by: Derek J. Clark <derekjohn.clark@gmail.com>
>> ---
>> drivers/platform/x86/lenovo/wmi-capdata.h | 6 ++++
>> drivers/platform/x86/lenovo/wmi-gamezone.h | 1 +
>> drivers/platform/x86/lenovo/wmi-other.c | 36 ++++++----------------
>> 3 files changed, 17 insertions(+), 26 deletions(-)
>>
>> diff --git a/drivers/platform/x86/lenovo/wmi-capdata.h b/drivers/platform/x86/lenovo/wmi-capdata.h
>> index 8c1df3efcc55..27202e2dc8a5 100644
>> --- a/drivers/platform/x86/lenovo/wmi-capdata.h
>> +++ b/drivers/platform/x86/lenovo/wmi-capdata.h
>> @@ -17,6 +17,12 @@
>> #define LWMI_ATTR_MODE_ID_MASK GENMASK(15, 8)
>> #define LWMI_ATTR_TYPE_ID_MASK GENMASK(7, 0)
>>
>> +#define LWMI_ATTR_ID(dev, feat, mode, type) \
>> + (FIELD_PREP(LWMI_ATTR_DEV_ID_MASK, dev) | \
>> + FIELD_PREP(LWMI_ATTR_FEAT_ID_MASK, feat) | \
>> + FIELD_PREP(LWMI_ATTR_MODE_ID_MASK, mode) | \
>> + FIELD_PREP(LWMI_ATTR_TYPE_ID_MASK, type))
>
>Why does this need to be macro? Static inline would have proper types.
>
Hi Ilpo,
It doesn't, I was just keeping it consistent with other previous uses. It's not a problem to change it. I'll need to move it somewhere else since this is a header.
Thanks,
Derek
>> +
>> #define LWMI_DEVICE_ID_FAN 0x04
>>
>> struct component_match;
>> diff --git a/drivers/platform/x86/lenovo/wmi-gamezone.h b/drivers/platform/x86/lenovo/wmi-gamezone.h
>> index 6b163a5eeb95..ddb919cf6c36 100644
>> --- a/drivers/platform/x86/lenovo/wmi-gamezone.h
>> +++ b/drivers/platform/x86/lenovo/wmi-gamezone.h
>> @@ -10,6 +10,7 @@ enum gamezone_events_type {
>> };
>>
>> enum thermal_mode {
>> + LWMI_GZ_THERMAL_MODE_NONE = 0x00,
>> LWMI_GZ_THERMAL_MODE_QUIET = 0x01,
>> LWMI_GZ_THERMAL_MODE_BALANCED = 0x02,
>> LWMI_GZ_THERMAL_MODE_PERFORMANCE = 0x03,
>> diff --git a/drivers/platform/x86/lenovo/wmi-other.c b/drivers/platform/x86/lenovo/wmi-other.c
>> index 6040f45aa2b0..95886df39c8d 100644
>> --- a/drivers/platform/x86/lenovo/wmi-other.c
>> +++ b/drivers/platform/x86/lenovo/wmi-other.c
>> @@ -71,10 +71,9 @@
>> #define LWMI_FAN_NR 4
>> #define LWMI_FAN_ID(x) ((x) + LWMI_FAN_ID_BASE)
>>
>> -#define LWMI_ATTR_ID_FAN_RPM(x) \
>> - (FIELD_PREP(LWMI_ATTR_DEV_ID_MASK, LWMI_DEVICE_ID_FAN) | \
>> - FIELD_PREP(LWMI_ATTR_FEAT_ID_MASK, LWMI_FEATURE_ID_FAN_RPM) | \
>> - FIELD_PREP(LWMI_ATTR_TYPE_ID_MASK, LWMI_FAN_ID(x)))
>> +#define LWMI_ATTR_ID_FAN_RPM(x) \
>> + LWMI_ATTR_ID(LWMI_DEVICE_ID_FAN, LWMI_FEATURE_ID_FAN_RPM, \
>> + LWMI_GZ_THERMAL_MODE_NONE, LWMI_FAN_ID(x))
>>
>> #define LWMI_FAN_DIV 100
>>
>> @@ -716,12 +715,8 @@ static ssize_t attr_capdata01_show(struct kobject *kobj,
>> u32 attribute_id;
>> int value, ret;
>>
>> - attribute_id =
>> - FIELD_PREP(LWMI_ATTR_DEV_ID_MASK, tunable_attr->device_id) |
>> - FIELD_PREP(LWMI_ATTR_FEAT_ID_MASK, tunable_attr->feature_id) |
>> - FIELD_PREP(LWMI_ATTR_MODE_ID_MASK,
>> - LWMI_GZ_THERMAL_MODE_CUSTOM) |
>> - FIELD_PREP(LWMI_ATTR_TYPE_ID_MASK, tunable_attr->type_id);
>> + attribute_id = LWMI_ATTR_ID(tunable_attr->device_id, tunable_attr->feature_id,
>> + LWMI_GZ_THERMAL_MODE_CUSTOM, tunable_attr->type_id);
>>
>> ret = lwmi_cd01_get_data(priv->cd01_list, attribute_id, &capdata);
>> if (ret)
>> @@ -776,7 +771,6 @@ static ssize_t attr_current_value_store(struct kobject *kobj,
>> struct wmi_method_args_32 args;
>> struct capdata01 capdata;
>> enum thermal_mode mode;
>> - u32 attribute_id;
>> u32 value;
>> int ret;
>>
>> @@ -787,13 +781,10 @@ static ssize_t attr_current_value_store(struct kobject *kobj,
>> if (mode != LWMI_GZ_THERMAL_MODE_CUSTOM)
>> return -EBUSY;
>>
>> - attribute_id =
>> - FIELD_PREP(LWMI_ATTR_DEV_ID_MASK, tunable_attr->device_id) |
>> - FIELD_PREP(LWMI_ATTR_FEAT_ID_MASK, tunable_attr->feature_id) |
>> - FIELD_PREP(LWMI_ATTR_MODE_ID_MASK, mode) |
>> - FIELD_PREP(LWMI_ATTR_TYPE_ID_MASK, tunable_attr->type_id);
>> + args.arg0 = LWMI_ATTR_ID(tunable_attr->device_id, tunable_attr->feature_id,
>> + mode, tunable_attr->type_id);
>>
>> - ret = lwmi_cd01_get_data(priv->cd01_list, attribute_id, &capdata);
>> + ret = lwmi_cd01_get_data(priv->cd01_list, args.arg0, &capdata);
>> if (ret)
>> return ret;
>>
>> @@ -804,7 +795,6 @@ static ssize_t attr_current_value_store(struct kobject *kobj,
>> if (value < capdata.min_value || value > capdata.max_value)
>> return -EINVAL;
>>
>> - args.arg0 = attribute_id;
>> args.arg1 = value;
>>
>> ret = lwmi_dev_evaluate_int(priv->wdev, 0x0, LWMI_FEATURE_VALUE_SET,
>> @@ -838,7 +828,6 @@ static ssize_t attr_current_value_show(struct kobject *kobj,
>> struct lwmi_om_priv *priv = dev_get_drvdata(tunable_attr->dev);
>> struct wmi_method_args_32 args;
>> enum thermal_mode mode;
>> - u32 attribute_id;
>> int retval;
>> int ret;
>>
>> @@ -846,13 +835,8 @@ static ssize_t attr_current_value_show(struct kobject *kobj,
>> if (ret)
>> return ret;
>>
>> - attribute_id =
>> - FIELD_PREP(LWMI_ATTR_DEV_ID_MASK, tunable_attr->device_id) |
>> - FIELD_PREP(LWMI_ATTR_FEAT_ID_MASK, tunable_attr->feature_id) |
>> - FIELD_PREP(LWMI_ATTR_MODE_ID_MASK, mode) |
>> - FIELD_PREP(LWMI_ATTR_TYPE_ID_MASK, tunable_attr->type_id);
>> -
>> - args.arg0 = attribute_id;
>> + args.arg0 = LWMI_ATTR_ID(tunable_attr->device_id, tunable_attr->feature_id,
>> + mode, tunable_attr->type_id);
>>
>> ret = lwmi_dev_evaluate_int(priv->wdev, 0x0, LWMI_FEATURE_VALUE_GET,
>> (unsigned char *)&args, sizeof(args),
>>
>
next prev parent reply other threads:[~2026-02-25 17:52 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-24 4:31 [PATCH v3 0/6] platform-x86: lenovo-wmi: Add fixes and enhancement Derek J. Clark
2026-02-24 4:31 ` [PATCH v3 1/6] platform/x86: lenovo-wmi-other: Add LWMI_ATTR_ID Macro Derek J. Clark
2026-02-24 8:42 ` Ilpo Järvinen
2026-02-25 17:52 ` Derek J. Clark [this message]
2026-02-26 9:18 ` Ilpo Järvinen
2026-02-24 8:43 ` Ilpo Järvinen
2026-02-24 4:31 ` [PATCH v3 2/6] platform/x86: lenovo-wmi-other: Limit adding attributes to supported devices Derek J. Clark
2026-02-24 8:47 ` Ilpo Järvinen
2026-02-25 17:58 ` Derek J. Clark
2026-02-26 9:20 ` Ilpo Järvinen
2026-02-25 17:14 ` Rong Zhang
2026-02-25 18:09 ` Derek J. Clark
2026-02-25 18:33 ` Rong Zhang
2026-02-24 4:31 ` [PATCH v3 3/6] platform/x86: lenovo-wmi-other: Add missing CPU tunable attributes Derek J. Clark
2026-02-24 8:49 ` Ilpo Järvinen
2026-02-24 4:31 ` [PATCH v3 4/6] platform/x86: lenovo-wmi-other: Add GPU " Derek J. Clark
2026-02-24 5:29 ` Derek J. Clark
2026-02-24 8:49 ` Ilpo Järvinen
2026-02-24 4:31 ` [PATCH v3 5/6] platform-x86: lenovo-wmi-other: Rename LWMI_OM_FW_ATTR_BASE_PATH Derek J. Clark
2026-02-24 8:51 ` Ilpo Järvinen
2026-02-25 18:00 ` Derek J. Clark
2026-02-25 17:25 ` Rong Zhang
2026-02-25 18:11 ` Derek J. Clark
2026-02-24 4:32 ` [PATCH v3 6/6] platform/x86: lenovo-wmi-other: Add WMI battery charge limiting Derek J. Clark
2026-02-24 9:05 ` Ilpo Järvinen
2026-02-25 18:04 ` Derek J. Clark
2026-02-24 9:17 ` Ilpo Järvinen
2026-02-25 17:55 ` Rong Zhang
2026-02-25 18:23 ` Derek J. Clark
2026-02-25 18:44 ` Rong Zhang
2026-02-25 18:02 ` [PATCH v3 0/6] platform-x86: lenovo-wmi: Add fixes and enhancement Rong Zhang
2026-02-25 18:26 ` Derek J. Clark
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=947F9B21-0300-4C2A-A8DB-DC190DCE7004@gmail.com \
--to=derekjohn.clark@gmail.com \
--cc=W_Armin@gmx.de \
--cc=corbet@lwn.net \
--cc=hansg@kernel.org \
--cc=i@rong.moe \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=kuurtb@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mpearson-lenovo@squebb.ca \
--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®