mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Stephen Horvath <s.horvath@outlook.com.au>
To: "Rafael J. Wysocki" <rafael@kernel.org>,
	Zhang Rui <rui.zhang@intel.com>, Len Brown <lenb@kernel.org>,
	linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Stephen Horvath <s.horvath@outlook.com.au>
Subject: [PATCH v2] ACPI: thermal: Continue registering thermal zones even if trip points fail validation
Date: Sun, 31 Mar 2024 18:37:06 +1000	[thread overview]
Message-ID: <SY4P282MB3063A002007A252337A416DEC5382@SY4P282MB3063.AUSP282.PROD.OUTLOOK.COM> (raw)

Some laptops where the thermal control is handled by the EC may
provide trip points that fail the kernels new validation, but still have
working temperature sensors. An example of this is the Framework 13 AMD.

This patch allows the thermal zone to still be registered without trip
points if the trip points fail validation, allowing the temperature
sensor to be viewed and used by the user.

Closes: https://bugzilla.kernel.org/show_bug.cgi?id=218586
Fixes: 9c8647224e9f ("ACPI: thermal: Use library functions to obtain trip point temperature values")
Signed-off-by: Stephen Horvath <s.horvath@outlook.com.au>
---
 V1 -> V2: Referenced bug tracker in commit, and switched to using
                `thermal_tripless_zone_device_register` as per the
                suggestion of Rafael J. Wysocki.

 drivers/acpi/thermal.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
index 302dce0b2b50..10044c56b85e 100644
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -662,14 +662,16 @@ static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz,
 {
 	int result;
 
-	tz->thermal_zone = thermal_zone_device_register_with_trips("acpitz",
-								   trip_table,
-								   trip_count,
-								   tz,
-								   &acpi_thermal_zone_ops,
-								   NULL,
-								   passive_delay,
-								   tz->polling_frequency * 100);
+	if (trip_count) {
+		tz->thermal_zone = thermal_zone_device_register_with_trips(
+			"acpitz", trip_table, trip_count, tz,
+			&acpi_thermal_zone_ops, NULL, passive_delay,
+			tz->polling_frequency * 100);
+	} else {
+		tz->thermal_zone = thermal_tripless_zone_device_register(
+			"acpitz", tz, &acpi_thermal_zone_ops, NULL);
+	}
+
 	if (IS_ERR(tz->thermal_zone))
 		return PTR_ERR(tz->thermal_zone);
 
@@ -903,8 +905,6 @@ static int acpi_thermal_add(struct acpi_device *device)
 
 	if (trip == trip_table) {
 		pr_warn(FW_BUG "No valid trip points!\n");
-		result = -ENODEV;
-		goto free_memory;
 	}
 
 	result = acpi_thermal_register_thermal_zone(tz, trip_table,

base-commit: 4cece764965020c22cff7665b18a012006359095
-- 
2.43.0


             reply	other threads:[~2024-03-31  8:37 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-31  8:37 Stephen Horvath [this message]
2024-04-02 19:40 ` Rafael J. Wysocki
2024-04-02 22:43   ` Stephen Horvath

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=SY4P282MB3063A002007A252337A416DEC5382@SY4P282MB3063.AUSP282.PROD.OUTLOOK.COM \
    --to=s.horvath@outlook.com.au \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=rui.zhang@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®