Skip to contentSkip to conversation

drivers/thermal: optimize the for circle to run a bit fast

PATCH Superseded Bernard Zhao 1 participant 1 message Oct 19, 2020 Thermal

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers/thermal: optimize the for circle to run a bit fast

Function thermal_zone_device_register, in the for circle, if the first if branch set the count bit in tz->trips_disabled, there is no need to set in the other if branch again.
This change is to make the code run a bit fast and readable.

---
 drivers/thermal/thermal_core.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/thermal/thermal_core.c +6 -2
index c6d74bc1c90b..03577794eea3 100644
@@ -1446,10 +1446,14 @@ thermal_zone_device_register(const char *type, int trips, int mask,
 		goto release_device;
 
 	for (count = 0; count < trips; count++) {
-		if (tz->ops->get_trip_type(tz, count, &trip_type))
+		if (tz->ops->get_trip_type(tz, count, &trip_type)) {
 			set_bit(count, &tz->trips_disabled);
-		if (tz->ops->get_trip_temp(tz, count, &trip_temp))
+			continue;
+		}
+		if (tz->ops->get_trip_temp(tz, count, &trip_temp)) {
 			set_bit(count, &tz->trips_disabled);
+			continue;
+		}
 		/* Check for bogus trip points */
 		if (trip_temp == 0)
 			set_bit(count, &tz->trips_disabled);
Signature · 1 line
2.28.0