Re: [PATCH 1/4] thermal/of: Add thermal_zone_get_zone_by_node() API

From: Daniel Lezcano

Date: Tue Dec 01 2026 - 11:19:12 EST




Le 25/11/2026 à 11:17, Manivannan Sadhasivam via B4 Relay a écrit :
From: Manivannan Sadhasivam <manivannan.sadhasivam@xxxxxxxxxxxxxxxx>

Add an API to allow the drivers to get a registered thermal zone from OF
node.

Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@xxxxxxxxxxxxxxxx>
---
drivers/thermal/thermal_of.c | 21 +++++++++++++++++++++
include/linux/thermal.h | 8 ++++++++
2 files changed, 29 insertions(+)

diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c
index 9e96fb1b033e..e38f67c19c8e 100644
--- a/drivers/thermal/thermal_of.c
+++ b/drivers/thermal/thermal_of.c
@@ -530,6 +530,27 @@ void devm_thermal_of_zone_unregister(struct device *dev, struct thermal_zone_dev
}
EXPORT_SYMBOL_GPL(devm_thermal_of_zone_unregister);
+/**
+ * thermal_zone_get_zone_by_node() - get a registered zone from its OF node
+ * @np: device tree node of the thermal zone
+ *
+ * Thermal zones described in the device tree are registered using the name
+ * of their device tree node, so resolve @np to its registered thermal zone
+ * by that name.
+ *
+ * Return: a valid thermal zone on success, an ERR_PTR otherwise (-EINVAL for
+ * an invalid argument, -ENODEV if no zone matches @np and -EEXIST if the name
+ * is not unique).
+ */
+struct thermal_zone_device *thermal_zone_get_zone_by_node(struct device_node *np)
+{
+ if (!np)
+ return ERR_PTR(-EINVAL);
+
+ return thermal_zone_get_zone_by_name(np->name);
+}
+EXPORT_SYMBOL_GPL(thermal_zone_get_zone_by_node);

I don't think it is worth to add a new function for that as you can directly call thermal_zone_get_zone_by_name()