diff mbox series

[v1,03/13] ACPI: thermal: Collapse trip devices update function wrappers

Message ID 3198428.5fSG56mABF@kreacher
State New
Headers show
Series thermal: ACPI: More ACPI thermal improvements and modification of thermal instances | expand

Commit Message

Rafael J. Wysocki Sept. 21, 2023, 5:50 p.m. UTC
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

In order to reduce code duplicationeve further, merge
acpi_thermal_update_passive/active_devices() into one function
called acpi_thermal_update_trip_devices() that will be used for
updating both the passive and active trip points.

No intentional functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/acpi/thermal.c |   26 +++++++-------------------
 1 file changed, 7 insertions(+), 19 deletions(-)

Comments

Daniel Lezcano Sept. 27, 2023, 9:15 a.m. UTC | #1
On 21/09/2023 19:50, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> 
> In order to reduce code duplicationeve further, merge
> acpi_thermal_update_passive/active_devices() into one function
> called acpi_thermal_update_trip_devices() that will be used for
> updating both the passive and active trip points.
> 
> No intentional functional impact.
> 
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---

Reviewed-by: Daniel Lezcano <daniel.lezcano@linaro.org>
diff mbox series

Patch

Index: linux-pm/drivers/acpi/thermal.c
===================================================================
--- linux-pm.orig/drivers/acpi/thermal.c
+++ linux-pm/drivers/acpi/thermal.c
@@ -233,14 +233,16 @@  static bool update_trip_devices(struct a
 	return true;
 }
 
-static void acpi_thermal_update_passive_devices(struct acpi_thermal *tz)
+static void acpi_thermal_update_trip_devices(struct acpi_thermal *tz, int index)
 {
-	struct acpi_thermal_trip *acpi_trip = &tz->trips.passive.trip;
+	struct acpi_thermal_trip *acpi_trip;
 
+	acpi_trip = index == ACPI_THERMAL_TRIP_PASSIVE ?
+			&tz->trips.passive.trip : &tz->trips.active[index].trip;
 	if (!acpi_thermal_trip_valid(acpi_trip))
 		return;
 
-	if (update_trip_devices(tz, acpi_trip, ACPI_THERMAL_TRIP_PASSIVE, true)) {
+	if (update_trip_devices(tz, acpi_trip, index, true)) {
 		return;
 	}
 
@@ -283,20 +285,6 @@  static void acpi_thermal_update_active_t
 		ACPI_THERMAL_TRIPS_EXCEPTION(tz, "state");
 }
 
-static void acpi_thermal_update_active_devices(struct acpi_thermal *tz, int index)
-{
-	struct acpi_thermal_trip *acpi_trip = &tz->trips.active[index].trip;
-
-	if (!acpi_thermal_trip_valid(acpi_trip))
-		return;
-
-	if (update_trip_devices(tz, acpi_trip, index, true))
-		return;
-
-	acpi_trip->temperature = THERMAL_TEMP_INVALID;
-	ACPI_THERMAL_TRIPS_EXCEPTION(tz, "state");
-}
-
 static int acpi_thermal_adjust_trip(struct thermal_trip *trip, void *data)
 {
 	struct acpi_thermal_trip *acpi_trip = trip->priv;
@@ -324,9 +312,9 @@  static void acpi_thermal_adjust_thermal_
 		for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++)
 			acpi_thermal_update_active_trip(tz, i);
 	} else {
-		acpi_thermal_update_passive_devices(tz);
+		acpi_thermal_update_trip_devices(tz, ACPI_THERMAL_TRIP_PASSIVE);
 		for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++)
-			acpi_thermal_update_active_devices(tz, i);
+			acpi_thermal_update_trip_devices(tz, i);
 	}
 
 	for_each_thermal_trip(tz->thermal_zone, acpi_thermal_adjust_trip, tz);