[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20230203173331.3322089-6-daniel.lezcano@linaro.org>
Date: Fri, 3 Feb 2023 18:33:25 +0100
From: Daniel Lezcano <daniel.lezcano@...aro.org>
To: rjw@...ysocki.net
Cc: linux-acpi@...r.kernel.org, linux-pm@...r.kernel.org,
"Rafael J. Wysocki" <rafael@...nel.org>,
Zhang Rui <rui.zhang@...el.com>, Len Brown <lenb@...nel.org>,
linux-kernel@...r.kernel.org (open list)
Subject: [PATCH v1 05/11] thermal/acpi: Optimize get_trip_points()
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@...aro.org>
---
drivers/acpi/thermal.c | 19 ++++++++-----------
1 file changed, 8 insertions(+), 11 deletions(-)
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
index 903f0e3d95f5..c4fd583fbf5c 100644
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -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 */
--
2.34.1
Powered by blists - more mailing lists