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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20230525140135.3589917-8-daniel.lezcano@linaro.org>
Date:   Thu, 25 May 2023 16:01:34 +0200
From:   Daniel Lezcano <daniel.lezcano@...aro.org>
To:     daniel.lezcano@...aro.org, rafael@...nel.org
Cc:     linux-pm@...r.kernel.org, thierry.reding@...il.com,
        Amit Kucheria <amitk@...nel.org>,
        Zhang Rui <rui.zhang@...el.com>,
        Srinivas Pandruvada <srinivas.pandruvada@...ux.intel.com>,
        Baolin Wang <baolin.wang@...ux.alibaba.com>,
        linux-kernel@...r.kernel.org (open list)
Subject: [PATCH 7/8] thermal/drivers/int340x: Use thermal zone device trip update

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@...aro.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