[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231102055120.1192015-1-xinglong.yang@cixtech.com>
Date: Thu, 2 Nov 2023 13:51:20 +0800
From: "xinglong.yang" <seanyang230@...il.com>
To: xinglong.yang@...tech.com, rafael@...nel.org,
daniel.lezcano@...aro.org, amitk@...nel.org, rui.zhang@...el.com
Cc: linux-pm@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH] driver: thermal: simplify the traverse of sensor in thermal_zone.
The number of sensor in a thermal zone needs to be greater than zero
and equal to one. Add the opinion when the number of sensor is greater
than one in a thermal zone.
There is also no need to traverse the sensor in the thermal zone,
because there is only one sensor on one thermal zone.
Signed-off-by: xinglong.yang <xinglong.yang@...tech.com>
---
drivers/thermal/thermal_of.c | 34 +++++++++++++++++-----------------
1 file changed, 17 insertions(+), 17 deletions(-)
diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c
index e615f735f4c0..a405754c42cd 100644
--- a/drivers/thermal/thermal_of.c
+++ b/drivers/thermal/thermal_of.c
@@ -186,6 +186,7 @@ static struct device_node *of_thermal_zone_find(struct device_node *sensor, int
for_each_available_child_of_node(np, tz) {
int count, i;
+ int ret;
count = of_count_phandle_with_args(tz, "thermal-sensors",
"#thermal-sensor-cells");
@@ -193,26 +194,25 @@ static struct device_node *of_thermal_zone_find(struct device_node *sensor, int
pr_err("%pOFn: missing thermal sensor\n", tz);
tz = ERR_PTR(-EINVAL);
goto out;
+ } else if (count > 1) {
+ pr_err("%pOFn: number of thermal sensor greater than one\n", tz);
+ tz = ERR_PTR(-EINVAL);
+ goto out;
}
- for (i = 0; i < count; i++) {
-
- int ret;
-
- ret = of_parse_phandle_with_args(tz, "thermal-sensors",
- "#thermal-sensor-cells",
- i, &sensor_specs);
- if (ret < 0) {
- pr_err("%pOFn: Failed to read thermal-sensors cells: %d\n", tz, ret);
- tz = ERR_PTR(ret);
- goto out;
- }
+ ret = of_parse_phandle_with_args(tz, "thermal-sensors",
+ "#thermal-sensor-cells",
+ 0, &sensor_specs);
+ if (ret < 0) {
+ pr_err("%pOFn: Failed to read thermal-sensors cells: %d\n", tz, ret);
+ tz = ERR_PTR(ret);
+ goto out;
+ }
- if ((sensor == sensor_specs.np) && id == (sensor_specs.args_count ?
- sensor_specs.args[0] : 0)) {
- pr_debug("sensor %pOFn id=%d belongs to %pOFn\n", sensor, id, tz);
- goto out;
- }
+ if ((sensor == sensor_specs.np) && id == (sensor_specs.args_count ?
+ sensor_specs.args[0] : 0)) {
+ pr_debug("sensor %pOFn id=%d belongs to %pOFn\n", sensor, id, tz);
+ goto out;
}
}
tz = ERR_PTR(-ENODEV);
--
2.42.0
Powered by blists - more mailing lists