From: Daniel Lezcano <daniel.lezcano@linaro.org>
To: daniel.lezcano@linaro.org, rafael@kernel.org
Cc: linux-pm@vger.kernel.org, thierry.reding@gmail.com,
Amit Kucheria <amitk@kernel.org>, Zhang Rui <rui.zhang@intel.com>,
Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>,
Baolin Wang <baolin.wang@linux.alibaba.com>,
linux-kernel@vger.kernel.org (open list)
Subject: [PATCH 7/8] thermal/drivers/int340x: Use thermal zone device trip update
Date: Thu, 25 May 2023 16:01:34 +0200 [thread overview]
Message-ID: <20230525140135.3589917-8-daniel.lezcano@linaro.org> (raw)
In-Reply-To: <20230525140135.3589917-1-daniel.lezcano@linaro.org>
The current code takes the thermal zone device lock to update the
thermal trips.
Now we have an API allowing to update the thermal trip directly, so
use it and get ride of the thermal zone lock access.
Take also the opportunity to use the zone>-type accessor.
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
.../int340x_thermal/int340x_thermal_zone.c | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c b/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c
index 89cf007146ea..94697063f41e 100644
--- a/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c
+++ b/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c
@@ -58,7 +58,8 @@ static int int340x_thermal_set_trip_temp(struct thermal_zone_device *zone,
static void int340x_thermal_critical(struct thermal_zone_device *zone)
{
- dev_dbg(&zone->device, "%s: critical temperature reached\n", zone->type);
+ dev_dbg(thermal_zone_device(zone), "%s: critical temperature reached\n",
+ thermal_zone_device_type(zone));
}
static struct thermal_zone_device_ops int340x_thermal_zone_ops = {
@@ -215,13 +216,15 @@ EXPORT_SYMBOL_GPL(int340x_thermal_zone_remove);
void int340x_thermal_update_trips(struct int34x_thermal_zone *int34x_zone)
{
struct acpi_device *zone_adev = int34x_zone->adev;
- struct thermal_trip *zone_trips = int34x_zone->trips;
- int trip_cnt = int34x_zone->zone->num_trips;
+ struct thermal_trip *zone_trips;
+ int trip_cnt = thermal_zone_get_num_trips(int34x_zone->zone);
int act_trip_nr = 0;
int i;
- mutex_lock(&int34x_zone->zone->lock);
-
+ zone_trips = kmemdup(int34x_zone->trips, sizeof(*zone_trips) * trip_cnt, GFP_KERNEL);
+ if (!zone_trips)
+ return;
+
for (i = int34x_zone->aux_trip_nr; i < trip_cnt; i++) {
int temp, err;
@@ -250,7 +253,9 @@ void int340x_thermal_update_trips(struct int34x_thermal_zone *int34x_zone)
zone_trips[i].temperature = temp;
}
- mutex_unlock(&int34x_zone->zone->lock);
+ if (!thermal_zone_trips_update(int34x_zone->zone, zone_trips, trip_cnt,
+ GENMASK_ULL((trip_cnt) - 1, 0)))
+ int34x_zone->trips = zone_trips;
}
EXPORT_SYMBOL_GPL(int340x_thermal_update_trips);
--
2.34.1
next prev parent reply other threads:[~2023-05-25 14:02 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-25 14:01 [PATCH 0/8] Finish thermal zone structure encapsulation Daniel Lezcano
2023-05-25 14:01 ` [PATCH 1/8] net/mlx5: Update the driver with the recent thermal changes Daniel Lezcano
2023-05-26 9:20 ` Simon Horman
2023-05-31 22:10 ` Saeed Mahameed
2023-06-07 13:17 ` Daniel Lezcano
2023-05-25 14:01 ` [PATCH 2/8] thermal/core: Hardening the self-encapsulation Daniel Lezcano
2023-05-25 14:01 ` [PATCH 3/8] thermal/core: Reorder the headers inclusion Daniel Lezcano
2023-05-25 14:01 ` [PATCH 4/8] thermal/core: Update the generic trip points Daniel Lezcano
2023-06-20 11:28 ` Rafael J. Wysocki
2023-06-20 18:35 ` Daniel Lezcano
2023-06-23 17:59 ` Rafael J. Wysocki
2023-06-25 20:29 ` Rafael J. Wysocki
2023-05-25 14:01 ` [PATCH 5/8] thermal/drivers/int3400: Use thermal zone device wrappers Daniel Lezcano
2023-07-03 10:49 ` Daniel Lezcano
2023-07-03 16:15 ` srinivas pandruvada
2023-07-05 10:41 ` Daniel Lezcano
2023-07-05 11:35 ` srinivas pandruvada
2023-07-05 11:49 ` Daniel Lezcano
2023-05-25 14:01 ` [PATCH 6/8] thermal/drivers/int340x: Do not check the thermal zone state Daniel Lezcano
2023-05-25 14:01 ` Daniel Lezcano [this message]
2023-05-25 14:01 ` [PATCH 8/8] thermal/core: Move the thermal zone structure to the private core header Daniel Lezcano
2023-06-13 14:12 ` [PATCH 0/8] Finish thermal zone structure encapsulation Daniel Lezcano
2023-06-20 10:54 ` Rafael J. Wysocki
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=20230525140135.3589917-8-daniel.lezcano@linaro.org \
--to=daniel.lezcano@linaro.org \
--cc=amitk@kernel.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=rui.zhang@intel.com \
--cc=srinivas.pandruvada@linux.intel.com \
--cc=thierry.reding@gmail.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;
as well as URLs for NNTP newsgroup(s).