From: "Mark Pearson" <mpearson-lenovo@squebb.ca>
To: "Rong Zhang" <i@rong.moe>,
"Derek J . Clark" <derekjohn.clark@gmail.com>,
"Hans de Goede" <hansg@kernel.org>,
"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
"Alok Tiwari" <alok.a.tiwari@oracle.com>,
"Armin Wolf" <W_Armin@gmx.de>
Cc: "platform-driver-x86@vger.kernel.org"
<platform-driver-x86@vger.kernel.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/5] platform/x86: lenovo-wmi-other: Factor out tunable_attr_01 definition into a macro
Date: Wed, 18 Nov 2026 17:19:42 -0500 [thread overview]
Message-ID: <2a87d4a1-b494-455f-984a-e8b93d5df70a@app.fastmail.com> (raw)
In-Reply-To: <20261119-lwmi-no-singleton-v1-3-6b06fcfb5126@rong.moe>
On Wed, Nov 18, 2026, at 1:58 PM, Rong Zhang wrote:
> Currently, all definitions of statically allocated tunable_attr_01
> variables are open-coded, making them hard to refactor.
>
> Add a macro to define statically allocated tunable_attr_01 variables so
> that further refactoring only touches the macro itself.
>
> Meanwhile, move the definition of statically allocated tunable_attr_01
> variables before the definition of struct lwmi_om_priv, so that upcoming
> changes can reference the former as needed.
>
> No functional change intended.
>
> Signed-off-by: Rong Zhang <i@rong.moe>
> ---
> drivers/platform/x86/lenovo/wmi-other.c | 178 +++++++-------------------------
> 1 file changed, 38 insertions(+), 140 deletions(-)
>
> diff --git a/drivers/platform/x86/lenovo/wmi-other.c
> b/drivers/platform/x86/lenovo/wmi-other.c
> index 4d51b05a5acf..252ef775f300 100644
> --- a/drivers/platform/x86/lenovo/wmi-other.c
> +++ b/drivers/platform/x86/lenovo/wmi-other.c
> @@ -130,6 +130,44 @@ struct lwmi_fan_info {
> long max_rpm;
> };
>
> +struct tunable_attr_01 {
> + u8 feature_id;
> + u8 device_id;
> + u8 type_id;
Really just a minor note that everywhere else in the code goes device, feature, type.
If you end up doing a v2 can you swap the order of feature and device in the above - purely for universal karma?
> + u8 cd_mode_id; /* mode arg for searching capdata */
> + u8 cv_mode_id; /* mode arg for set/get current_value */
> +};
> +
> +#define DEFINE_TUNABLE_ATTR_01(_name, _device, _feature, _type) \
> + static struct tunable_attr_01 _name = { \
> + .device_id = LWMI_DEVICE_ID_##_device, \
> + .feature_id = LWMI_FEATURE_ID_##_feature, \
> + .type_id = LWMI_TYPE_ID_##_type, \
> + }
> +
> +DEFINE_TUNABLE_ATTR_01(ppt_pl1_spl, CPU, CPU_SPL, NONE);
> +DEFINE_TUNABLE_ATTR_01(ppt_pl1_spl_cl, CPU, CPU_SPL, CROSSLOAD);
> +DEFINE_TUNABLE_ATTR_01(ppt_pl2_sppt, CPU, CPU_SPPT, NONE);
> +DEFINE_TUNABLE_ATTR_01(ppt_pl2_sppt_cl, CPU, CPU_SPPT, CROSSLOAD);
> +DEFINE_TUNABLE_ATTR_01(ppt_pl3_fppt, CPU, CPU_FPPT, NONE);
> +DEFINE_TUNABLE_ATTR_01(ppt_pl3_fppt_cl, CPU, CPU_FPPT, CROSSLOAD);
> +DEFINE_TUNABLE_ATTR_01(cpu_temp, CPU, CPU_TEMP, NONE);
> +DEFINE_TUNABLE_ATTR_01(ppt_pl1_apu_spl, CPU, CPU_APU, NONE);
> +DEFINE_TUNABLE_ATTR_01(ppt_cpu_cl, CPU, CPU_CL, NONE);
> +DEFINE_TUNABLE_ATTR_01(ppt_pl1_tau, CPU, CPU_TAU, NONE);
> +DEFINE_TUNABLE_ATTR_01(ppt_pl4_ipl, CPU, CPU_IPL, NONE);
> +DEFINE_TUNABLE_ATTR_01(ppt_pl4_ipl_cl, CPU, CPU_IPL, CROSSLOAD);
> +DEFINE_TUNABLE_ATTR_01(gpu_nv_ppab, GPU, GPU_NV_PPAB, NONE);
> +DEFINE_TUNABLE_ATTR_01(gpu_nv_ctgp, GPU, GPU_NV_CTGP, NONE);
> +DEFINE_TUNABLE_ATTR_01(gpu_temp, GPU, GPU_TEMP, NONE);
> +DEFINE_TUNABLE_ATTR_01(gpu_nv_ac_offset, GPU, GPU_AC_OFFSET, NONE);
> +DEFINE_TUNABLE_ATTR_01(dgpu_boost_clk, GPU, DGPU_BOOST_CLK, NONE);
> +DEFINE_TUNABLE_ATTR_01(dgpu_enable, GPU, DGPU_EN, NONE);
> +DEFINE_TUNABLE_ATTR_01(gpu_mode, GPU, GPU_MODE, NONE);
> +DEFINE_TUNABLE_ATTR_01(dgpu_didvid, GPU, DGPU_DIDVID, NONE);
> +DEFINE_TUNABLE_ATTR_01(gpu_nv_bpl, GPU, GPU_NV_BPL, NONE);
> +DEFINE_TUNABLE_ATTR_01(gpu_nv_cpu_boost, GPU, GPU_NV_CPU_BOOST, NONE);
> +
> struct lwmi_om_priv {
> struct component_master_ops *ops;
>
> @@ -966,14 +1004,6 @@ static void lwmi_om_psy_remove(struct lwmi_om_priv *priv)
>
> /* ======== fw_attributes (component: lenovo-wmi-capdata 01) ======== */
>
> -struct tunable_attr_01 {
> - u8 feature_id;
> - u8 device_id;
> - u8 type_id;
> - u8 cd_mode_id; /* mode arg for searching capdata */
> - u8 cv_mode_id; /* mode arg for set/get current_value */
> -};
> -
> /**
> * tunable_attr_01_id() - Formats a tunable_attr_01 to a capdata
> attribute ID
> * @attr: The tunable_attr_01 to format.
> @@ -986,138 +1016,6 @@ static u32 tunable_attr_01_id(const struct
> tunable_attr_01 *attr, u8 mode)
> return lwmi_attr_id(attr->device_id, attr->feature_id, mode,
> attr->type_id);
> }
>
> -static struct tunable_attr_01 ppt_pl1_spl = {
> - .device_id = LWMI_DEVICE_ID_CPU,
> - .feature_id = LWMI_FEATURE_ID_CPU_SPL,
> - .type_id = LWMI_TYPE_ID_NONE,
> -};
> -
> -static struct tunable_attr_01 ppt_pl1_spl_cl = {
> - .device_id = LWMI_DEVICE_ID_CPU,
> - .feature_id = LWMI_FEATURE_ID_CPU_SPL,
> - .type_id = LWMI_TYPE_ID_CROSSLOAD,
> -};
> -
> -static struct tunable_attr_01 ppt_pl2_sppt = {
> - .device_id = LWMI_DEVICE_ID_CPU,
> - .feature_id = LWMI_FEATURE_ID_CPU_SPPT,
> - .type_id = LWMI_TYPE_ID_NONE,
> -};
> -
> -static struct tunable_attr_01 ppt_pl2_sppt_cl = {
> - .device_id = LWMI_DEVICE_ID_CPU,
> - .feature_id = LWMI_FEATURE_ID_CPU_SPPT,
> - .type_id = LWMI_TYPE_ID_CROSSLOAD,
> -};
> -
> -static struct tunable_attr_01 ppt_pl3_fppt = {
> - .device_id = LWMI_DEVICE_ID_CPU,
> - .feature_id = LWMI_FEATURE_ID_CPU_FPPT,
> - .type_id = LWMI_TYPE_ID_NONE,
> -};
> -
> -static struct tunable_attr_01 ppt_pl3_fppt_cl = {
> - .device_id = LWMI_DEVICE_ID_CPU,
> - .feature_id = LWMI_FEATURE_ID_CPU_FPPT,
> - .type_id = LWMI_TYPE_ID_CROSSLOAD,
> -};
> -
> -static struct tunable_attr_01 cpu_temp = {
> - .device_id = LWMI_DEVICE_ID_CPU,
> - .feature_id = LWMI_FEATURE_ID_CPU_TEMP,
> - .type_id = LWMI_TYPE_ID_NONE,
> -};
> -
> -static struct tunable_attr_01 ppt_pl1_apu_spl = {
> - .device_id = LWMI_DEVICE_ID_CPU,
> - .feature_id = LWMI_FEATURE_ID_CPU_APU,
> - .type_id = LWMI_TYPE_ID_NONE,
> -};
> -
> -static struct tunable_attr_01 ppt_cpu_cl = {
> - .device_id = LWMI_DEVICE_ID_CPU,
> - .feature_id = LWMI_FEATURE_ID_CPU_CL,
> - .type_id = LWMI_TYPE_ID_NONE,
> -};
> -
> -static struct tunable_attr_01 ppt_pl1_tau = {
> - .device_id = LWMI_DEVICE_ID_CPU,
> - .feature_id = LWMI_FEATURE_ID_CPU_TAU,
> - .type_id = LWMI_TYPE_ID_NONE,
> -};
> -
> -static struct tunable_attr_01 ppt_pl4_ipl = {
> - .device_id = LWMI_DEVICE_ID_CPU,
> - .feature_id = LWMI_FEATURE_ID_CPU_IPL,
> - .type_id = LWMI_TYPE_ID_NONE,
> -};
> -
> -static struct tunable_attr_01 ppt_pl4_ipl_cl = {
> - .device_id = LWMI_DEVICE_ID_CPU,
> - .feature_id = LWMI_FEATURE_ID_CPU_IPL,
> - .type_id = LWMI_TYPE_ID_CROSSLOAD,
> -};
> -
> -static struct tunable_attr_01 gpu_nv_ppab = {
> - .device_id = LWMI_DEVICE_ID_GPU,
> - .feature_id = LWMI_FEATURE_ID_GPU_NV_PPAB,
> - .type_id = LWMI_TYPE_ID_NONE,
> -};
> -
> -static struct tunable_attr_01 gpu_nv_ctgp = {
> - .device_id = LWMI_DEVICE_ID_GPU,
> - .feature_id = LWMI_FEATURE_ID_GPU_NV_CTGP,
> - .type_id = LWMI_TYPE_ID_NONE,
> -};
> -
> -static struct tunable_attr_01 gpu_temp = {
> - .device_id = LWMI_DEVICE_ID_GPU,
> - .feature_id = LWMI_FEATURE_ID_GPU_TEMP,
> - .type_id = LWMI_TYPE_ID_NONE,
> -};
> -
> -static struct tunable_attr_01 gpu_nv_ac_offset = {
> - .device_id = LWMI_DEVICE_ID_GPU,
> - .feature_id = LWMI_FEATURE_ID_GPU_AC_OFFSET,
> - .type_id = LWMI_TYPE_ID_NONE,
> -};
> -
> -static struct tunable_attr_01 dgpu_boost_clk = {
> - .device_id = LWMI_DEVICE_ID_GPU,
> - .feature_id = LWMI_FEATURE_ID_DGPU_BOOST_CLK,
> - .type_id = LWMI_TYPE_ID_NONE,
> -};
> -
> -static struct tunable_attr_01 dgpu_enable = {
> - .device_id = LWMI_DEVICE_ID_GPU,
> - .feature_id = LWMI_FEATURE_ID_DGPU_EN,
> - .type_id = LWMI_TYPE_ID_NONE,
> -};
> -
> -static struct tunable_attr_01 gpu_mode = {
> - .device_id = LWMI_DEVICE_ID_GPU,
> - .feature_id = LWMI_FEATURE_ID_GPU_MODE,
> - .type_id = LWMI_TYPE_ID_NONE,
> -};
> -
> -static struct tunable_attr_01 dgpu_didvid = {
> - .device_id = LWMI_DEVICE_ID_GPU,
> - .feature_id = LWMI_FEATURE_ID_DGPU_DIDVID,
> - .type_id = LWMI_TYPE_ID_NONE,
> -};
> -
> -static struct tunable_attr_01 gpu_nv_bpl = {
> - .device_id = LWMI_DEVICE_ID_GPU,
> - .feature_id = LWMI_FEATURE_ID_GPU_NV_BPL,
> - .type_id = LWMI_TYPE_ID_NONE,
> -};
> -
> -static struct tunable_attr_01 gpu_nv_cpu_boost = {
> - .device_id = LWMI_DEVICE_ID_GPU,
> - .feature_id = LWMI_FEATURE_ID_GPU_NV_CPU_BOOST,
> - .type_id = LWMI_TYPE_ID_NONE,
> -};
> -
> struct capdata01_attr {
> struct kobj_attribute kobj_attr;
> struct tunable_attr_01 *tunable_attr;
>
> --
> 2.55.0
Looks good to me (I'm OK if my comment above is ignored)
Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Mark
next prev parent reply other threads:[~2026-11-18 22:20 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 18:58 [PATCH 0/5] platform/x86: lenovo-wmi-other: Refine firmware_attributes interface Rong Zhang
2026-11-18 18:58 ` [PATCH 1/5] platform/x86: lenovo-wmi-other: Retrieve private data from firmware_attributes device Rong Zhang
2026-11-18 22:19 ` Mark Pearson
2026-11-18 18:58 ` [PATCH 2/5] platform/x86: lenovo-wmi-other: Eliminate attribute-specific callbacks Rong Zhang
2026-11-18 22:17 ` Mark Pearson
2026-11-18 18:58 ` [PATCH 3/5] platform/x86: lenovo-wmi-other: Factor out tunable_attr_01 definition into a macro Rong Zhang
2026-11-18 22:19 ` Mark Pearson [this message]
2026-11-18 18:58 ` [PATCH 4/5] platform/x86: lenovo-wmi-other: Properly implement no_singleton driver Rong Zhang
2026-11-18 22:27 ` Mark Pearson
2026-11-18 18:58 ` [PATCH 5/5] platform/x86: lenovo-wmi-other: Hide unsupported attributes using is_visible() callback Rong Zhang
2026-11-18 22:23 ` Mark Pearson
2026-11-18 22:19 ` [PATCH 0/5] platform/x86: lenovo-wmi-other: Refine firmware_attributes interface Mark Pearson
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=2a87d4a1-b494-455f-984a-e8b93d5df70a@app.fastmail.com \
--to=mpearson-lenovo@squebb.ca \
--cc=W_Armin@gmx.de \
--cc=alok.a.tiwari@oracle.com \
--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®