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 08/12] thermal: of: Separate zone parsing from sensor lookup
Date: Thu, 19 Nov 2026 10:46:50 +0100 [thread overview]
Message-ID: <20261119094706.3439040-9-daniel.lezcano@oss.qualcomm.com> (raw)
In-Reply-To: <20261119094706.3439040-1-daniel.lezcano@oss.qualcomm.com>
Extract node-based thermal zone registration so subsequent aggregation
support can reuse trip, monitoring, cooling-map and critical-action
handling. Pass initialized zone parameters into the shared helper and
keep legacy slope and offset parsing in the hardware sensor path.
Keep device node ownership in the lookup wrapper and preserve existing
source registration and enablement behavior.
Signed-off-by: Daniel Lezcano <daniel.lezcano@oss.qualcomm.com>
---
drivers/thermal/thermal_of.c | 70 +++++++++++++++---------------------
1 file changed, 29 insertions(+), 41 deletions(-)
diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c
index 9e96fb1b033e..710ff25140e7 100644
--- a/drivers/thermal/thermal_of.c
+++ b/drivers/thermal/thermal_of.c
@@ -363,55 +363,27 @@ static void thermal_of_zone_unregister(struct thermal_zone_device *tz)
thermal_zone_device_unregister(tz);
}
-/**
- * thermal_of_zone_register - Register a thermal zone with device node
- * sensor
- *
- * The thermal_of_zone_register() parses a device tree given a device
- * node sensor and identifier. It searches for the thermal zone
- * associated to the couple sensor/id and retrieves all the thermal
- * zone properties and registers new thermal zone with those
- * properties.
- *
- * @sensor: A device node pointer corresponding to the sensor in the device tree
- * @id: An integer as sensor identifier
- * @data: A private data to be stored in the thermal zone dedicated private area
- * @ops: A set of thermal sensor ops
- *
- * Return: a valid thermal zone structure pointer on success.
- * - EINVAL: if the device tree thermal description is malformed
- * - ENOMEM: if one structure can not be allocated
- * - Other negative errors are returned by the underlying called functions
- */
-static struct thermal_zone_device *thermal_of_zone_register(struct device_node *sensor, int id, void *data,
- const struct thermal_zone_device_ops *ops)
+static struct thermal_zone_device *
+thermal_of_zone_register_node(struct device_node *np, void *data,
+ const struct thermal_zone_device_ops *ops,
+ const struct thermal_zone_params *params)
{
struct thermal_zone_device_ops of_ops = *ops;
struct thermal_zone_device *tz;
struct thermal_trip *trips;
- struct thermal_zone_params tzp = {};
- struct device_node *np;
const char *action;
int delay, pdelay;
int ntrips;
int ret;
- np = of_thermal_zone_find(sensor, id);
- if (IS_ERR(np)) {
- if (PTR_ERR(np) != -ENODEV)
- pr_err("Failed to find thermal zone for %pOFP id=%d\n", sensor, id);
- return ERR_CAST(np);
- }
-
trips = thermal_of_trips_init(np, &ntrips);
if (IS_ERR(trips)) {
- pr_err("Failed to parse trip points for %pOFP id=%d\n", sensor, id);
- ret = PTR_ERR(trips);
- goto out_of_node_put;
+ pr_err("Failed to parse trip points for %pOFP\n", np);
+ return ERR_CAST(trips);
}
if (!trips)
- pr_info("No trip points found for %pOFP id=%d\n", sensor, id);
+ pr_info("No trip points found for %pOFP\n", np);
ret = thermal_of_monitor_init(np, &delay, &pdelay);
if (ret) {
@@ -419,8 +391,6 @@ static struct thermal_zone_device *thermal_of_zone_register(struct device_node *
goto out_kfree_trips;
}
- thermal_of_parameters_init(np, &tzp);
-
of_ops.should_bind = thermal_of_should_bind;
ret = of_property_read_string(np, "critical-action", &action);
@@ -432,7 +402,7 @@ static struct thermal_zone_device *thermal_of_zone_register(struct device_node *
}
tz = thermal_zone_device_register_with_trips(np->name, trips, ntrips,
- data, &of_ops, &tzp,
+ data, &of_ops, params,
pdelay, delay);
if (IS_ERR(tz)) {
ret = PTR_ERR(tz);
@@ -440,7 +410,6 @@ static struct thermal_zone_device *thermal_of_zone_register(struct device_node *
goto out_kfree_trips;
}
- of_node_put(np);
kfree(trips);
ret = thermal_zone_device_enable(tz);
@@ -455,10 +424,29 @@ static struct thermal_zone_device *thermal_of_zone_register(struct device_node *
out_kfree_trips:
kfree(trips);
-out_of_node_put:
+ return ERR_PTR(ret);
+}
+
+static struct thermal_zone_device *
+thermal_of_zone_register(struct device_node *sensor, int id, void *data,
+ const struct thermal_zone_device_ops *ops)
+{
+ struct thermal_zone_params tzp = {};
+ struct thermal_zone_device *tz;
+ struct device_node *np;
+
+ np = of_thermal_zone_find(sensor, id);
+ if (IS_ERR(np)) {
+ if (PTR_ERR(np) != -ENODEV)
+ pr_err("Failed to find thermal zone for %pOFP id=%d\n", sensor, id);
+ return ERR_CAST(np);
+ }
+
+ thermal_of_parameters_init(np, &tzp);
+ tz = thermal_of_zone_register_node(np, data, ops, &tzp);
of_node_put(np);
- return ERR_PTR(ret);
+ return tz;
}
static void devm_thermal_of_zone_release(struct device *dev, void *res)
--
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 ` [PATCH v1 05/12] thermal: core: Dispatch aggregate temperature reads Daniel Lezcano
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 ` Daniel Lezcano [this message]
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-9-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®