From: Daniel Lezcano <daniel.lezcano@oss.qualcomm.com>
To: daniel.lezcano@oss.qualcomm.com, rafael@kernel.org
Cc: Zhang Rui <rui.zhang@intel.com>,
Lukasz Luba <lukasz.luba@arm.com>, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Anvesh Jain P <anvesh.p@oss.qualcomm.com>,
Ulf Hansson <ulf.hansson@oss.qualcomm.com>,
linux-pm@vger.kernel.org,
Daniel Lezcano <daniel.lezcano@kernel.org>,
linux-kernel@vger.kernel.org (open list)
Subject: [PATCH v1 05/12] thermal: core: Dispatch aggregate temperature reads
Date: Thu, 19 Nov 2026 10:46:47 +0100 [thread overview]
Message-ID: <20261119094706.3439040-6-daniel.lezcano@oss.qualcomm.com> (raw)
In-Reply-To: <20261119094706.3439040-1-daniel.lezcano@oss.qualcomm.com>
Select a private aggregate temperature helper in __thermal_zone_get_temp()
when the zone parameters contain an aggregation description. Retain the
existing driver callback for non-aggregated zones and the common emulation
and error handling for both paths.
Add the aggregate temperature helper in thermal_aggregation.c and declare
it in the private thermal core header. Keep temperature dispatch in
thermal_helpers.c.
Leave the aggregate helper as a placeholder returning -EOPNOTSUPP until
the calculation is implemented, avoiding a successful return with an
uninitialized temperature.
Provide a private stub returning -EOPNOTSUPP when thermal aggregation
is disabled, preserving the ordinary thermal zone path.
Signed-off-by: Daniel Lezcano <daniel.lezcano@oss.qualcomm.com>
---
drivers/thermal/thermal_aggregation.c | 5 +++++
drivers/thermal/thermal_core.h | 8 ++++++++
drivers/thermal/thermal_helpers.c | 7 +++++--
3 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/drivers/thermal/thermal_aggregation.c b/drivers/thermal/thermal_aggregation.c
index 8b503fab25bc..fa6cfb8669b3 100644
--- a/drivers/thermal/thermal_aggregation.c
+++ b/drivers/thermal/thermal_aggregation.c
@@ -154,3 +154,8 @@ thermal_zone_aggregate_validate(struct thermal_zone_aggregate *aggregate,
return 0;
}
+
+int thermal_zone_get_temp_aggregate(struct thermal_zone_device *tz, int *temp)
+{
+ return -EOPNOTSUPP;
+}
diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h
index 365704584966..34903cfeec33 100644
--- a/drivers/thermal/thermal_core.h
+++ b/drivers/thermal/thermal_core.h
@@ -313,6 +313,14 @@ void thermal_zone_set_trips(struct thermal_zone_device *tz, int low, int high);
int thermal_zone_trip_id(const struct thermal_zone_device *tz,
const struct thermal_trip *trip);
int __thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp);
+#ifdef CONFIG_THERMAL_AGGREGATION
+int thermal_zone_get_temp_aggregate(struct thermal_zone_device *tz, int *temp);
+#else
+static inline int thermal_zone_get_temp_aggregate(struct thermal_zone_device *tz, int *temp)
+{
+ return -EOPNOTSUPP;
+}
+#endif
void thermal_zone_set_trip_hyst(struct thermal_zone_device *tz,
struct thermal_trip *trip, int hyst);
diff --git a/drivers/thermal/thermal_helpers.c b/drivers/thermal/thermal_helpers.c
index b1152ad7acc9..cf84d4c1ef65 100644
--- a/drivers/thermal/thermal_helpers.c
+++ b/drivers/thermal/thermal_helpers.c
@@ -74,7 +74,7 @@ EXPORT_SYMBOL_GPL(thermal_trip_is_bound_to_cdev);
* temperature and fill @temp.
*
* Both tz and tz->ops must be valid pointers when calling this function,
- * and the tz->ops.get_temp callback must be provided.
+ * and the tz->ops.get_temp callback must be provided for non-aggregated zones.
* The function must be called under tz->lock.
*
* Return: On success returns 0, an error code otherwise
@@ -87,7 +87,10 @@ int __thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp)
lockdep_assert_held(&tz->lock);
- ret = tz->ops.get_temp(tz, temp);
+ if (tz->tzp && tz->tzp->aggregate)
+ ret = thermal_zone_get_temp_aggregate(tz, temp);
+ else
+ ret = tz->ops.get_temp(tz, temp);
if (IS_ENABLED(CONFIG_THERMAL_EMULATION) && tz->emul_temperature) {
for_each_trip_desc(tz, td) {
--
2.43.0
next prev parent reply other threads:[~2026-11-19 9:47 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20261119094706.3439040-1-daniel.lezcano@oss.qualcomm.com>
2026-11-19 9:46 ` [PATCH v1 01/12] thermal: core: Add thermal zone device reference helpers Daniel Lezcano
2026-11-19 9:46 ` [PATCH v1 02/12] thermal: core: Introduce private thermal zone aggregation structures Daniel Lezcano
2026-11-19 9:46 ` [PATCH v1 03/12] thermal: core: Validate thermal zone aggregation descriptions Daniel Lezcano
2026-11-19 9:46 ` [PATCH v1 04/12] thermal: core: Initialize thermal zone aggregation coefficients Daniel Lezcano
2026-11-19 9:46 ` Daniel Lezcano [this message]
2026-11-19 9:46 ` [PATCH v1 06/12] thermal: core: Calculate aggregated thermal zone temperatures Daniel Lezcano
2026-11-19 9:46 ` [PATCH v1 07/12] thermal: core: Initialize aggregation during zone registration Daniel Lezcano
2026-11-19 9:46 ` [PATCH v1 08/12] thermal: of: Separate zone parsing from sensor lookup Daniel Lezcano
2026-11-19 9:46 ` [PATCH v1 09/12] thermal: of: Track registered hardware temperature sources Daniel Lezcano
2026-11-19 9:46 ` [PATCH v1 10/12] thermal: of: Instantiate aggregates after their source zones Daniel Lezcano
2026-11-19 9:46 ` [PATCH v1 11/12] dt-bindings: thermal: Describe multi-source zone aggregation Daniel Lezcano
2026-11-19 9:46 ` [PATCH v1 12/12] thermal: testing: Add KUnit coverage for " Daniel Lezcano
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=20261119094706.3439040-6-daniel.lezcano@oss.qualcomm.com \
--to=daniel.lezcano@oss.qualcomm.com \
--cc=anvesh.p@oss.qualcomm.com \
--cc=daniel.lezcano@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=lukasz.luba@arm.com \
--cc=rafael@kernel.org \
--cc=robh@kernel.org \
--cc=rui.zhang@intel.com \
--cc=ulf.hansson@oss.qualcomm.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
all inboxes | Powered by JetHome®