lkml.org 
[lkml]   [2020]   [Oct]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v2] drivers/thermal: optimize the for circle to run a bit fast
Date
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.

Signed-off-by: Bernard Zhao <bernard@vivo.com>

Changes since V1:
*make the code more clear and readable

Link for V1:
*https://lore.kernel.org/patchwork/patch/1324507/
---
drivers/thermal/thermal_core.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index c6d74bc1c90b..3d1e0033bf3e 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -1446,12 +1446,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);
}

--
2.28.0
\
 
 \ /
  Last update: 2020-10-27 02:49    [W:0.064 / U:0.576 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site