Linux Power Management development
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rafael@kernel.org>
To: 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>, Armin Wolf <w_armin@gmx.de>
Subject: [PATCH v1 08/10] ACPI: processor: thermal: Use more suitable cooling device data
Date: Fri, 11 Sep 2026 15:05:50 +0200	[thread overview]
Message-ID: <6192780.MhkbZ0Pkbq@rafael.j.wysocki> (raw)
In-Reply-To: <1965933.tdWV9SEqCh@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_processor_thermal_init()
pass a pointer to the struct acpi_processor representing the given CPU
to it, which allows the callback functions in processor_cooling_ops to
be simplified and the second argument of acpi_processor_thermal_init()
and acpi_processor_thermal_exit() to be dropped.

No intentional functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/acpi/processor_driver.c  |  2 +-
 drivers/acpi/processor_thermal.c | 35 +++++---------------------------
 include/acpi/processor.h         |  3 +--
 3 files changed, 7 insertions(+), 33 deletions(-)

diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c
index 90c14480393d..bdd1529d79f0 100644
--- a/drivers/acpi/processor_driver.c
+++ b/drivers/acpi/processor_driver.c
@@ -164,7 +164,7 @@ static int __acpi_processor_start(struct acpi_device *device)
 
 	acpi_pss_perf_init(pr);
 
-	result = acpi_processor_thermal_init(pr, device);
+	result = acpi_processor_thermal_init(pr);
 	if (result)
 		goto err_power_exit;
 
diff --git a/drivers/acpi/processor_thermal.c b/drivers/acpi/processor_thermal.c
index 6cd47551844a..11036f0d2b94 100644
--- a/drivers/acpi/processor_thermal.c
+++ b/drivers/acpi/processor_thermal.c
@@ -235,15 +235,7 @@ static int
 processor_get_max_state(struct thermal_cooling_device *cdev,
 			unsigned long *state)
 {
-	struct acpi_device *device = cdev->devdata;
-	struct acpi_processor *pr;
-
-	if (!device)
-		return -EINVAL;
-
-	pr = acpi_driver_data(device);
-	if (!pr)
-		return -EINVAL;
+	struct acpi_processor *pr = cdev->devdata;
 
 	*state = acpi_processor_max_state(pr);
 	return 0;
@@ -253,15 +245,7 @@ static int
 processor_get_cur_state(struct thermal_cooling_device *cdev,
 			unsigned long *cur_state)
 {
-	struct acpi_device *device = cdev->devdata;
-	struct acpi_processor *pr;
-
-	if (!device)
-		return -EINVAL;
-
-	pr = acpi_driver_data(device);
-	if (!pr)
-		return -EINVAL;
+	struct acpi_processor *pr = cdev->devdata;
 
 	*cur_state = cpufreq_get_cur_state(pr->id);
 	if (pr->flags.throttling)
@@ -273,18 +257,10 @@ static int
 processor_set_cur_state(struct thermal_cooling_device *cdev,
 			unsigned long state)
 {
-	struct acpi_device *device = cdev->devdata;
-	struct acpi_processor *pr;
+	struct acpi_processor *pr = cdev->devdata;
 	int result = 0;
 	int max_pstate;
 
-	if (!device)
-		return -EINVAL;
-
-	pr = acpi_driver_data(device);
-	if (!pr)
-		return -EINVAL;
-
 	max_pstate = cpufreq_get_max_state(pr->id);
 
 	if (state > acpi_processor_max_state(pr))
@@ -308,10 +284,9 @@ const struct thermal_cooling_device_ops processor_cooling_ops = {
 	.set_cur_state = processor_set_cur_state,
 };
 
-int acpi_processor_thermal_init(struct acpi_processor *pr,
-				struct acpi_device *device)
+int acpi_processor_thermal_init(struct acpi_processor *pr)
 {
-	pr->cdev = thermal_cooling_device_create(pr->dev, "Processor", device,
+	pr->cdev = thermal_cooling_device_create(pr->dev, "Processor", pr,
 						 &processor_cooling_ops);
 	if (IS_ERR(pr->cdev))
 		return PTR_ERR(pr->cdev);
diff --git a/include/acpi/processor.h b/include/acpi/processor.h
index 656aaf74fb18..b5447af4d40b 100644
--- a/include/acpi/processor.h
+++ b/include/acpi/processor.h
@@ -427,8 +427,7 @@ int acpi_processor_ffh_lpi_enter(struct acpi_lpi_state *lpi);
 #endif /* CONFIG_ACPI_PROCESSOR_IDLE */
 
 /* in processor_thermal.c */
-int acpi_processor_thermal_init(struct acpi_processor *pr,
-				struct acpi_device *device);
+int acpi_processor_thermal_init(struct acpi_processor *pr);
 void acpi_processor_thermal_exit(struct acpi_processor *pr);
 extern const struct thermal_cooling_device_ops processor_cooling_ops;
 #ifdef CONFIG_CPU_FREQ
-- 
2.51.0





  parent reply	other threads:[~2026-09-11 13:08 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 ` Rafael J. Wysocki [this message]
2026-09-11 21:22   ` [PATCH v1 08/10] ACPI: processor: thermal: Use more suitable cooling device data 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
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=6192780.MhkbZ0Pkbq@rafael.j.wysocki \
    --to=rafael@kernel.org \
    --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=w_armin@gmx.de \
    /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