All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@rjwysocki.net>
To: Linux ACPI <linux-acpi@vger.kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Linux PM <linux-pm@vger.kernel.org>,
	Zhang Rui <rui.zhang@intel.com>,
	Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>,
	Daniel Lezcano <daniel.lezcano@linaro.org>
Subject: [PATCH v1 9/9] ACPI: thermal: Drop valid flag from struct acpi_thermal_trip
Date: Tue, 12 Sep 2023 20:47:23 +0200	[thread overview]
Message-ID: <9162925.CDJkKcVGEf@kreacher> (raw)
In-Reply-To: <5708760.DvuYhMxLoT@kreacher>

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

Notice that the valid flag in struct acpi_thermal_trip is in fact
redundant, because the temperature field of invalid trips is always
equal to THERMAL_TEMP_INVALID, so drop it from there and adjust the
code accordingly.

No intentional functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/acpi/thermal.c |   49 +++++++++++++++++++++++--------------------------
 1 file changed, 23 insertions(+), 26 deletions(-)

Index: linux-pm/drivers/acpi/thermal.c
===================================================================
--- linux-pm.orig/drivers/acpi/thermal.c
+++ linux-pm/drivers/acpi/thermal.c
@@ -81,7 +81,6 @@ static struct workqueue_struct *acpi_the
 
 struct acpi_thermal_trip {
 	unsigned long temperature;
-	bool valid;
 };
 
 struct acpi_thermal_passive {
@@ -175,11 +174,9 @@ static int acpi_thermal_temp(struct acpi
 						       tz->kelvin_offset);
 }
 
-static void update_acpi_thermal_trip_temp(struct acpi_thermal_trip *acpi_trip,
-					  int temp)
+static bool acpi_thermal_trip_valid(struct acpi_thermal_trip *acpi_trip)
 {
-	acpi_trip->valid = temp != THERMAL_TEMP_INVALID;
-	acpi_trip->temperature = temp;
+	return acpi_trip->temperature != THERMAL_TEMP_INVALID;
 }
 
 static long get_passive_temp(struct acpi_thermal *tz)
@@ -198,11 +195,11 @@ static void acpi_thermal_update_passive_
 {
 	struct acpi_thermal_trip *acpi_trip = &tz->trips.passive.trip;
 
-	if (!acpi_trip->valid || psv > 0)
+	if (!acpi_thermal_trip_valid(acpi_trip) || psv > 0)
 		return;
 
-	update_acpi_thermal_trip_temp(acpi_trip, get_passive_temp(tz));
-	if (!acpi_trip->valid)
+	acpi_trip->temperature = get_passive_temp(tz);
+	if (!acpi_thermal_trip_valid(acpi_trip))
 		ACPI_THERMAL_TRIPS_EXCEPTION(tz, "state");
 }
 
@@ -231,13 +228,13 @@ static void acpi_thermal_update_passive_
 {
 	struct acpi_thermal_trip *acpi_trip = &tz->trips.passive.trip;
 
-	if (!acpi_trip->valid)
+	if (!acpi_thermal_trip_valid(acpi_trip))
 		return;
 
 	if (update_passive_devices(tz, true))
 		return;
 
-	update_acpi_thermal_trip_temp(acpi_trip, THERMAL_TEMP_INVALID);
+	acpi_trip->temperature = THERMAL_TEMP_INVALID;
 	ACPI_THERMAL_TRIPS_EXCEPTION(tz, "state");
 }
 
@@ -268,11 +265,11 @@ static void acpi_thermal_update_active_t
 {
 	struct acpi_thermal_trip *acpi_trip = &tz->trips.active[index].trip;
 
-	if (!acpi_trip->valid)
+	if (!acpi_thermal_trip_valid(acpi_trip))
 		return;
 
-	update_acpi_thermal_trip_temp(acpi_trip, get_active_temp(tz, index));
-	if (!acpi_trip->valid)
+	acpi_trip->temperature = get_active_temp(tz, index);
+	if (!acpi_thermal_trip_valid(acpi_trip))
 		ACPI_THERMAL_TRIPS_EXCEPTION(tz, "state");
 }
 
@@ -303,13 +300,13 @@ static void acpi_thermal_update_active_d
 {
 	struct acpi_thermal_trip *acpi_trip = &tz->trips.active[index].trip;
 
-	if (!acpi_trip->valid)
+	if (!acpi_thermal_trip_valid(acpi_trip))
 		return;
 
 	if (update_active_devices(tz, index, true))
 		return;
 
-	update_acpi_thermal_trip_temp(acpi_trip, THERMAL_TEMP_INVALID);
+	acpi_trip->temperature = THERMAL_TEMP_INVALID;
 	ACPI_THERMAL_TRIPS_EXCEPTION(tz, "state");
 }
 
@@ -321,7 +318,7 @@ static int acpi_thermal_adjust_trip(stru
 	if (!acpi_trip)
 		return 0;
 
-	if (acpi_trip->valid)
+	if (acpi_thermal_trip_valid(acpi_trip))
 		trip->temperature = acpi_thermal_temp(tz, acpi_trip->temperature);
 	else
 		trip->temperature = THERMAL_TEMP_INVALID;
@@ -465,11 +462,11 @@ static bool acpi_thermal_init_passive_tr
 	if (!update_passive_devices(tz, false))
 		goto fail;
 
-	update_acpi_thermal_trip_temp(&tz->trips.passive.trip, temp);
+	tz->trips.passive.trip.temperature = temp;
 	return true;
 
 fail:
-	update_acpi_thermal_trip_temp(&tz->trips.passive.trip, THERMAL_TEMP_INVALID);
+	tz->trips.passive.trip.temperature = THERMAL_TEMP_INVALID;
 	return false;
 }
 
