diff mbox series

[thermal:,thermal/next] drivers/thermal/core: Optimize trip points check

Message ID 160621060274.11115.1871630758046158914.tip-bot2@tip-bot2 (mailing list archive)
State Not Applicable, archived
Headers show
Series [thermal:,thermal/next] drivers/thermal/core: Optimize trip points check | expand

Commit Message

thermal-bot for Stanislaw Gruszka Nov. 24, 2020, 9:36 a.m. UTC
The following commit has been merged into the thermal/next branch of thermal:

Commit-ID:     37b2539e63d6570c9ee51b1d48bdecb334df367d
Gitweb:        https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git//37b2539e63d6570c9ee51b1d48bdecb334df367d
Author:        Bernard Zhao <bernard@vivo.com>
AuthorDate:    Mon, 26 Oct 2020 18:37:42 -07:00
Committer:     Daniel Lezcano <daniel.lezcano@linaro.org>
CommitterDate: Tue, 27 Oct 2020 09:53:19 +01:00

drivers/thermal/core: Optimize trip points check

The trip points are checked one by one with multiple condition
branches where one condition is enough to disable the trip point.

Merge all these conditions in a single 'OR' statement.

Signed-off-by: Bernard Zhao <bernard@vivo.com>
Suggested-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20201027013743.62392-1-bernard@vivo.com

[dlezcano] Changed patch description
---
 drivers/thermal/thermal_core.c |  9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index 96349ba..90e38cc 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -1358,12 +1358,9 @@  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))
-			set_bit(count, &tz->trips_disabled);
-		if (tz->ops->get_trip_temp(tz, count, &trip_temp))
-			set_bit(count, &tz->trips_disabled);
-		/* Check for bogus trip points */
-		if (trip_temp == 0)
+		if (tz->ops->get_trip_type(tz, count, &trip_type) ||
+		    tz->ops->get_trip_temp(tz, count, &trip_temp) ||
+		    !trip_temp)
 			set_bit(count, &tz->trips_disabled);
 	}