lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1785516.VLH7GnMWUR@kreacher>
Date:   Thu, 21 Sep 2023 19:51:19 +0200
From:   "Rafael J. Wysocki" <rjw@...ysocki.net>
To:     Linux PM <linux-pm@...r.kernel.org>
Cc:     LKML <linux-kernel@...r.kernel.org>,
        Linux ACPI <linux-acpi@...r.kernel.org>,
        Srinivas Pandruvada <srinivas.pandruvada@...ux.intel.com>,
        Zhang Rui <rui.zhang@...el.com>,
        Daniel Lezcano <daniel.lezcano@...aro.org>,
        Lukasz Luba <lukasz.luba@....com>,
        "Rafael J. Wysocki" <rafael@...nel.org>
Subject: [PATCH v1 04/13] ACPI: thermal: Merge trip initialization functions

From: Rafael J. Wysocki <rafael.j.wysocki@...el.com>

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 <rafael.j.wysocki@...el.com>
---
 drivers/acpi/thermal.c |   64 ++++++++++++++++++++++---------------------------
 1 file changed, 30 insertions(+), 34 deletions(-)

Index: linux-pm/drivers/acpi/thermal.c
===================================================================
--- linux-pm.orig/drivers/acpi/thermal.c
+++ linux-pm/drivers/acpi/thermal.c
@@ -399,72 +399,68 @@ static long acpi_thermal_get_hot_trip(st
 	return tmp;
 }
 
-static bool acpi_thermal_init_passive_trip(struct acpi_thermal *tz)
+static bool passive_trip_params_init(struct acpi_thermal *tz)
 {
 	unsigned long long tmp;
 	acpi_status status;
-	int temp;
-
-	if (psv == -1)
-		goto fail;
-
-	if (psv > 0) {
-		temp = celsius_to_deci_kelvin(psv);
-	} else {
-		temp = get_passive_temp(tz);
-		if (temp == THERMAL_TEMP_INVALID)
-			goto fail;
-	}
 
 	status = acpi_evaluate_integer(tz->device->handle, "_TC1", NULL, &tmp);
 	if (ACPI_FAILURE(status))
-		goto fail;
+		return false;
 
 	tz->trips.passive.tc1 = tmp;
 
 	status = acpi_evaluate_integer(tz->device->handle, "_TC2", NULL, &tmp);
 	if (ACPI_FAILURE(status))
-		goto fail;
+		return false;
 
 	tz->trips.passive.tc2 = tmp;
 
 	status = acpi_evaluate_integer(tz->device->handle, "_TSP", NULL, &tmp);
 	if (ACPI_FAILURE(status))
-		goto fail;
+		return false;
 
 	tz->trips.passive.tsp = tmp;
 
-	if (!update_trip_devices(tz, &tz->trips.passive.trip,
-				 ACPI_THERMAL_TRIP_PASSIVE, false))
-		goto fail;
-
-	tz->trips.passive.trip.temperature = temp;
 	return true;
-
-fail:
-	tz->trips.passive.trip.temperature = THERMAL_TEMP_INVALID;
-	return false;
 }
 
-static bool acpi_thermal_init_active_trip(struct acpi_thermal *tz, int index)
+static bool acpi_thermal_init_trip(struct acpi_thermal *tz, int index)
 {
+	struct acpi_thermal_trip *acpi_trip;
 	long temp;
 
-	if (act == -1)
-		goto fail;
+	if (index == ACPI_THERMAL_TRIP_PASSIVE) {
+		acpi_trip = &tz->trips.passive.trip;
+
+		if (psv == -1)
+			goto fail;
+
+		if (!passive_trip_params_init(tz))
+			goto fail;
+
+		temp = psv > 0 ? celsius_to_deci_kelvin(psv) :
+				 get_passive_temp(tz);
+	} else {
+		acpi_trip = &tz->trips.active[index].trip;
+
+		if (act == -1)
+			goto fail;
+
+		temp = get_active_temp(tz, index);
+	}
 
-	temp = get_active_temp(tz, index);
 	if (temp == THERMAL_TEMP_INVALID)
 		goto fail;
 
-	if (!update_trip_devices(tz, &tz->trips.active[index].trip, index, false))
+	if (!update_trip_devices(tz, acpi_trip, index, false))
 		goto fail;
 
-	tz->trips.active[index].trip.temperature = temp;
+	acpi_trip->temperature = temp;
 	return true;
 
 fail:
-	tz->trips.active[index].trip.temperature = THERMAL_TEMP_INVALID;
+	acpi_trip->temperature = THERMAL_TEMP_INVALID;
 	return false;
 }
 
@@ -473,11 +469,11 @@ static int acpi_thermal_get_trip_points(
 	unsigned int count = 0;
 	int i;
 
-	if (acpi_thermal_init_passive_trip(tz))
+	if (acpi_thermal_init_trip(tz, ACPI_THERMAL_TRIP_PASSIVE))
 		count++;
 
 	for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
-		if (acpi_thermal_init_active_trip(tz, i))
+		if (acpi_thermal_init_trip(tz, i))
 			count++;
 		else
 			break;



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