From: Daniel Lezcano <daniel.lezcano@linaro.org>
To: rjw@rjwysocki.net
Cc: daniel.lezcano@linaro.org, linux-acpi@vger.kernel.org,
linux-pm@vger.kernel.org,
Daniel Lezcano <daniel.lezcano@kernel.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Zhang Rui <rui.zhang@intel.com>, Len Brown <lenb@kernel.org>,
linux-kernel@vger.kernel.org (open list)
Subject: [PATCH v2 11/11] thermal/acpi: Use the thermal framework ACPI API
Date: Fri, 3 Feb 2023 18:44:29 +0100 [thread overview]
Message-ID: <20230203174429.3375691-12-daniel.lezcano@linaro.org> (raw)
In-Reply-To: <20230203174429.3375691-1-daniel.lezcano@linaro.org>
From: Daniel Lezcano <daniel.lezcano@kernel.org>
The thermal framework has a set of functions to fill the trip
points. Those functions are already used by the int340x and the quark
Intel's platform.
Reuse these functions in order to consolidate the generic trip points
usage across the thermal ACPI user.
Signed-off-by: Daniel Lezcano <daniel.lezcano@kernel.org>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
drivers/acpi/thermal.c | 85 +++++++++++++++++++-----------------------
1 file changed, 38 insertions(+), 47 deletions(-)
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
index f89236cd4fcd..5e4d93c67b75 100644
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -259,8 +259,11 @@ static struct thermal_trip *acpi_thermal_trips_alloc_critical(struct acpi_therma
struct thermal_trip *trips,
int *num_trips)
{
- acpi_status status = AE_OK;
- unsigned long long temp;
+ struct thermal_trip trip = {
+ .type = THERMAL_TRIP_CRITICAL,
+ };
+
+ int ret;
/*
* Module parameters disable the critical trip point
@@ -268,14 +271,12 @@ static struct thermal_trip *acpi_thermal_trips_alloc_critical(struct acpi_therma
if (crt < 0)
goto out;
- status = acpi_evaluate_integer(tz->device->handle, "_CRT", NULL, &temp);
- if (ACPI_FAILURE(status)) {
- acpi_handle_debug(tz->device->handle, "No critical threshold\n");
+ ret = thermal_acpi_critical_trip_temp(tz->device->handle, &trip.temperature);
+ if (ret)
goto out;
- }
-
- if (temp <= 2732) {
- pr_info(FW_BUG "Invalid critical threshold (%llu)\n", temp);
+
+ if (trip.temperature <= 0) {
+ pr_info(FW_BUG "Invalid critical threshold (%d)\n", trip.temperature);
goto out;
}
@@ -283,10 +284,7 @@ static struct thermal_trip *acpi_thermal_trips_alloc_critical(struct acpi_therma
if (!trips)
goto out;
- memset(&trips[*num_trips], 0, sizeof(*trips));
-
- trips[*num_trips].temperature = deci_kelvin_to_millicelsius(temp);
- trips[*num_trips].type = THERMAL_TRIP_CRITICAL;
+ trips[*num_trips] = trip; /* structure copy */
if (crt > 0)
acpi_thermal_trips_override(&trips[*num_trips], crt * MILLI);
@@ -300,23 +298,21 @@ static struct thermal_trip *acpi_thermal_trips_alloc_hot(struct acpi_thermal *tz
struct thermal_trip *trips,
int *num_trips)
{
- acpi_status status;
- unsigned long long temp;
+ struct thermal_trip trip = {
+ .type = THERMAL_TRIP_HOT,
+ };
- status = acpi_evaluate_integer(tz->device->handle, "_HOT", NULL, &temp);
- if (ACPI_FAILURE(status)) {
- acpi_handle_debug(tz->device->handle, "No hot threshold\n");
+ int ret;
+
+ ret = thermal_acpi_hot_trip_temp(tz->device->handle, &trip.temperature);
+ if (ret)
goto out;
- }
trips = krealloc(trips, sizeof(*trips) * (*num_trips + 1), GFP_KERNEL);
if (!trips)
goto out;
- memset(&trips[*num_trips], 0, sizeof(*trips));
-
- trips[*num_trips].temperature = deci_kelvin_to_millicelsius(temp);
- trips[*num_trips].type = THERMAL_TRIP_HOT;
+ trips[*num_trips] = trip; /* structure copy */
(*num_trips)++;
out:
@@ -327,9 +323,12 @@ static struct thermal_trip *acpi_thermal_trips_alloc_passive(struct acpi_thermal
struct thermal_trip *trips,
int *num_trips)
{
- struct acpi_handle_list devices;
acpi_status status;
- unsigned long long temp;
+ struct acpi_handle_list devices;
+ struct thermal_trip trip = {
+ .type = THERMAL_TRIP_PASSIVE
+ };
+ int ret;
/*
* Module parameters disable all passive trip points
@@ -337,26 +336,21 @@ static struct thermal_trip *acpi_thermal_trips_alloc_passive(struct acpi_thermal
if (psv < 0)
goto out;
- status = acpi_evaluate_integer(tz->device->handle, "_PSV", NULL, &temp);
- if (ACPI_FAILURE(status)) {
- acpi_handle_debug(tz->device->handle, "No passive threshold\n");
+ ret = thermal_acpi_passive_trip_temp(tz->device->handle, &trip.temperature);
+ if (ret)
goto out;
- }
-
+
status = acpi_evaluate_reference(tz->device->handle, "_PSL", NULL, &devices);
if (ACPI_FAILURE(status)) {
acpi_handle_debug(tz->device->handle, "No passive device associated\n");
goto out;
}
-
+
trips = krealloc(trips, sizeof(*trips) * (*num_trips + 1), GFP_KERNEL);
if (!trips)
goto out;
- memset(&trips[*num_trips], 0, sizeof(*trips));
-
- trips[*num_trips].temperature = deci_kelvin_to_millicelsius(temp);
- trips[*num_trips].type = THERMAL_TRIP_PASSIVE;
+ trips[*num_trips] = trip; /* structure copy */
(*num_trips)++;
out:
@@ -367,10 +361,9 @@ static struct thermal_trip *acpi_thermal_trips_alloc_active(struct acpi_thermal
struct thermal_trip *trips,
int *num_trips)
{
- struct acpi_handle_list devices;
acpi_status status;
- unsigned long long temp;
- int i;
+ struct acpi_handle_list devices;
+ int i, ret;
/*
* Module parameters disable all active trip points
@@ -379,12 +372,13 @@ static struct thermal_trip *acpi_thermal_trips_alloc_active(struct acpi_thermal
return trips;
for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
+ struct thermal_trip trip = {
+ .type = THERMAL_TRIP_ACTIVE,
+ };
char name[5];
- sprintf(name, "_AC%d", i);
-
- status = acpi_evaluate_integer(tz->device->handle, name, NULL, &temp);
- if (ACPI_FAILURE(status))
+ ret = thermal_acpi_active_trip_temp(tz->device->handle, i , &trip.temperature);
+ if (ret)
break;
sprintf(name, "_AL%d", i);
@@ -394,16 +388,13 @@ static struct thermal_trip *acpi_thermal_trips_alloc_active(struct acpi_thermal
acpi_handle_info(tz->device->handle, "No _AL%d defined for _AC%d\n", i, i);
break;
}
-
+
trips = krealloc(trips, sizeof(*trips) * (*num_trips + 1), GFP_KERNEL);
if (!trips)
break;
- memset(&trips[*num_trips], 0, sizeof(*trips));
+ trips[*num_trips] = trip; /* structure copy */
- trips[*num_trips].temperature = deci_kelvin_to_millicelsius(temp);
- trips[*num_trips].type = THERMAL_TRIP_ACTIVE;
-
(*num_trips)++;
}
--
2.34.1
next prev parent reply other threads:[~2023-02-03 17:45 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20230203174429.3375691-1-daniel.lezcano@linaro.org>
2023-02-03 17:44 ` [PATCH v2 01/11] thermal/acpi: Remove the intermediate acpi_thermal_trip structure Daniel Lezcano
2023-02-03 17:44 ` [PATCH v2 02/11] thermal/acpi: Change to a common " Daniel Lezcano
2023-02-03 17:44 ` [PATCH v2 03/11] thermal/acpi: Convert the acpi thermal trips to an array Daniel Lezcano
2023-02-03 17:44 ` [PATCH v2 04/11] thermal/acpi: Move the active trip points to the same array Daniel Lezcano
2023-02-03 17:44 ` [PATCH v2 05/11] thermal/acpi: Optimize get_trip_points() Daniel Lezcano
2023-02-03 17:44 ` [PATCH v2 06/11] thermal/acpi: Encapsulate in functions the trip initialization Daniel Lezcano
2023-02-03 17:44 ` [PATCH v2 07/11] thermal/acpi: Simplifify the condition check Daniel Lezcano
2023-02-03 17:44 ` [PATCH v2 08/11] thermal/acpi: Remove active and enabled flags Daniel Lezcano
2023-02-03 17:44 ` [PATCH v2 09/11] thermal/acpi: Convert the units to milli Celsuis Daniel Lezcano
2023-02-03 17:44 ` [PATCH v2 10/11] thermal/acpi: Rewrite the trip point intialization to use the generic thermal trip Daniel Lezcano
2023-02-03 17:44 ` Daniel Lezcano [this message]
2023-02-04 5:10 ` [PATCH v2 11/11] thermal/acpi: Use the thermal framework ACPI API kernel test robot
2023-02-04 7:54 ` kernel test robot
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=20230203174429.3375691-12-daniel.lezcano@linaro.org \
--to=daniel.lezcano@linaro.org \
--cc=daniel.lezcano@kernel.org \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=rjw@rjwysocki.net \
--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®