[v1,05/11] thermal/acpi: Optimize get_trip_points()
Commit Message
The function has two purposes. Initialize the trip points by reading
the ACPI table and then doing a check trip points exists.
This check will go through all the trip points and at the end if a
valid trip point is found, the parsing is considered valid.
Instead of checking all the trip points, exit when a valid trip point
is found.
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
drivers/acpi/thermal.c | 19 ++++++++-----------
1 file changed, 8 insertions(+), 11 deletions(-)
@@ -461,23 +461,20 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag)
static int acpi_thermal_get_trip_points(struct acpi_thermal *tz)
{
- int i, valid, ret = acpi_thermal_trips_update(tz, ACPI_TRIPS_INIT);
+ int i, ret;
+ ret = acpi_thermal_trips_update(tz, ACPI_TRIPS_INIT);
if (ret)
return ret;
- valid = tz->trips[ACPI_THERMAL_TRIP_CRITICAL].flags.valid |
- tz->trips[ACPI_THERMAL_TRIP_HOT].flags.valid |
- tz->trips[ACPI_THERMAL_TRIP_PASSIVE].flags.valid;
+ for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
+ if (tz->trips[i].flags.valid)
+ return 0;
+ }
- for (i = ACPI_THERMAL_TRIP_ACTIVE; i < ACPI_THERMAL_MAX_ACTIVE; i++)
- valid |= tz->trips[i].flags.valid;
+ pr_warn(FW_BUG "No valid trip found\n");
- if (!valid) {
- pr_warn(FW_BUG "No valid trip found\n");
- return -ENODEV;
- }
- return 0;
+ return -ENODEV;
}
/* sys I/F for generic thermal sysfs support */