Re: [PATCH v2 5/9] platform/x86: asus-wmi: store a min default for ppt options

From: Ilpo Järvinen
Date: Tue Apr 02 2024 - 06:50:05 EST


On Tue, 2 Apr 2024, Luke D. Jones wrote:

> Laptops with any of the ppt or nv tunables default to the minimum setting
> on boot so we can safely assume a stored value is correct.
>
> This patch adds storing of those values in the local struct, and enables
> reading of those values back. To prevent creating a series of byte holes
> in the struct the "<name>_available" bool is removed and
> `asus_sysfs_is_visible()` uses the `ASUS_WMI_DEVID_<name>` directly.
>
> Signed-off-by: Luke D. Jones <luke@xxxxxxxxxx>
> ---
> drivers/platform/x86/asus-wmi.c | 127 +++++++++++++++++++++++++-------
> 1 file changed, 99 insertions(+), 28 deletions(-)
>
> diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
> index b795f9c1941f..c80afa385532 100644
> --- a/drivers/platform/x86/asus-wmi.c
> +++ b/drivers/platform/x86/asus-wmi.c
> @@ -262,13 +262,13 @@ struct asus_wmi {
> u32 gpu_mux_dev;
>
> /* Tunables provided by ASUS for gaming laptops */
> - bool ppt_pl2_sppt_available;
> - bool ppt_pl1_spl_available;
> - bool ppt_apu_sppt_available;
> - bool ppt_plat_sppt_available;
> - bool ppt_fppt_available;
> - bool nv_dyn_boost_available;
> - bool nv_temp_tgt_available;
> + u32 ppt_pl2_sppt;
> + u32 ppt_pl1_spl;
> + u32 ppt_apu_sppt;
> + u32 ppt_platform_sppt;
> + u32 ppt_fppt;
> + u32 nv_dynamic_boost;
> + u32 nv_temp_target;
>
> u32 kbd_rgb_dev;
> bool kbd_rgb_state_available;
> @@ -1020,11 +1020,21 @@ static ssize_t ppt_pl2_sppt_store(struct device *dev,
> return -EIO;
> }
>
> + asus->ppt_pl2_sppt = value;
> sysfs_notify(&asus->platform_device->dev.kobj, NULL, "ppt_pl2_sppt");
>
> return count;
> }
> -static DEVICE_ATTR_WO(ppt_pl2_sppt);
> +
> +static ssize_t ppt_pl2_sppt_show(struct device *dev,
> + struct device_attribute *attr,
> + char *buf)
> +{
> + struct asus_wmi *asus = dev_get_drvdata(dev);
> +
> + return sysfs_emit(buf, "%d\n", asus->ppt_pl2_sppt);

Use %u for u32 values. This applies to all sysfs_emits in this patch.

--
i.