public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
From: Maximilian Luz <luzmaximilian@gmail.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,
	"Mario Limonciello" <mario.limonciello@amd.com>,
	"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>,
	"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>,
	"Alexis Belmonte" <alexbelm48@gmail.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 v4 02/19] ACPI: platform_profile: Let drivers set drvdata to the class device
Date: Sun, 19 Jan 2025 15:55:33 +0100	[thread overview]
Message-ID: <944696bd-89d0-4ee6-800d-71413e1dd7b1@gmail.com> (raw)
In-Reply-To: <20250116002721.75592-3-kuurtb@gmail.com>

On 1/16/25 1:27 AM, Kurt Borja wrote:
> Add *drvdata to platform_profile_register() signature and assign it to
> the class device.
> 
> While at it, pass specific driver state as drvdata to replace uses of
> container_of() with dev_get_drvdata().
> 
> Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
> Signed-off-by: Kurt Borja <kuurtb@gmail.com>

Reviewed-by: Maximilian Luz <luzmaximilian@gmail.com>

> ---
>   drivers/acpi/platform_profile.c                     | 7 ++++---
>   drivers/platform/surface/surface_platform_profile.c | 6 +++---
>   drivers/platform/x86/acer-wmi.c                     | 2 +-
>   drivers/platform/x86/amd/pmf/sps.c                  | 6 +++---
>   drivers/platform/x86/asus-wmi.c                     | 6 +++---
>   drivers/platform/x86/dell/alienware-wmi.c           | 2 +-
>   drivers/platform/x86/dell/dell-pc.c                 | 2 +-
>   drivers/platform/x86/hp/hp-wmi.c                    | 2 +-
>   drivers/platform/x86/ideapad-laptop.c               | 6 +++---
>   drivers/platform/x86/inspur_platform_profile.c      | 8 +++-----
>   drivers/platform/x86/thinkpad_acpi.c                | 2 +-
>   include/linux/platform_profile.h                    | 4 ++--
>   12 files changed, 26 insertions(+), 27 deletions(-)
> 
> diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
> index 15f24adc57d4..689541d2e66c 100644
> --- a/drivers/acpi/platform_profile.c
> +++ b/drivers/acpi/platform_profile.c
> @@ -460,7 +460,7 @@ int platform_profile_cycle(void)
>   }
>   EXPORT_SYMBOL_GPL(platform_profile_cycle);
>   
> -int platform_profile_register(struct platform_profile_handler *pprof)
> +int platform_profile_register(struct platform_profile_handler *pprof, void *drvdata)
>   {
>   	int err;
>   
> @@ -480,6 +480,7 @@ int platform_profile_register(struct platform_profile_handler *pprof)
>   
>   	pprof->class_dev.class = &platform_profile_class;
>   	pprof->class_dev.parent = pprof->dev;
> +	dev_set_drvdata(&pprof->class_dev, drvdata);
>   	dev_set_name(&pprof->class_dev, "platform-profile-%d", pprof->minor);
>   	err = device_register(&pprof->class_dev);
>   	if (err) {
> @@ -529,7 +530,7 @@ static void devm_platform_profile_release(struct device *dev, void *res)
>   	platform_profile_remove(*pprof);
>   }
>   
> -int devm_platform_profile_register(struct platform_profile_handler *pprof)
> +int devm_platform_profile_register(struct platform_profile_handler *pprof, void *drvdata)
>   {
>   	struct platform_profile_handler **dr;
>   	int ret;
> @@ -538,7 +539,7 @@ int devm_platform_profile_register(struct platform_profile_handler *pprof)
>   	if (!dr)
>   		return -ENOMEM;
>   
> -	ret = platform_profile_register(pprof);
> +	ret = platform_profile_register(pprof, drvdata);
>   	if (ret) {
>   		devres_free(dr);
>   		return ret;
> diff --git a/drivers/platform/surface/surface_platform_profile.c b/drivers/platform/surface/surface_platform_profile.c
> index 6c87e982bfc8..edb9362003a4 100644
> --- a/drivers/platform/surface/surface_platform_profile.c
> +++ b/drivers/platform/surface/surface_platform_profile.c
> @@ -161,7 +161,7 @@ static int ssam_platform_profile_get(struct platform_profile_handler *pprof,
>   	enum ssam_tmp_profile tp;
>   	int status;
>   
> -	tpd = container_of(pprof, struct ssam_platform_profile_device, handler);
> +	tpd = dev_get_drvdata(&pprof->class_dev);
>   
>   	status = ssam_tmp_profile_get(tpd->sdev, &tp);
>   	if (status)
> @@ -181,7 +181,7 @@ static int ssam_platform_profile_set(struct platform_profile_handler *pprof,
>   	struct ssam_platform_profile_device *tpd;
>   	int tp;
>   
> -	tpd = container_of(pprof, struct ssam_platform_profile_device, handler);
> +	tpd = dev_get_drvdata(&pprof->class_dev);
>   
>   	tp = convert_profile_to_ssam_tmp(tpd->sdev, profile);
>   	if (tp < 0)
> @@ -224,7 +224,7 @@ static int surface_platform_profile_probe(struct ssam_device *sdev)
>   	set_bit(PLATFORM_PROFILE_BALANCED_PERFORMANCE, tpd->handler.choices);
>   	set_bit(PLATFORM_PROFILE_PERFORMANCE, tpd->handler.choices);
>   
> -	return platform_profile_register(&tpd->handler);
> +	return platform_profile_register(&tpd->handler, tpd);
>   }
>   
>   static void surface_platform_profile_remove(struct ssam_device *sdev)
> diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c
> index acf610d59168..1aedf0ef4189 100644
> --- a/drivers/platform/x86/acer-wmi.c
> +++ b/drivers/platform/x86/acer-wmi.c
> @@ -2073,7 +2073,7 @@ static int acer_platform_profile_setup(struct platform_device *device)
>   				ACER_PREDATOR_V4_THERMAL_PROFILE_TURBO;
>   		}
>   
> -		err = platform_profile_register(&platform_profile_handler);
> +		err = platform_profile_register(&platform_profile_handler, NULL);
>   		if (err)
>   			return err;
>   
> diff --git a/drivers/platform/x86/amd/pmf/sps.c b/drivers/platform/x86/amd/pmf/sps.c
> index bd2bd6cfc39a..259a598acd3e 100644
> --- a/drivers/platform/x86/amd/pmf/sps.c
> +++ b/drivers/platform/x86/amd/pmf/sps.c
> @@ -285,7 +285,7 @@ bool is_pprof_balanced(struct amd_pmf_dev *pmf)
>   static int amd_pmf_profile_get(struct platform_profile_handler *pprof,
>   			       enum platform_profile_option *profile)
>   {
> -	struct amd_pmf_dev *pmf = container_of(pprof, struct amd_pmf_dev, pprof);
> +	struct amd_pmf_dev *pmf = dev_get_drvdata(&pprof->class_dev);
>   
>   	*profile = pmf->current_profile;
>   	return 0;
> @@ -366,7 +366,7 @@ int amd_pmf_power_slider_update_event(struct amd_pmf_dev *dev)
>   static int amd_pmf_profile_set(struct platform_profile_handler *pprof,
>   			       enum platform_profile_option profile)
>   {
> -	struct amd_pmf_dev *pmf = container_of(pprof, struct amd_pmf_dev, pprof);
> +	struct amd_pmf_dev *pmf = dev_get_drvdata(&pprof->class_dev);
>   	int ret = 0;
>   
>   	pmf->current_profile = profile;
> @@ -416,7 +416,7 @@ int amd_pmf_init_sps(struct amd_pmf_dev *dev)
>   	set_bit(PLATFORM_PROFILE_PERFORMANCE, dev->pprof.choices);
>   
>   	/* Create platform_profile structure and register */
> -	err = platform_profile_register(&dev->pprof);
> +	err = platform_profile_register(&dev->pprof, dev);
>   	if (err)
>   		dev_err(dev->dev, "Failed to register SPS support, this is most likely an SBIOS bug: %d\n",
>   			err);
> diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
> index 6c674de60ec0..f91099792cb9 100644
> --- a/drivers/platform/x86/asus-wmi.c
> +++ b/drivers/platform/x86/asus-wmi.c
> @@ -3806,7 +3806,7 @@ static int asus_wmi_platform_profile_get(struct platform_profile_handler *pprof,
>   	struct asus_wmi *asus;
>   	int tp;
>   
> -	asus = container_of(pprof, struct asus_wmi, platform_profile_handler);
> +	asus = dev_get_drvdata(&pprof->class_dev);
>   	tp = asus->throttle_thermal_policy_mode;
>   
>   	switch (tp) {
> @@ -3832,7 +3832,7 @@ static int asus_wmi_platform_profile_set(struct platform_profile_handler *pprof,
>   	struct asus_wmi *asus;
>   	int tp;
>   
> -	asus = container_of(pprof, struct asus_wmi, platform_profile_handler);
> +	asus = dev_get_drvdata(&pprof->class_dev);
>   
>   	switch (profile) {
>   	case PLATFORM_PROFILE_PERFORMANCE:
> @@ -3887,7 +3887,7 @@ static int platform_profile_setup(struct asus_wmi *asus)
>   	set_bit(PLATFORM_PROFILE_PERFORMANCE,
>   		asus->platform_profile_handler.choices);
>   
> -	err = platform_profile_register(&asus->platform_profile_handler);
> +	err = platform_profile_register(&asus->platform_profile_handler, asus);
>   	if (err == -EEXIST) {
>   		pr_warn("%s, a platform_profile handler is already registered\n", __func__);
>   		return 0;
> diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c
> index d7f577e0d146..154c417a438c 100644
> --- a/drivers/platform/x86/dell/alienware-wmi.c
> +++ b/drivers/platform/x86/dell/alienware-wmi.c
> @@ -1129,7 +1129,7 @@ static int create_thermal_profile(struct platform_device *platform_device)
>   	pp_handler.name = "alienware-wmi";
>   	pp_handler.dev = &platform_device->dev;
>   
> -	return devm_platform_profile_register(&pp_handler);
> +	return devm_platform_profile_register(&pp_handler, NULL);
>   }
>   
>   /*
> diff --git a/drivers/platform/x86/dell/dell-pc.c b/drivers/platform/x86/dell/dell-pc.c
> index 3797a5721dbd..1a0a721d706f 100644
> --- a/drivers/platform/x86/dell/dell-pc.c
> +++ b/drivers/platform/x86/dell/dell-pc.c
> @@ -271,7 +271,7 @@ static int thermal_init(void)
>   		set_bit(PLATFORM_PROFILE_PERFORMANCE, thermal_handler->choices);
>   
>   	/* Clean up if failed */
> -	ret = platform_profile_register(thermal_handler);
> +	ret = platform_profile_register(thermal_handler, NULL);
>   	if (ret)
>   		goto cleanup_thermal_handler;
>   
> diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-wmi.c
> index 6d6e13a0c6e2..8e5e1422e024 100644
> --- a/drivers/platform/x86/hp/hp-wmi.c
> +++ b/drivers/platform/x86/hp/hp-wmi.c
> @@ -1629,7 +1629,7 @@ static int thermal_profile_setup(struct platform_device *device)
>   	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);
> +	err = platform_profile_register(&platform_profile_handler, NULL);
>   	if (err)
>   		return err;
>   
> diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c
> index dc98f862a06d..ed0d880a07a9 100644
> --- a/drivers/platform/x86/ideapad-laptop.c
> +++ b/drivers/platform/x86/ideapad-laptop.c
> @@ -936,7 +936,7 @@ static int convert_profile_to_dytc(enum platform_profile_option profile, int *pe
>   static int dytc_profile_get(struct platform_profile_handler *pprof,
>   			    enum platform_profile_option *profile)
>   {
> -	struct ideapad_dytc_priv *dytc = container_of(pprof, struct ideapad_dytc_priv, pprof);
> +	struct ideapad_dytc_priv *dytc = dev_get_drvdata(&pprof->class_dev);
>   
>   	*profile = dytc->current_profile;
>   	return 0;
> @@ -989,7 +989,7 @@ static int dytc_cql_command(struct ideapad_private *priv, unsigned long cmd,
>   static int dytc_profile_set(struct platform_profile_handler *pprof,
>   			    enum platform_profile_option profile)
>   {
> -	struct ideapad_dytc_priv *dytc = container_of(pprof, struct ideapad_dytc_priv, pprof);
> +	struct ideapad_dytc_priv *dytc = dev_get_drvdata(&pprof->class_dev);
>   	struct ideapad_private *priv = dytc->priv;
>   	unsigned long output;
>   	int err;
> @@ -1114,7 +1114,7 @@ static int ideapad_dytc_profile_init(struct ideapad_private *priv)
>   	set_bit(PLATFORM_PROFILE_PERFORMANCE, priv->dytc->pprof.choices);
>   
>   	/* Create platform_profile structure and register */
> -	err = platform_profile_register(&priv->dytc->pprof);
> +	err = platform_profile_register(&priv->dytc->pprof, &priv->dytc);
>   	if (err)
>   		goto pp_reg_failed;
>   
> diff --git a/drivers/platform/x86/inspur_platform_profile.c b/drivers/platform/x86/inspur_platform_profile.c
> index 53af73a7fbf7..471fca50d1c9 100644
> --- a/drivers/platform/x86/inspur_platform_profile.c
> +++ b/drivers/platform/x86/inspur_platform_profile.c
> @@ -87,8 +87,7 @@ static int inspur_wmi_perform_query(struct wmi_device *wdev,
>   static int inspur_platform_profile_set(struct platform_profile_handler *pprof,
>   				       enum platform_profile_option profile)
>   {
> -	struct inspur_wmi_priv *priv = container_of(pprof, struct inspur_wmi_priv,
> -						    handler);
> +	struct inspur_wmi_priv *priv = dev_get_drvdata(&pprof->class_dev);
>   	u8 ret_code[4] = {0, 0, 0, 0};
>   	int ret;
>   
> @@ -135,8 +134,7 @@ static int inspur_platform_profile_set(struct platform_profile_handler *pprof,
>   static int inspur_platform_profile_get(struct platform_profile_handler *pprof,
>   				       enum platform_profile_option *profile)
>   {
> -	struct inspur_wmi_priv *priv = container_of(pprof, struct inspur_wmi_priv,
> -						    handler);
> +	struct inspur_wmi_priv *priv = dev_get_drvdata(&pprof->class_dev);
>   	u8 ret_code[4] = {0, 0, 0, 0};
>   	int ret;
>   
> @@ -186,7 +184,7 @@ static int inspur_wmi_probe(struct wmi_device *wdev, const void *context)
>   	set_bit(PLATFORM_PROFILE_BALANCED, priv->handler.choices);
>   	set_bit(PLATFORM_PROFILE_PERFORMANCE, priv->handler.choices);
>   
> -	return platform_profile_register(&priv->handler);
> +	return platform_profile_register(&priv->handler, priv);
>   }
>   
>   static void inspur_wmi_remove(struct wmi_device *wdev)
> diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
> index d99573e7a983..8be3f4e5366d 100644
> --- a/drivers/platform/x86/thinkpad_acpi.c
> +++ b/drivers/platform/x86/thinkpad_acpi.c
> @@ -10641,7 +10641,7 @@ static int tpacpi_dytc_profile_init(struct ibm_init_struct *iibm)
>   
>   	dytc_profile.dev = &tpacpi_pdev->dev;
>   	/* Create platform_profile structure and register */
> -	err = platform_profile_register(&dytc_profile);
> +	err = platform_profile_register(&dytc_profile, NULL);
>   	/*
>   	 * If for some reason platform_profiles aren't enabled
>   	 * don't quit terminally.
> diff --git a/include/linux/platform_profile.h b/include/linux/platform_profile.h
> index 8a9b8754f9ac..1c8fdda51eaa 100644
> --- a/include/linux/platform_profile.h
> +++ b/include/linux/platform_profile.h
> @@ -40,9 +40,9 @@ struct platform_profile_handler {
>   				enum platform_profile_option profile);
>   };
>   
> -int platform_profile_register(struct platform_profile_handler *pprof);
> +int platform_profile_register(struct platform_profile_handler *pprof, void *drvdata);
>   int platform_profile_remove(struct platform_profile_handler *pprof);
> -int devm_platform_profile_register(struct platform_profile_handler *pprof);
> +int devm_platform_profile_register(struct platform_profile_handler *pprof, void *drvdata);
>   int platform_profile_cycle(void);
>   void platform_profile_notify(struct platform_profile_handler *pprof);
>   


  reply	other threads:[~2025-01-19 14:55 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-16  0:27 [PATCH v4 00/19] Hide platform_profile_handler from consumers Kurt Borja
2025-01-16  0:27 ` [PATCH v4 01/19] ACPI: platform_profile: Replace *class_dev member with class_dev Kurt Borja
2025-01-16  0:27 ` [PATCH v4 02/19] ACPI: platform_profile: Let drivers set drvdata to the class device Kurt Borja
2025-01-19 14:55   ` Maximilian Luz [this message]
2025-01-16  0:27 ` [PATCH v4 03/19] ACPI: platform_profile: Remove platform_profile_handler from callbacks Kurt Borja
2025-01-19 14:57   ` Maximilian Luz
2025-01-16  0:27 ` [PATCH v4 04/19] ACPI: platform_profile: Add `ops` member to handlers Kurt Borja
2025-01-19 14:58   ` Maximilian Luz
2025-01-16  0:27 ` [PATCH v4 05/19] ACPI: platform_profile: Add `probe` to platform_profile_ops Kurt Borja
2025-01-19 15:00   ` Maximilian Luz
2025-01-16  0:27 ` [PATCH v4 06/19] platform/surface: surface_platform_profile: Use devm_platform_profile_register() Kurt Borja
2025-01-19 15:01   ` Maximilian Luz
2025-01-16  0:27 ` [PATCH v4 07/19] platform/x86: acer-wmi: " Kurt Borja
2025-01-16  0:27 ` [PATCH v4 08/19] platform/x86: amd: pmf: sps: " Kurt Borja
2025-01-16  0:27 ` [PATCH v4 09/19] platform/x86: asus-wmi: " Kurt Borja
2025-01-16  0:27 ` [PATCH v4 10/19] platform/x86: dell-pc: " Kurt Borja
2025-01-16  0:27 ` [PATCH v4 11/19] platform/x86: ideapad-laptop: " Kurt Borja
2025-01-16  0:27 ` [PATCH v4 12/19] platform/x86: hp-wmi: " Kurt Borja
2025-01-16  0:27 ` [PATCH v4 13/19] platform/x86: inspur_platform_profile: " Kurt Borja
2025-01-16  0:27 ` [PATCH v4 14/19] platform/x86: thinkpad_acpi: " Kurt Borja
2025-01-16  0:27 ` [PATCH v4 15/19] ACPI: platform_profile: Remove platform_profile_handler from exported symbols Kurt Borja
2025-01-19 15:04   ` Maximilian Luz
2025-01-16  0:27 ` [PATCH v4 16/19] ACPI: platform_profile: Move platform_profile_handler Kurt Borja
2025-01-16  0:27 ` [PATCH v4 17/19] ACPI: platform_profile: Clean platform_profile_handler Kurt Borja
2025-01-16  0:27 ` [PATCH v4 18/19] ACPI: platform_profile: Add documentation Kurt Borja
2025-01-16  0:27 ` [PATCH v4 19/19] ACPI: platform_profile: Add a prefix to log messages Kurt Borja
2025-01-16 16:09 ` [PATCH v4 00/19] Hide platform_profile_handler from consumers Ilpo Järvinen
2025-01-17  4:16   ` Kurt Borja
2025-01-16 22:20 ` Mark Pearson
2025-01-17  4:27   ` Kurt Borja
2025-01-17 16:42   ` Ilpo Järvinen
2025-01-17 17:13     ` Kurt Borja
2025-01-17 17:19       ` Ilpo Järvinen
2025-01-17 20:45         ` Mark Pearson
2025-01-18  1:33           ` Mark Pearson
2025-01-18  7:16             ` Kurt Borja
2025-01-20 12:28             ` Ilpo Järvinen

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=944696bd-89d0-4ee6-800d-71413e1dd7b1@gmail.com \
    --to=luzmaximilian@gmail.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=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=mario.limonciello@amd.com \
    --cc=mpearson-lenovo@squebb.ca \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=soyer@irl.hu \
    /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