Skip to content

Commit 4f9cf91

Browse files
committed
ACPI: thermal: Combine passive and active trip update functions
Combine acpi_thermal_update_passive_trip() and acpi_thermal_update_active_trip() into one common function called acpi_thermal_update_trip(), so as to reduce code duplication and prepare the code in question for subsequent changes. No intentional functional impact. Signed-off-by: Rafael J. Wysocki <[email protected]> Reviewed-by: Daniel Lezcano <[email protected]>
1 parent 44babd8 commit 4f9cf91

File tree

1 file changed

+17
-18
lines changed

1 file changed

+17
-18
lines changed

drivers/acpi/thermal.c

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -212,14 +212,25 @@ static long get_active_temp(struct acpi_thermal *tz, int index)
212212
return tmp;
213213
}
214214

215-
static void acpi_thermal_update_passive_trip(struct acpi_thermal *tz)
215+
static void acpi_thermal_update_trip(struct acpi_thermal *tz,
216+
int index)
216217
{
217-
struct acpi_thermal_trip *acpi_trip = &tz->trips.passive.trip;
218+
struct acpi_thermal_trip *acpi_trip;
218219

219-
if (!acpi_thermal_trip_valid(acpi_trip) || psv > 0)
220+
acpi_trip = index == ACPI_THERMAL_TRIP_PASSIVE ?
221+
&tz->trips.passive.trip : &tz->trips.active[index].trip;
222+
if (!acpi_thermal_trip_valid(acpi_trip))
220223
return;
221224

222-
acpi_trip->temp_dk = get_passive_temp(tz);
225+
if (index == ACPI_THERMAL_TRIP_PASSIVE) {
226+
if (psv > 0)
227+
return;
228+
229+
acpi_trip->temp_dk = get_passive_temp(tz);
230+
} else {
231+
acpi_trip->temp_dk = get_active_temp(tz, index);
232+
}
233+
223234
if (!acpi_thermal_trip_valid(acpi_trip))
224235
ACPI_THERMAL_TRIPS_EXCEPTION(tz, "state");
225236
}
@@ -270,18 +281,6 @@ static void acpi_thermal_update_trip_devices(struct acpi_thermal *tz, int index)
270281
ACPI_THERMAL_TRIPS_EXCEPTION(tz, "state");
271282
}
272283

273-
static void acpi_thermal_update_active_trip(struct acpi_thermal *tz, int index)
274-
{
275-
struct acpi_thermal_trip *acpi_trip = &tz->trips.active[index].trip;
276-
277-
if (!acpi_thermal_trip_valid(acpi_trip))
278-
return;
279-
280-
acpi_trip->temp_dk = get_active_temp(tz, index);
281-
if (!acpi_thermal_trip_valid(acpi_trip))
282-
ACPI_THERMAL_TRIPS_EXCEPTION(tz, "state");
283-
}
284-
285284
static int acpi_thermal_adjust_trip(struct thermal_trip *trip, void *data)
286285
{
287286
struct acpi_thermal_trip *acpi_trip = trip->priv;
@@ -305,9 +304,9 @@ static void acpi_thermal_adjust_thermal_zone(struct thermal_zone_device *thermal
305304
int i;
306305

307306
if (data == ACPI_THERMAL_NOTIFY_THRESHOLDS) {
308-
acpi_thermal_update_passive_trip(tz);
307+
acpi_thermal_update_trip(tz, ACPI_THERMAL_TRIP_PASSIVE);
309308
for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++)
310-
acpi_thermal_update_active_trip(tz, i);
309+
acpi_thermal_update_trip(tz, i);
311310
} else {
312311
acpi_thermal_update_trip_devices(tz, ACPI_THERMAL_TRIP_PASSIVE);
313312
for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++)

0 commit comments

Comments
 (0)