summaryrefslogtreecommitdiff
path: root/drivers/acpi/thermal.c
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2023-08-07 20:06:13 +0200
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2023-08-17 11:24:18 +0200
commitbf07b4a3ba3446ba4bbe1ddac235162dbda2ce57 (patch)
treecaf1d5a27c2fc1758938a8f3b731e13c1ac7d18b /drivers/acpi/thermal.c
parentcba440fab30106c9ebd30dbbb64d4fb7b997a8e8 (diff)
ACPI: thermal: Clean up acpi_thermal_register_thermal_zone()
Rename the trips variable in acpi_thermal_register_thermal_zone() to trip_count so its name better reflects the purpose, rearrange white space in the loop over active trips for clarity and reduce code duplication related to calling thermal_zone_device_register() by using an extra local variable to store the passive delay value. No intentional functional impact. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/acpi/thermal.c')
-rw-r--r--drivers/acpi/thermal.c32
1 files changed, 14 insertions, 18 deletions
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
index 45a32b0148d9..4db33da40144 100644
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -740,33 +740,29 @@ static void acpi_thermal_zone_sysfs_remove(struct acpi_thermal *tz)
static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz)
{
- int trips = 0;
+ int passive_delay = 0;
+ int trip_count = 0;
int result;
int i;
if (tz->trips.critical.valid)
- trips++;
+ trip_count++;
if (tz->trips.hot.valid)
- trips++;
+ trip_count++;
- if (tz->trips.passive.valid)
- trips++;
-
- for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE && tz->trips.active[i].valid;
- i++, trips++);
+ if (tz->trips.passive.valid) {
+ trip_count++;
+ passive_delay = tz->trips.passive.tsp * 100;
+ }
- if (tz->trips.passive.valid)
- tz->thermal_zone = thermal_zone_device_register("acpitz", trips, 0, tz,
- &acpi_thermal_zone_ops, NULL,
- tz->trips.passive.tsp * 100,
- tz->polling_frequency * 100);
- else
- tz->thermal_zone =
- thermal_zone_device_register("acpitz", trips, 0, tz,
- &acpi_thermal_zone_ops, NULL,
- 0, tz->polling_frequency * 100);
+ for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE && tz->trips.active[i].valid; i++)
+ trip_count++;
+ tz->thermal_zone = thermal_zone_device_register("acpitz", trip_count, 0,
+ tz, &acpi_thermal_zone_ops,
+ NULL, passive_delay,
+ tz->polling_frequency * 100);
if (IS_ERR(tz->thermal_zone))
return -ENODEV;