@@ -487,11 +484,11 @@ static bool acpi_thermal_init_active_tri
 	if (!update_active_devices(tz, false, index))
 		goto fail;
 
-	update_acpi_thermal_trip_temp(&tz->trips.active[index].trip, temp);
+	tz->trips.active[index].trip.temperature = temp;
 	return true;
 
 fail:
-	update_acpi_thermal_trip_temp(&tz->trips.active[index].trip, THERMAL_TEMP_INVALID);
+	tz->trips.active[index].trip.temperature = THERMAL_TEMP_INVALID;
 	return false;
 }
 
@@ -545,7 +542,7 @@ static int thermal_get_trend(struct ther
 		return -EINVAL;
 
 	acpi_trip = trip->priv;
-	if (!acpi_trip || !acpi_trip->valid)
+	if (!acpi_trip || !acpi_thermal_trip_valid(acpi_trip))
 		return -EINVAL;
 
 	switch (trip->type) {
@@ -618,7 +615,7 @@ static int acpi_thermal_cooling_device_c
 	if (tz->trips.hot_valid)
 		trip++;
 
-	if (tz->trips.passive.trip.valid) {
+	if (acpi_thermal_trip_valid(&tz->trips.passive.trip)) {
 		trip++;
 		for (i = 0; i < tz->trips.passive.devices.count; i++) {
 			handle = tz->trips.passive.devices.handles[i];
@@ -643,7 +640,7 @@ static int acpi_thermal_cooling_device_c
 	}
 
 	for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
-		if (!tz->trips.active[i].trip.valid)
+		if (!acpi_thermal_trip_valid(&tz->trips.active[i].trip))
 			break;
 
 		trip++;
@@ -949,7 +946,7 @@ static int acpi_thermal_add(struct acpi_
 	}
 
 	acpi_trip = &tz->trips.passive.trip;
-	if (acpi_trip->valid) {
+	if (acpi_thermal_trip_valid(acpi_trip)) {
 		passive_delay = tz->trips.passive.tsp * 100;
 
 		trip->type = THERMAL_TRIP_PASSIVE;
@@ -961,7 +958,7 @@ static int acpi_thermal_add(struct acpi_
 	for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
 		acpi_trip =  &tz->trips.active[i].trip;
 
-		if (!acpi_trip->valid)
+		if (!acpi_thermal_trip_valid(acpi_trip))
 			break;
 
 		trip->type = THERMAL_TRIP_ACTIVE;
@@ -1038,7 +1035,7 @@ static int acpi_thermal_resume(struct de
 		return -EINVAL;
 
 	for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
-		if (!tz->trips.active[i].trip.valid)
+		if (!acpi_thermal_trip_valid(&tz->trips.active[i].trip))
 			break;
 
 		for (j = 0; j < tz->trips.active[i].devices.count; j++) {




  parent reply	other threads:[~2023-09-12 18:47 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-12 18:33 [PATCH v1 0/9] ACPI: thermal: Removal of redundant data and cleanup Rafael J. Wysocki
2023-09-12 18:35 ` [PATCH v1 1/9] ACPI: thermal: Simplify initialization of critical and hot trips Rafael J. Wysocki
2023-09-25 15:20   ` Daniel Lezcano
2023-09-25 17:12     ` Rafael J. Wysocki
2023-09-12 18:36 ` [PATCH v1 2/9] ACPI: thermal: Fold acpi_thermal_get_info() into its caller Rafael J. Wysocki
2023-09-25 15:31   ` Daniel Lezcano
2023-09-12 18:37 ` [PATCH v1 3/9] ACPI: thermal: Determine the number of trip points earlier Rafael J. Wysocki
2023-09-25 15:59   ` Daniel Lezcano
2023-09-12 18:39 ` [PATCH v1 4/9] ACPI: thermal: Create and populate trip points table earlier Rafael J. Wysocki
2023-09-25 16:29   ` Daniel Lezcano
2023-09-12 18:41 ` [PATCH v1 5/9] ACPI: thermal: Simplify critical and hot trips representation Rafael J. Wysocki
2023-09-25 16:33   ` Daniel Lezcano
2023-09-12 18:43 ` [PATCH v1 6/9] ACPI: thermal: Untangle initialization and updates of the passive trip Rafael J. Wysocki
2023-09-26 11:30   ` Daniel Lezcano
2023-09-12 18:43 ` [PATCH v1 7/9] ACPI: thermal: Untangle initialization and updates of active trips Rafael J. Wysocki
2023-09-20 13:06   ` Rafael J. Wysocki
2023-09-26 13:04   ` Daniel Lezcano
2023-09-12 18:46 ` [PATCH v1 8/9] ACPI: thermal: Drop redundant trip point flags Rafael J. Wysocki
2023-09-26 13:46   ` Daniel Lezcano
2023-09-12 18:47 ` Rafael J. Wysocki [this message]
2023-09-21  7:36   ` [PATCH v1 9/9] ACPI: thermal: Drop valid flag from struct acpi_thermal_trip Daniel Lezcano
2023-09-26 13:47   ` Daniel Lezcano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9162925.CDJkKcVGEf@kreacher \
    --to=rjw@rjwysocki.net \
    --cc=daniel.lezcano@linaro.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rui.zhang@intel.com \
    --cc=srinivas.pandruvada@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.