Linux ACPI
 help / color / mirror / Atom feed
From: Armin Wolf <W_Armin@gmx.de>
To: "Rafael J. Wysocki" <rafael@kernel.org>,
	Linux ACPI <linux-acpi@vger.kernel.org>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Daniel Lezcano <daniel.lezcano@kernel.org>,
	Hans de Goede <hansg@kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Linux PM <linux-pm@vger.kernel.org>,
	Lukasz Luba <lukasz.luba@arm.com>
Subject: Re: [PATCH v1 10/10] ACPI: fan: Use more suitable cooling device data
Date: Fri, 11 Sep 2026 23:26:08 +0200	[thread overview]
Message-ID: <10085066-c512-405f-a675-bcf1e166a29a@gmx.de> (raw)
In-Reply-To: <3631084.QJadu78ljV@rafael.j.wysocki>

Am 11.09.26 um 15:07 schrieb Rafael J. Wysocki:

> From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
>
> Instead of passing an ACPI device object pointer as devdata to
> thermal_cooling_device_create(), make acpi_fan_probe() pass a pointer
> to struct acpi_fan to it, which allows the callback functions in
> fan_cooling_ops to be simplified.
>
> Also avoid using acpi_driver_data() in two functions invoked by the
> cooling device callbacks by passing struct acpi_fan pointers instead
> of struct acpi_device pointers to them.
>
> No intentional functional impact.

Reviewed-by: Armin Wolf <W_Armin@gmx.de>

> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---
>   drivers/acpi/fan_core.c | 27 ++++++++++++---------------
>   1 file changed, 12 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/acpi/fan_core.c b/drivers/acpi/fan_core.c
> index 8b20b8a55c13..5ad65975fbb4 100644
> --- a/drivers/acpi/fan_core.c
> +++ b/drivers/acpi/fan_core.c
> @@ -54,8 +54,7 @@ MODULE_DEVICE_TABLE(acpi, fan_device_ids);
>   static int fan_get_max_state(struct thermal_cooling_device *cdev, unsigned long
>   			     *state)
>   {
> -	struct acpi_device *device = cdev->devdata;
> -	struct acpi_fan *fan = acpi_driver_data(device);
> +	struct acpi_fan *fan = cdev->devdata;
>   
>   	if (fan->acpi4) {
>   		if (fan->fif.fine_grain_ctrl)
> @@ -105,9 +104,9 @@ int acpi_fan_get_fst(acpi_handle handle, struct acpi_fan_fst *fst)
>   	return ret;
>   }
>   
> -static int fan_get_state_acpi4(struct acpi_device *device, unsigned long *state)
> +static int fan_get_state_acpi4(struct acpi_fan *fan, unsigned long *state)
>   {
> -	struct acpi_fan *fan = acpi_driver_data(device);
> +	struct acpi_device *device = fan->adev;
>   	struct acpi_fan_fst fst;
>   	int status, i;
>   
> @@ -159,13 +158,12 @@ static int fan_get_state(struct acpi_device *device, unsigned long *state)
>   static int fan_get_cur_state(struct thermal_cooling_device *cdev, unsigned long
>   			     *state)
>   {
> -	struct acpi_device *device = cdev->devdata;
> -	struct acpi_fan *fan = acpi_driver_data(device);
> +	struct acpi_fan *fan = cdev->devdata;
>   
>   	if (fan->acpi4)
> -		return fan_get_state_acpi4(device, state);
> +		return fan_get_state_acpi4(fan, state);
>   	else
> -		return fan_get_state(device, state);
> +		return fan_get_state(fan->adev, state);
>   }
>   
>   static int fan_set_state(struct acpi_device *device, unsigned long state)
> @@ -177,9 +175,9 @@ static int fan_set_state(struct acpi_device *device, unsigned long state)
>   				     state ? ACPI_STATE_D0 : ACPI_STATE_D3_COLD);
>   }
>   
> -static int fan_set_state_acpi4(struct acpi_device *device, unsigned long state)
> +static int fan_set_state_acpi4(struct acpi_fan *fan, unsigned long state)
>   {
> -	struct acpi_fan *fan = acpi_driver_data(device);
> +	struct acpi_device *device = fan->adev;
>   	acpi_status status;
>   	u64 value = state;
>   	int max_state;
> @@ -213,13 +211,12 @@ static int fan_set_state_acpi4(struct acpi_device *device, unsigned long state)
>   static int
>   fan_set_cur_state(struct thermal_cooling_device *cdev, unsigned long state)
>   {
> -	struct acpi_device *device = cdev->devdata;
> -	struct acpi_fan *fan = acpi_driver_data(device);
> +	struct acpi_fan *fan = cdev->devdata;
>   
>   	if (fan->acpi4)
> -		return fan_set_state_acpi4(device, state);
> +		return fan_set_state_acpi4(fan, state);
>   	else
> -		return fan_set_state(device, state);
> +		return fan_set_state(fan->adev, state);
>   }
>   
>   static const struct thermal_cooling_device_ops fan_cooling_ops = {
> @@ -565,7 +562,7 @@ static int acpi_fan_probe(struct platform_device *pdev)
>   	else
>   		name = acpi_device_bid(device);
>   
> -	cdev = thermal_cooling_device_create(&pdev->dev, name, device, &fan_cooling_ops);
> +	cdev = thermal_cooling_device_create(&pdev->dev, name, fan, &fan_cooling_ops);
>   	if (IS_ERR(cdev)) {
>   		result = PTR_ERR(cdev);
>   		goto err_end;

  reply	other threads:[~2026-09-11 21:26 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-11 13:00 [PATCH v1 00/10] ACPI: thermal: Register thermal class cooling devices under parents Rafael J. Wysocki
2026-09-11 13:00 ` [PATCH v1 01/10] ACPI: fan: Fix memory leak due to leftover devm_kcalloc() argument Rafael J. Wysocki
2026-09-11 16:29   ` Andy Shevchenko
2026-09-12 13:48     ` Rafael J. Wysocki (Intel)
2026-09-11 21:01   ` Armin Wolf
2026-09-11 13:01 ` [PATCH v1 02/10] ACPI: video: Fix backlight unregistration ordering Rafael J. Wysocki
2026-09-11 16:27   ` Andy Shevchenko
2026-09-11 16:35     ` Rafael J. Wysocki (Intel)
2026-09-11 21:02   ` Armin Wolf
2026-09-11 13:02 ` [PATCH v1 03/10] thermal: core: Introduce thermal_cooling_device_create() Rafael J. Wysocki
2026-09-11 21:04   ` Armin Wolf
2026-09-11 13:02 ` [PATCH v1 04/10] ACPI: processor: thermal: Use thermal_cooling_device_create() Rafael J. Wysocki
2026-09-11 16:32   ` Andy Shevchenko
2026-09-11 16:36     ` Rafael J. Wysocki (Intel)
2026-09-11 16:46       ` Andy Shevchenko
2026-09-11 17:01         ` Rafael J. Wysocki (Intel)
2026-09-11 18:06           ` Andy Shevchenko
2026-09-11 21:14             ` Armin Wolf
2026-09-13  8:15               ` Andy Shevchenko
2026-09-13 10:28                 ` Rafael J. Wysocki (Intel)
2026-09-11 21:11   ` Armin Wolf
2026-09-11 13:03 ` [PATCH v1 05/10] ACPI: video: " Rafael J. Wysocki
2026-09-11 21:16   ` Armin Wolf
2026-09-11 13:04 ` [PATCH v1 06/10] ACPI: fan: " Rafael J. Wysocki
2026-09-11 21:17   ` Armin Wolf
2026-09-11 13:05 ` [PATCH v1 07/10] ACPI: thermal: Use cooling device parent for thermal zone binding Rafael J. Wysocki
2026-09-11 16:36   ` Andy Shevchenko
2026-09-11 16:41     ` Rafael J. Wysocki (Intel)
2026-09-11 21:20   ` Armin Wolf
2026-09-11 13:05 ` [PATCH v1 08/10] ACPI: processor: thermal: Use more suitable cooling device data Rafael J. Wysocki
2026-09-11 21:22   ` Armin Wolf
2026-09-11 13:06 ` [PATCH v1 09/10] ACPI: fan: Store ACPI device pointer in struct acpi_fan Rafael J. Wysocki
2026-09-11 21:25   ` Armin Wolf
2026-09-11 13:07 ` [PATCH v1 10/10] ACPI: fan: Use more suitable cooling device data Rafael J. Wysocki
2026-09-11 21:26   ` Armin Wolf [this message]
2026-09-11 21:35 ` [PATCH v1 00/10] ACPI: thermal: Register thermal class cooling devices under parents Armin Wolf
2026-09-12 13:34   ` Rafael J. Wysocki (Intel)

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=10085066-c512-405f-a675-bcf1e166a29a@gmx.de \
    --to=w_armin@gmx.de \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=daniel.lezcano@kernel.org \
    --cc=hansg@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=lukasz.luba@arm.com \
    --cc=rafael@kernel.org \
    /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