Re: [PATCH v4 6/6] thermal/drivers/intel_menlow: Make additionnal sysfs information optional

From: Rafael J. Wysocki
Date: Thu Apr 20 2023 - 13:24:46 EST


On Wed, Apr 19, 2023 at 10:33 AM Daniel Lezcano
<daniel.lezcano@xxxxxxxxxx> wrote:
>
> The Menlon thermal driver creates auxiliary trip points in the thermal
> zone sysfs directory. It is specific to Menlon. Actually these trip
> points could be generalized with the generic trip points in the future.
>
> Let's make the code optional and disable it by default so we have a
> consistency with the attributes in the thermal zone sysfs
> directories. If that hurts we will enable by default this option
> instead of disabling it.
>
> Signed-off-by: Daniel Lezcano <daniel.lezcano@xxxxxxxxxx>
> ---
> drivers/thermal/intel/Kconfig | 11 +++++++++++
> drivers/thermal/intel/intel_menlow.c | 9 +++++++++
> 2 files changed, 20 insertions(+)
>
> diff --git a/drivers/thermal/intel/Kconfig b/drivers/thermal/intel/Kconfig
> index cb7e7697cf1e..ef7ffe6b56a0 100644
> --- a/drivers/thermal/intel/Kconfig
> +++ b/drivers/thermal/intel/Kconfig
> @@ -112,6 +112,17 @@ config INTEL_MENLOW
>
> If unsure, say N.
>
> +config INTEL_MENLOW_SYSFS_ADDON
> + bool "Enable extra sysfs attributes in the thermal zone"
> + depends on INTEL_MENLOW
> + def_bool n
> + help
> + Create auxiliary trip points in the thermal zone sysfs
> + directory. This is specific to this driver. By default those
> + are disabled and are candidate for removal, if you need these
> + information anyway, enable the option or upgrade the
> + userspace program using them.
> +
> config INTEL_HFI_THERMAL
> bool "Intel Hardware Feedback Interface"
> depends on NET
> diff --git a/drivers/thermal/intel/intel_menlow.c b/drivers/thermal/intel/intel_menlow.c
> index d720add918ff..605983be516c 100644
> --- a/drivers/thermal/intel/intel_menlow.c
> +++ b/drivers/thermal/intel/intel_menlow.c
> @@ -367,6 +367,7 @@ static ssize_t bios_enabled_show(struct device *dev,
> return sprintf(buf, "%s\n", bios_enabled ? "enabled" : "disabled");
> }
>
> +#ifdef CONFIG_INTEL_MENLOW_SYSFS_ADDON
> static int intel_menlow_add_one_attribute(char *name, umode_t mode, void *show,
> void *store, struct device *dev,
> acpi_handle handle)
> @@ -398,6 +399,14 @@ static int intel_menlow_add_one_attribute(char *name, umode_t mode, void *show,
>
> return 0;
> }
> +#else
> +static int intel_menlow_add_one_attribute(char *name, umode_t mode, void *show,
> + void *store, struct device *dev,
> + acpi_handle handle)
> +{
> + return 0;
> +}

After looking at it once more, I think that this driver isn't really
functional without the additional sysfs attributes, so if
CONFIG_INTEL_MENLOW_SYSFS_ADDON is set, the driver effectively becomes
dead code.

That's rather unfortunate and I'm not sure how to deal with it ATM.

I can queue up the rest of the series for 6.4-rc1 (in which case it
will be pushed in the second half of the merge window), but this
particular patch requires more thought IMV.

> +#endif
>
> static acpi_status intel_menlow_register_sensor(acpi_handle handle, u32 lvl,
> void *context, void **rv)
> --