ACPI: thermal: Collapse trip devices update function wrappers
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 21 Sep 2023 17:50:08 +0000 (19:50 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 28 Sep 2023 10:54:16 +0000 (12:54 +0200)
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>
drivers/acpi/thermal.c

index 93d2ab5526868b5430a5de865b8b9010de3a04c5..ebe11288d7e0d506ce895a928d907f67d3e51e0e 100644 (file)
@@ -233,14 +233,16 @@ static bool update_trip_devices(struct acpi_thermal *tz,
        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_trip(struct acpi_thermal *tz, int index)
                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_zone(struct thermal_zone_device *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);