public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
From: Mario Limonciello <mario.limonciello@amd.com>
To: Kurt Borja <kuurtb@gmail.com>, platform-driver-x86@vger.kernel.org
Cc: "Rafael J. Wysocki" <rafael@kernel.org>,
	"Len Brown" <lenb@kernel.org>,
	linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Armin Wolf" <W_Armin@gmx.de>,
	"Joshua Grisham" <josh@joshuagrisham.com>,
	"Derek J . Clark" <derekjohn.clark@gmail.com>,
	"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
	"Hans de Goede" <hdegoede@redhat.com>,
	"Maximilian Luz" <luzmaximilian@gmail.com>,
	"Lee, Chun-Yi" <jlee@suse.com>,
	"Shyam Sundar S K" <Shyam-sundar.S-k@amd.com>,
	"Corentin Chary" <corentin.chary@gmail.com>,
	"Luke D. Jones" <luke@ljones.dev>,
	"Lyndon Sanche" <lsanche@lyndeno.ca>,
	"Ike Panhc" <ike.pan@canonical.com>,
	"Henrique de Moraes Holschuh" <hmh@hmh.eng.br>,
	"Mark Pearson" <mpearson-lenovo@squebb.ca>,
	"Colin Ian King" <colin.i.king@gmail.com>,
	"Alexis Belmonte" <alexbelm48@gmail.com>,
	"Uwe Kleine-König" <u.kleine-koenig@baylibre.com>,
	"Ai Chao" <aichao@kylinos.cn>, "Gergo Koteles" <soyer@irl.hu>,
	Dell.Client.Kernel@dell.com,
	ibm-acpi-devel@lists.sourceforge.net
Subject: Re: [PATCH 02/18] ACPI: platform_profile: Add `choices` to platform_profile_ops
Date: Thu, 9 Jan 2025 10:32:31 -0600	[thread overview]
Message-ID: <1c921cca-1ac8-4e73-94e2-79884f596287@amd.com> (raw)
In-Reply-To: <20250109150731.110799-3-kuurtb@gmail.com>

