lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20231102093334.1363324-1-xinglong.yang@cixtech.com>
Date:   Thu,  2 Nov 2023 17:33:34 +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 v2] 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 | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c
index e615f735f4c0..c800599e7ebd 100644
--- a/drivers/thermal/thermal_of.c
+++ b/drivers/thermal/thermal_of.c
@@ -185,7 +185,8 @@ 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 count;
+		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

Powered by Openwall GNU/*/Linux Powered by OpenVZ