Skip to content

Commit 3e7d6f3

Browse files
committed
ACPI: thermal: Merge trip initialization functions
In order to reduce code duplicationeve further, merge acpi_thermal_init_passive/active_trip() into one function called acpi_thermal_init_trip() that will be used for initializing both the passive and active trip points. No intentional functional impact. Signed-off-by: Rafael J. Wysocki <[email protected]> Reviewed-by: Daniel Lezcano <[email protected]>
1 parent 54fc61a commit 3e7d6f3

File tree

1 file changed

+30
-34
lines changed

1 file changed

+30
-34
lines changed

drivers/acpi/thermal.c

Lines changed: 30 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -399,72 +399,68 @@ static long acpi_thermal_get_hot_trip(struct acpi_thermal *tz)
399399
return tmp;
400400
}
401401

402-
static bool acpi_thermal_init_passive_trip(struct acpi_thermal *tz)
402+
static bool passive_trip_params_init(struct acpi_thermal *tz)
403403
{
404404
unsigned long long tmp;
405405
acpi_status status;
406-
int temp;
407-
408-
if (psv == -1)
409-
goto fail;
410-
411-
if (psv > 0) {
412-
temp = celsius_to_deci_kelvin(psv);
413-
} else {
414-
temp = get_passive_temp(tz);
415-
if (temp == THERMAL_TEMP_INVALID)
416-
goto fail;
417-
}
418406

419407
status = acpi_evaluate_integer(tz->device->handle, "_TC1", NULL, &tmp);
420408
if (ACPI_FAILURE(status))
421-
goto fail;
409+
return false;
422410

423411
tz->trips.passive.tc1 = tmp;
424412

425413
status = acpi_evaluate_integer(tz->device->handle, "_TC2", NULL, &tmp);
426414
if (ACPI_FAILURE(status))
427-
goto fail;
415+
return false;
428416

429417
tz->trips.passive.tc2 = tmp;
430418

431419
status = acpi_evaluate_integer(tz->device->handle, "_TSP", NULL, &tmp);
432420
if (ACPI_FAILURE(status))
433-
goto fail;
421+
return false;
434422

435423
tz->trips.passive.tsp = tmp;
436424

437-
if (!update_trip_devices(tz, &tz->trips.passive.trip,
438-
ACPI_THERMAL_TRIP_PASSIVE, false))
439-
goto fail;
440-
441-
tz->trips.passive.trip.temperature = temp;
442425
return true;
443-
444-
fail:
445-
tz->trips.passive.trip.temperature = THERMAL_TEMP_INVALID;
446-
return false;
447426
}
448427

449-
static bool acpi_thermal_init_active_trip(struct acpi_thermal *tz, int index)
428+
static bool acpi_thermal_init_trip(struct acpi_thermal *tz, int index)
450429
{
430+
struct acpi_thermal_trip *acpi_trip;
451431
long temp;
452432

453-
if (act == -1)
454-
goto fail;
433+
if (index == ACPI_THERMAL_TRIP_PASSIVE) {
434+
acpi_trip = &tz->trips.passive.trip;
435+
436+
if (psv == -1)
437+
goto fail;
438+
439+
if (!passive_trip_params_init(tz))
440+
goto fail;
441+
442+
temp = psv > 0 ? celsius_to_deci_kelvin(psv) :
443+
get_passive_temp(tz);
444+
} else {
445+
acpi_trip = &tz->trips.active[index].trip;
446+
447+
if (act == -1)
448+
goto fail;
449+
450+
temp = get_active_temp(tz, index);
451+
}
455452

456-
temp = get_active_temp(tz, index);
457453
if (temp == THERMAL_TEMP_INVALID)
458454
goto fail;
459455

460-
if (!update_trip_devices(tz, &tz->trips.active[index].trip, index, false))
456+
if (!update_trip_devices(tz, acpi_trip, index, false))
461457
goto fail;
462458

463-
tz->trips.active[index].trip.temperature = temp;
459+
acpi_trip->temperature = temp;
464460
return true;
465461

466462
fail:
467-
tz->trips.active[index].trip.temperature = THERMAL_TEMP_INVALID;
463+
acpi_trip->temperature = THERMAL_TEMP_INVALID;
468464
return false;
469465
}
470466

@@ -473,11 +469,11 @@ static int acpi_thermal_get_trip_points(struct acpi_thermal *tz)
473469
unsigned int count = 0;
474470
int i;
475471

476-
if (acpi_thermal_init_passive_trip(tz))
472+
if (acpi_thermal_init_trip(tz, ACPI_THERMAL_TRIP_PASSIVE))
477473
count++;
478474

479475
for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
480-
if (acpi_thermal_init_active_trip(tz, i))
476+
if (acpi_thermal_init_trip(tz, i))
481477
count++;
482478
else
483479
break;

0 commit comments

Comments
 (0)