On 1/9/2025 09:06, Kurt Borja wrote:
> Add a `choices` callback to platform_profile_ops, which lets drivers
> specify how to select available profiles.
> 
> Signed-off-by: Kurt Borja <kuurtb@gmail.com>
> ---
>   drivers/acpi/platform_profile.c               | 13 +++++++--
>   .../surface/surface_platform_profile.c        | 16 ++++++----
>   drivers/platform/x86/acer-wmi.c               | 24 ++++++++-------
>   drivers/platform/x86/amd/pmf/sps.c            | 15 ++++++----
>   drivers/platform/x86/asus-wmi.c               | 16 ++++++----
>   drivers/platform/x86/dell/alienware-wmi.c     | 24 +++++++++------
>   drivers/platform/x86/dell/dell-pc.c           | 26 ++++++++++-------
>   drivers/platform/x86/hp/hp-wmi.c              | 29 +++++++++++++------
>   drivers/platform/x86/ideapad-laptop.c         | 15 ++++++----
>   .../platform/x86/inspur_platform_profile.c    | 14 ++++++---
>   drivers/platform/x86/thinkpad_acpi.c          | 15 ++++++----
>   include/linux/platform_profile.h              |  1 +
>   12 files changed, 137 insertions(+), 71 deletions(-)
> 
> diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
> index 39a22e27acc5..9cb82173947c 100644
> --- a/drivers/acpi/platform_profile.c
> +++ b/drivers/acpi/platform_profile.c
> @@ -464,12 +464,21 @@ int platform_profile_register(struct platform_profile_handler *pprof)
>   	int err;
>   
>   	/* Sanity check the profile handler */
> -	if (!pprof || bitmap_empty(pprof->choices, PLATFORM_PROFILE_LAST) ||
> -	    !pprof->ops->profile_set || !pprof->ops->profile_get) {
> +	if (!pprof || !pprof->ops->profile_set || !pprof->ops->profile_get ||
> +	    !pprof->ops->choices) {
>   		pr_err("platform_profile: handler is invalid\n");
>   		return -EINVAL;
>   	}
>   
> +	err = pprof->ops->choices(pprof);
> +	if (err < 0)
> +		return err;
> +
> +	if (bitmap_empty(pprof->choices, PLATFORM_PROFILE_LAST)) {
> +		pr_err("platform_profile: no available profiles\n");
> +		return -EINVAL;
> +	}
> +
>   	guard(mutex)(&profile_lock);
>   
>   	/* create class interface for individual handler */
> diff --git a/drivers/platform/surface/surface_platform_profile.c b/drivers/platform/surface/surface_platform_profile.c
> index 2a9716372d56..b69fcc4c3858 100644
> --- a/drivers/platform/surface/surface_platform_profile.c
> +++ b/drivers/platform/surface/surface_platform_profile.c
> @@ -201,9 +201,20 @@ static int ssam_platform_profile_set(struct platform_profile_handler *pprof,
>   	return tp;
>   }
>   
> +static int ssam_platform_profile_choices(struct platform_profile_handler *pprof)
> +{
> +	set_bit(PLATFORM_PROFILE_LOW_POWER, pprof->choices);
> +	set_bit(PLATFORM_PROFILE_BALANCED, pprof->choices);
> +	set_bit(PLATFORM_PROFILE_BALANCED_PERFORMANCE, pprof->choices);
> +	set_bit(PLATFORM_PROFILE_PERFORMANCE, pprof->choices);
> +
> +	return 0;

At first I didn't really like the callback, but it grew on me and I 
realized why I didn't like it is because it's confusing that the 
callback is called .choices() as well as the implementation used is 
called .choices.

If anything it should be "set_choices" or "probe" with a slight leaning 
on probe()..

With probe the flow could be:

driver()
->platform_profile_register(ops)
->->drivers's implementation for platform_profile_probe()


> +}
> +
>   static const struct platform_profile_ops ssam_platform_profile_ops = {
>   	.profile_get = ssam_platform_profile_get,
>   	.profile_set = ssam_platform_profile_set,
> +	.choices = ssam_platform_profile_choices,
>   };
>   
>   static int surface_platform_profile_probe(struct ssam_device *sdev)
> @@ -223,11 +234,6 @@ static int surface_platform_profile_probe(struct ssam_device *sdev)
>   
>   	tpd->has_fan = device_property_read_bool(&sdev->dev, "has_fan");
>   
> -	set_bit(PLATFORM_PROFILE_LOW_POWER, tpd->handler.choices);
> -	set_bit(PLATFORM_PROFILE_BALANCED, tpd->handler.choices);
> -	set_bit(PLATFORM_PROFILE_BALANCED_PERFORMANCE, tpd->handler.choices);
> -	set_bit(PLATFORM_PROFILE_PERFORMANCE, tpd->handler.choices);
> -
>   	return platform_profile_register(&tpd->handler);
>   }
>   
> diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c
> index ac7b3ab8fd2a..1fa0cd69da8c 100644
> --- a/drivers/platform/x86/acer-wmi.c
> +++ b/drivers/platform/x86/acer-wmi.c
> @@ -1900,9 +1900,22 @@ acer_predator_v4_platform_profile_set(struct platform_profile_handler *pprof,
>   	return 0;
>   }
>   
> +static int
> +acer_predator_v4_platform_profile_choices(struct platform_profile_handler *pprof)
> +{
> +	set_bit(PLATFORM_PROFILE_PERFORMANCE, pprof->choices);
> +	set_bit(PLATFORM_PROFILE_BALANCED_PERFORMANCE, pprof->choices);
> +	set_bit(PLATFORM_PROFILE_BALANCED, pprof->choices);
> +	set_bit(PLATFORM_PROFILE_QUIET, pprof->choices);
> +	set_bit(PLATFORM_PROFILE_LOW_POWER, pprof->choices);
> +
> +	return 0;
> +}
> +
>   static const struct platform_profile_ops acer_predator_v4_platform_profile_ops = {
>   	.profile_get = acer_predator_v4_platform_profile_get,
>   	.profile_set = acer_predator_v4_platform_profile_set,
> +	.choices = acer_predator_v4_platform_profile_choices,
>   };
>   
>   static int acer_platform_profile_setup(struct platform_device *device)
> @@ -1915,17 +1928,6 @@ static int acer_platform_profile_setup(struct platform_device *device)
>   		platform_profile_handler.ops =
>   			&acer_predator_v4_platform_profile_ops;
>   
> -		set_bit(PLATFORM_PROFILE_PERFORMANCE,
> -			platform_profile_handler.choices);
> -		set_bit(PLATFORM_PROFILE_BALANCED_PERFORMANCE,
> -			platform_profile_handler.choices);
> -		set_bit(PLATFORM_PROFILE_BALANCED,
> -			platform_profile_handler.choices);
> -		set_bit(PLATFORM_PROFILE_QUIET,
> -			platform_profile_handler.choices);
> -		set_bit(PLATFORM_PROFILE_LOW_POWER,
> -			platform_profile_handler.choices);
> -
>   		err = platform_profile_register(&platform_profile_handler);
>   		if (err)
>   			return err;
> diff --git a/drivers/platform/x86/amd/pmf/sps.c b/drivers/platform/x86/amd/pmf/sps.c
> index 7c8391ac4dbb..37316bc3e071 100644
> --- a/drivers/platform/x86/amd/pmf/sps.c
> +++ b/drivers/platform/x86/amd/pmf/sps.c
> @@ -387,9 +387,19 @@ static int amd_pmf_profile_set(struct platform_profile_handler *pprof,
>   	return 0;
>   }
>   
> +static int amd_pmf_profile_choices(struct platform_profile_handler *pprof)
> +{
> +	set_bit(PLATFORM_PROFILE_LOW_POWER, pprof->choices);
> +	set_bit(PLATFORM_PROFILE_BALANCED, pprof->choices);
> +	set_bit(PLATFORM_PROFILE_PERFORMANCE, pprof->choices);
> +
> +	return 0;
> +}
> +
>   static const struct platform_profile_ops amd_pmf_profile_ops = {
>   	.profile_get = amd_pmf_profile_get,
>   	.profile_set = amd_pmf_profile_set,
> +	.choices = amd_pmf_profile_choices,
>   };
>   
>   int amd_pmf_init_sps(struct amd_pmf_dev *dev)
> @@ -414,11 +424,6 @@ int amd_pmf_init_sps(struct amd_pmf_dev *dev)
>   	dev->pprof.dev = dev->dev;
>   	dev->pprof.ops = &amd_pmf_profile_ops;
>   
> -	/* Setup supported modes */
> -	set_bit(PLATFORM_PROFILE_LOW_POWER, dev->pprof.choices);
> -	set_bit(PLATFORM_PROFILE_BALANCED, dev->pprof.choices);
> -	set_bit(PLATFORM_PROFILE_PERFORMANCE, dev->pprof.choices);
> -
>   	/* Create platform_profile structure and register */
>   	err = platform_profile_register(&dev->pprof);
>   	if (err)
> diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
> index ef4129d91656..3e94986078a6 100644
> --- a/drivers/platform/x86/asus-wmi.c
> +++ b/drivers/platform/x86/asus-wmi.c
> @@ -3852,9 +3852,19 @@ static int asus_wmi_platform_profile_set(struct platform_profile_handler *pprof,
>   	return throttle_thermal_policy_write(asus);
>   }
>   
> +static int asus_wmi_platform_profile_choices(struct platform_profile_handler *pprof)
> +{
> +	set_bit(PLATFORM_PROFILE_QUIET, pprof->choices);
> +	set_bit(PLATFORM_PROFILE_BALANCED, pprof->choices);
> +	set_bit(PLATFORM_PROFILE_PERFORMANCE, pprof->choices);
> +
> +	return 0;
> +}
> +
>   static const struct platform_profile_ops asus_wmi_platform_profile_ops = {
>   	.profile_get = asus_wmi_platform_profile_get,
>   	.profile_set = asus_wmi_platform_profile_set,
> +	.choices = asus_wmi_platform_profile_choices,
>   };
>   
>   static int platform_profile_setup(struct asus_wmi *asus)
> @@ -3885,12 +3895,6 @@ static int platform_profile_setup(struct asus_wmi *asus)
>   	asus->platform_profile_handler.dev = dev;
>   	asus->platform_profile_handler.ops = &asus_wmi_platform_profile_ops;
>   
> -	set_bit(PLATFORM_PROFILE_QUIET, asus->platform_profile_handler.choices);
> -	set_bit(PLATFORM_PROFILE_BALANCED,
> -		asus->platform_profile_handler.choices);
> -	set_bit(PLATFORM_PROFILE_PERFORMANCE,
> -		asus->platform_profile_handler.choices);
> -
>   	err = platform_profile_register(&asus->platform_profile_handler);
>   	if (err == -EEXIST) {
>   		pr_warn("%s, a platform_profile handler is already registered\n", __func__);
> diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c
> index c824414565b6..386b22e9c922 100644
> --- a/drivers/platform/x86/dell/alienware-wmi.c
> +++ b/drivers/platform/x86/dell/alienware-wmi.c
> @@ -1108,12 +1108,7 @@ static int thermal_profile_set(struct platform_profile_handler *pprof,
>   	return wmax_thermal_control(supported_thermal_profiles[profile]);
>   }
>   
> -static const struct platform_profile_ops awcc_platform_profile_ops = {
> -	.profile_get = thermal_profile_get,
> -	.profile_set = thermal_profile_set,
> -};
> -
> -static int create_thermal_profile(struct platform_device *platform_device)
> +static int thermal_profile_choices(struct platform_profile_handler *pprof)
>   {
>   	u32 out_data;
>   	u8 sys_desc[4];
> @@ -1146,19 +1141,30 @@ static int create_thermal_profile(struct platform_device *platform_device)
>   		profile = wmax_mode_to_platform_profile[mode];
>   		supported_thermal_profiles[profile] = out_data;
>   
> -		set_bit(profile, pp_handler.choices);
> +		set_bit(profile, pprof->choices);
>   	}
>   
> -	if (bitmap_empty(pp_handler.choices, PLATFORM_PROFILE_LAST))
> +	if (bitmap_empty(pprof->choices, PLATFORM_PROFILE_LAST))
>   		return -ENODEV;
>   
>   	if (quirks->gmode) {
>   		supported_thermal_profiles[PLATFORM_PROFILE_PERFORMANCE] =
>   			WMAX_THERMAL_MODE_GMODE;
>   
> -		set_bit(PLATFORM_PROFILE_PERFORMANCE, pp_handler.choices);
> +		set_bit(PLATFORM_PROFILE_PERFORMANCE, pprof->choices);
>   	}
>   
> +	return 0;
> +}
> +
> +static const struct platform_profile_ops awcc_platform_profile_ops = {
> +	.profile_get = thermal_profile_get,
> +	.profile_set = thermal_profile_set,
> +	.choices = thermal_profile_choices,
> +};
> +
> +static int create_thermal_profile(struct platform_device *platform_device)
> +{
>   	pp_handler.name = "alienware-wmi";
>   	pp_handler.dev = &platform_device->dev;
>   	pp_handler.ops = &awcc_platform_profile_ops;
> diff --git a/drivers/platform/x86/dell/dell-pc.c b/drivers/platform/x86/dell/dell-pc.c
> index 1751b7235031..ba366c28d9a6 100644
> --- a/drivers/platform/x86/dell/dell-pc.c
> +++ b/drivers/platform/x86/dell/dell-pc.c
> @@ -24,6 +24,7 @@
>   #include "dell-smbios.h"
>   
>   static struct platform_device *platform_device;
> +static int supported_modes;
>   
>   static const struct dmi_system_id dell_device_table[] __initconst = {
>   	{
> @@ -231,15 +232,29 @@ static int thermal_platform_profile_get(struct platform_profile_handler *pprof,
>   	return 0;
>   }
>   
> +static int thermal_platform_profile_choices(struct platform_profile_handler *pprof)
> +{
> +	if (supported_modes & DELL_QUIET)
> +		set_bit(PLATFORM_PROFILE_QUIET, pprof->choices);
> +	if (supported_modes & DELL_COOL_BOTTOM)
> +		set_bit(PLATFORM_PROFILE_COOL, pprof->choices);
> +	if (supported_modes & DELL_BALANCED)
> +		set_bit(PLATFORM_PROFILE_BALANCED, pprof->choices);
> +	if (supported_modes & DELL_PERFORMANCE)
> +		set_bit(PLATFORM_PROFILE_PERFORMANCE, pprof->choices);
> +
> +	return 0;
> +}
> +
>   static const struct platform_profile_ops dell_pc_platform_profile_ops = {
>   	.profile_get = thermal_platform_profile_get,
>   	.profile_set = thermal_platform_profile_set,
> +	.choices = thermal_platform_profile_choices,
>   };
>   
>   static int thermal_init(void)
>   {
>   	int ret;
> -	int supported_modes;
>   
>   	/* If thermal commands are not supported, exit without error */
>   	if (!dell_smbios_class_is_supported(CLASS_INFO))
> @@ -265,15 +280,6 @@ static int thermal_init(void)
>   	thermal_handler->dev = &platform_device->dev;
>   	thermal_handler->ops = &dell_pc_platform_profile_ops;
>   
> -	if (supported_modes & DELL_QUIET)
> -		set_bit(PLATFORM_PROFILE_QUIET, thermal_handler->choices);
> -	if (supported_modes & DELL_COOL_BOTTOM)
> -		set_bit(PLATFORM_PROFILE_COOL, thermal_handler->choices);
> -	if (supported_modes & DELL_BALANCED)
> -		set_bit(PLATFORM_PROFILE_BALANCED, thermal_handler->choices);
> -	if (supported_modes & DELL_PERFORMANCE)
> -		set_bit(PLATFORM_PROFILE_PERFORMANCE, thermal_handler->choices);
> -
>   	/* Clean up if failed */
>   	ret = platform_profile_register(thermal_handler);
>   	if (ret)
> diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-wmi.c
> index c37e44f7606c..3c2d4549eb7f 100644
> --- a/drivers/platform/x86/hp/hp-wmi.c
> +++ b/drivers/platform/x86/hp/hp-wmi.c
> @@ -1488,6 +1488,23 @@ static int platform_profile_victus_set(struct platform_profile_handler *pprof,
>   	return 0;
>   }
>   
> +static int hp_wmi_platform_profile_choices(struct platform_profile_handler *pprof)
> +{
> +	if (is_omen_thermal_profile()) {
> +		set_bit(PLATFORM_PROFILE_COOL, pprof->choices);
> +	} else if (is_victus_thermal_profile()) {
> +		set_bit(PLATFORM_PROFILE_QUIET, pprof->choices);
> +	} else {
> +		set_bit(PLATFORM_PROFILE_QUIET, pprof->choices);
> +		set_bit(PLATFORM_PROFILE_COOL, pprof->choices);
> +	}
> +
> +	set_bit(PLATFORM_PROFILE_BALANCED, pprof->choices);
> +	set_bit(PLATFORM_PROFILE_PERFORMANCE, pprof->choices);
> +
> +	return 0;
> +}
> +
>   static int omen_powersource_event(struct notifier_block *nb,
>   				  unsigned long value,
>   				  void *data)
> @@ -1568,16 +1585,19 @@ static inline void omen_unregister_powersource_event_handler(void)
>   static const struct platform_profile_ops platform_profile_omen_ops = {
>   	.profile_get = platform_profile_omen_get,
>   	.profile_set = platform_profile_omen_set,
> +	.choices = hp_wmi_platform_profile_choices,
>   };
>   
>   static const struct platform_profile_ops platform_profile_victus_ops = {
>   	.profile_get = platform_profile_victus_get,
>   	.profile_set = platform_profile_victus_set,
> +	.choices = hp_wmi_platform_profile_choices,
>   };
>   
>   static const struct platform_profile_ops hp_wmi_platform_profile_ops = {
>   	.profile_get = hp_wmi_platform_profile_get,
>   	.profile_set = hp_wmi_platform_profile_set,
> +	.choices = hp_wmi_platform_profile_choices,
>   };
>   
>   static int thermal_profile_setup(struct platform_device *device)
> @@ -1598,8 +1618,6 @@ static int thermal_profile_setup(struct platform_device *device)
>   			return err;
>   
>   		platform_profile_handler.ops = &platform_profile_omen_ops;
> -
> -		set_bit(PLATFORM_PROFILE_COOL, platform_profile_handler.choices);
>   	} else if (is_victus_thermal_profile()) {
>   		err = platform_profile_victus_get_ec(&active_platform_profile);
>   		if (err < 0)
> @@ -1614,8 +1632,6 @@ static int thermal_profile_setup(struct platform_device *device)
>   			return err;
>   
>   		platform_profile_handler.ops = &platform_profile_victus_ops;
> -
> -		set_bit(PLATFORM_PROFILE_QUIET, platform_profile_handler.choices);
>   	} else {
>   		tp = thermal_profile_get();
>   
> @@ -1631,15 +1647,10 @@ static int thermal_profile_setup(struct platform_device *device)
>   			return err;
>   
>   		platform_profile_handler.ops = &hp_wmi_platform_profile_ops;
> -
> -		set_bit(PLATFORM_PROFILE_QUIET, platform_profile_handler.choices);
> -		set_bit(PLATFORM_PROFILE_COOL, platform_profile_handler.choices);
>   	}
>   
>   	platform_profile_handler.name = "hp-wmi";
>   	platform_profile_handler.dev = &device->dev;
> -	set_bit(PLATFORM_PROFILE_BALANCED, platform_profile_handler.choices);
> -	set_bit(PLATFORM_PROFILE_PERFORMANCE, platform_profile_handler.choices);
>   
>   	err = platform_profile_register(&platform_profile_handler);
>   	if (err)
> diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c
> index b49ee94f9bee..f5ea03763a54 100644
> --- a/drivers/platform/x86/ideapad-laptop.c
> +++ b/drivers/platform/x86/ideapad-laptop.c
> @@ -1023,6 +1023,15 @@ static int dytc_profile_set(struct platform_profile_handler *pprof,
>   	return -EINTR;
>   }
>   
> +static int dytc_profile_choices(struct platform_profile_handler *pprof)
> +{
> +	set_bit(PLATFORM_PROFILE_LOW_POWER, pprof->choices);
> +	set_bit(PLATFORM_PROFILE_BALANCED, pprof->choices);
> +	set_bit(PLATFORM_PROFILE_PERFORMANCE, pprof->choices);
> +
> +	return 0;
> +}
> +
>   static void dytc_profile_refresh(struct ideapad_private *priv)
>   {
>   	enum platform_profile_option profile;
> @@ -1066,6 +1075,7 @@ static const struct dmi_system_id ideapad_dytc_v4_allow_table[] = {
>   static const struct platform_profile_ops dytc_profile_ops = {
>   	.profile_get = dytc_profile_get,
>   	.profile_set = dytc_profile_set,
> +	.choices = dytc_profile_choices,
>   };
>   
>   static int ideapad_dytc_profile_init(struct ideapad_private *priv)
> @@ -1112,11 +1122,6 @@ static int ideapad_dytc_profile_init(struct ideapad_private *priv)
>   	priv->dytc->priv = priv;
>   	priv->dytc->pprof.ops = &dytc_profile_ops;
>   
> -	/* Setup supported modes */
> -	set_bit(PLATFORM_PROFILE_LOW_POWER, priv->dytc->pprof.choices);
> -	set_bit(PLATFORM_PROFILE_BALANCED, priv->dytc->pprof.choices);
> -	set_bit(PLATFORM_PROFILE_PERFORMANCE, priv->dytc->pprof.choices);
> -
>   	/* Create platform_profile structure and register */
>   	err = platform_profile_register(&priv->dytc->pprof);
>   	if (err)
> diff --git a/drivers/platform/x86/inspur_platform_profile.c b/drivers/platform/x86/inspur_platform_profile.c
> index 38d4745f6be1..8fa9308d4686 100644
> --- a/drivers/platform/x86/inspur_platform_profile.c
> +++ b/drivers/platform/x86/inspur_platform_profile.c
> @@ -166,9 +166,19 @@ static int inspur_platform_profile_get(struct platform_profile_handler *pprof,
>   	return 0;
>   }
>   
> +static int inspur_platform_profile_choices(struct platform_profile_handler *pprof)
> +{
> +	set_bit(PLATFORM_PROFILE_LOW_POWER, pprof->choices);
> +	set_bit(PLATFORM_PROFILE_BALANCED, pprof->choices);
> +	set_bit(PLATFORM_PROFILE_PERFORMANCE, pprof->choices);
> +
> +	return 0;
> +}
> +
>   static const struct platform_profile_ops inspur_platform_profile_ops = {
>   	.profile_get = inspur_platform_profile_get,
>   	.profile_set = inspur_platform_profile_set,
> +	.choices = inspur_platform_profile_choices,
>   };
>   
>   static int inspur_wmi_probe(struct wmi_device *wdev, const void *context)
> @@ -186,10 +196,6 @@ static int inspur_wmi_probe(struct wmi_device *wdev, const void *context)
>   	priv->handler.dev = &wdev->dev;
>   	priv->handler.ops = &inspur_platform_profile_ops;
>   
> -	set_bit(PLATFORM_PROFILE_LOW_POWER, priv->handler.choices);
> -	set_bit(PLATFORM_PROFILE_BALANCED, priv->handler.choices);
> -	set_bit(PLATFORM_PROFILE_PERFORMANCE, priv->handler.choices);
> -
>   	return platform_profile_register(&priv->handler);
>   }
>   
> diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
> index 04a292af2bfc..a35453c3c605 100644
> --- a/drivers/platform/x86/thinkpad_acpi.c
> +++ b/drivers/platform/x86/thinkpad_acpi.c
> @@ -10538,9 +10538,19 @@ static int dytc_profile_set(struct platform_profile_handler *pprof,
>   	return err;
>   }
>   
> +static int dytc_profile_choices(struct platform_profile_handler *pprof)
> +{
> +	set_bit(PLATFORM_PROFILE_LOW_POWER, pprof->choices);
> +	set_bit(PLATFORM_PROFILE_BALANCED, pprof->choices);
> +	set_bit(PLATFORM_PROFILE_PERFORMANCE, pprof->choices);
> +
> +	return 0;
> +}
> +
>   static const struct platform_profile_ops dytc_profile_ops = {
>   	.profile_get = dytc_profile_get,
>   	.profile_set = dytc_profile_set,
> +	.choices = dytc_profile_choices,
>   };
>   
>   static struct platform_profile_handler dytc_profile = {
> @@ -10584,11 +10594,6 @@ static int tpacpi_dytc_profile_init(struct ibm_init_struct *iibm)
>   {
>   	int err, output;
>   
> -	/* Setup supported modes */
> -	set_bit(PLATFORM_PROFILE_LOW_POWER, dytc_profile.choices);
> -	set_bit(PLATFORM_PROFILE_BALANCED, dytc_profile.choices);
> -	set_bit(PLATFORM_PROFILE_PERFORMANCE, dytc_profile.choices);
> -
>   	err = dytc_command(DYTC_CMD_QUERY, &output);
>   	if (err)
>   		return err;
> diff --git a/include/linux/platform_profile.h b/include/linux/platform_profile.h
> index a9db95bc360d..972a62be60b2 100644
> --- a/include/linux/platform_profile.h
> +++ b/include/linux/platform_profile.h
> @@ -34,6 +34,7 @@ struct platform_profile_ops {
>   				enum platform_profile_option *profile);
>   	int (*profile_set)(struct platform_profile_handler *pprof,
>   				enum platform_profile_option profile);
> +	int (*choices)(struct platform_profile_handler *pprof);
>   };
>   
>   struct platform_profile_handler {


  reply	other threads:[~2025-01-09 16:32 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-09 15:06 [PATCH 00/18] Hide platform_profile_handler from consumers Kurt Borja
2025-01-09 15:06 ` [PATCH 01/18] ACPI: platform_profile: Add `ops` member to handlers Kurt Borja
2025-01-09 16:32   ` Mario Limonciello
2025-01-09 15:06 ` [PATCH 02/18] ACPI: platform_profile: Add `choices` to platform_profile_ops Kurt Borja
2025-01-09 16:32   ` Mario Limonciello [this message]
2025-01-09 23:02     ` Kurt Borja
2025-01-09 15:06 ` [PATCH 03/18] ACPI: platform_profile: Replace *class_dev member with class_dev Kurt Borja
2025-01-09 16:36   ` Mario Limonciello
2025-01-09 15:06 ` [PATCH 04/18] ACPI: platform_profile: Let drivers set drvdata to the class device Kurt Borja
2025-01-09 16:36   ` Mario Limonciello
2025-01-09 15:06 ` [PATCH 05/18] platform/surface: surface_platform_profile: Use devm_platform_profile_register() Kurt Borja
2025-01-09 16:36   ` Mario Limonciello
2025-01-09 15:06 ` [PATCH 06/18] platform/x86: acer-wmi: " Kurt Borja
2025-01-09 16:36   ` Mario Limonciello
2025-01-09 15:06 ` [PATCH 07/18] platform/x86: amd: pmf: sps: " Kurt Borja
2025-01-09 16:36   ` Mario Limonciello
2025-01-09 15:06 ` [PATCH 08/18] platform/x86: asus-wmi: " Kurt Borja
2025-01-09 16:36   ` Mario Limonciello
2025-01-09 15:06 ` [PATCH 09/18] platform/x86: dell-pc: " Kurt Borja
2025-01-09 16:36   ` Mario Limonciello
2025-01-09 15:06 ` [PATCH 10/18] platform/x86: ideapad-laptop: " Kurt Borja
2025-01-09 16:36   ` Mario Limonciello
2025-01-09 15:06 ` [PATCH 11/18] platform/x86: hp-wmi: " Kurt Borja
2025-01-09 16:46   ` Mario Limonciello
2025-01-09 15:06 ` [PATCH 12/18] platform/x86: inspur_platform_profile: " Kurt Borja
2025-01-09 16:46   ` Mario Limonciello
2025-01-09 15:06 ` [PATCH 13/18] platform/x86: thinkpad_acpi: " Kurt Borja
2025-01-09 16:45   ` Mario Limonciello
2025-01-09 15:06 ` [PATCH 14/18] ACPI: platform_profile: Remove platform_profile_handler from exported symbols Kurt Borja
2025-01-09 16:45   ` Mario Limonciello
2025-01-09 22:49     ` Kurt Borja
2025-01-09 15:06 ` [PATCH 15/18] ACPI: platform_profile: Remove platform_profile_handler from callbacks Kurt Borja
2025-01-09 16:42   ` Mario Limonciello
2025-01-09 22:51     ` Kurt Borja
2025-01-09 15:06 ` [PATCH 16/18] ACPI: platform_profile: Move platform_profile_handler Kurt Borja
2025-01-09 16:40   ` Mario Limonciello
2025-01-09 15:06 ` [PATCH 17/18] ACPI: platform_profile: Clean platform_profile_handler Kurt Borja
2025-01-09 16:42   ` Mario Limonciello
2025-01-09 15:06 ` [PATCH 18/18] ACPI: platform_profile: Add documentation Kurt Borja
2025-01-09 16:39   ` Mario Limonciello

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=1c921cca-1ac8-4e73-94e2-79884f596287@amd.com \
    --to=mario.limonciello@amd.com \
    --cc=Dell.Client.Kernel@dell.com \
    --cc=Shyam-sundar.S-k@amd.com \
    --cc=W_Armin@gmx.de \
    --cc=aichao@kylinos.cn \
    --cc=alexbelm48@gmail.com \
    --cc=colin.i.king@gmail.com \
    --cc=corentin.chary@gmail.com \
    --cc=derekjohn.clark@gmail.com \
    --cc=hdegoede@redhat.com \
    --cc=hmh@hmh.eng.br \
    --cc=ibm-acpi-devel@lists.sourceforge.net \
    --cc=ike.pan@canonical.com \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=jlee@suse.com \
    --cc=josh@joshuagrisham.com \
    --cc=kuurtb@gmail.com \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lsanche@lyndeno.ca \
    --cc=luke@ljones.dev \
    --cc=luzmaximilian@gmail.com \
    --cc=mpearson-lenovo@squebb.ca \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=soyer@irl.hu \
    --cc=u.kleine-koenig@baylibre.com \
    /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