Re: [PATCH 5/9] platform/x86: asus-wmi: use WMI_SIMPLE_SHOW in more places

From: Ilpo Järvinen
Date: Tue May 28 2024 - 05:06:37 EST


On Tue, 28 May 2024, Luke D. Jones wrote:

> Further reduce code duplication by using the new macros in a few more
> places.
>
> Signed-off-by: Luke D. Jones <luke@xxxxxxxxxx>
> ---
> drivers/platform/x86/asus-wmi.c | 30 ++++--------------------------
> 1 file changed, 4 insertions(+), 26 deletions(-)
>
> diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
> index 5c03e28ff252..260548aa6a42 100644
> --- a/drivers/platform/x86/asus-wmi.c
> +++ b/drivers/platform/x86/asus-wmi.c
> @@ -813,19 +813,6 @@ static void asus_wmi_tablet_mode_get_state(struct asus_wmi *asus)
> }
>
> /* dGPU ********************************************************************/
> -static ssize_t dgpu_disable_show(struct device *dev,
> - struct device_attribute *attr, char *buf)
> -{
> - struct asus_wmi *asus = dev_get_drvdata(dev);
> - int result;
> -
> - result = asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_DGPU);
> - if (result < 0)
> - return result;
> -
> - return sysfs_emit(buf, "%d\n", result);
> -}
> -
> /*
> * A user may be required to store the value twice, typcial store first, then
> * rescan PCI bus to activate power, then store a second time to save correctly.
> @@ -875,22 +862,11 @@ static ssize_t dgpu_disable_store(struct device *dev,
>
> return count;
> }
> +
> +WMI_SIMPLE_SHOW(dgpu_disable, "%d\n", ASUS_WMI_DEVID_DGPU);
> static DEVICE_ATTR_RW(dgpu_disable);
>
> /* eGPU ********************************************************************/
> -static ssize_t egpu_enable_show(struct device *dev,
> - struct device_attribute *attr, char *buf)
> -{
> - struct asus_wmi *asus = dev_get_drvdata(dev);
> - int result;
> -
> - result = asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_EGPU);
> - if (result < 0)
> - return result;
> -
> - return sysfs_emit(buf, "%d\n", result);
> -}
> -
> /* The ACPI call to enable the eGPU also disables the internal dGPU */
> static ssize_t egpu_enable_store(struct device *dev,
> struct device_attribute *attr,
> @@ -943,6 +919,8 @@ static ssize_t egpu_enable_store(struct device *dev,
>
> return count;
> }
> +
> +WMI_SIMPLE_SHOW(egpu_enable, "%d\n", ASUS_WMI_DEVID_EGPU);
> static DEVICE_ATTR_RW(egpu_enable);

It seems odd you do this subset in own patch. I think it would be more
logical if you reorder patches 4 and 5.

--
i.