All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] thermal/drivers/intel: Use generic trip points for quark_dts
@ 2023-01-18 18:16 Daniel Lezcano
  2023-01-18 18:16 ` [PATCH 2/3] thermal/drivers/intel: Use generic trip points for processor_thermal_device_pci Daniel Lezcano
                   ` (2 more replies)
  0 siblings, 3 replies; 27+ messages in thread
From: Daniel Lezcano @ 2023-01-18 18:16 UTC (permalink / raw)
  To: daniel.lezcano, rafael
  Cc: srinivas.pandruvada, linux-pm, linux-kernel, rui.zhang, Amit Kucheria

The thermal framework gives the possibility to register the trip
points with the thermal zone. When that is done, no get_trip_* ops are
needed and they can be removed.

Convert ops content logic into generic trip points and register them with the
thermal zone.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 .../thermal/intel/intel_quark_dts_thermal.c   | 56 +++++++++----------
 1 file changed, 25 insertions(+), 31 deletions(-)

diff --git a/drivers/thermal/intel/intel_quark_dts_thermal.c b/drivers/thermal/intel/intel_quark_dts_thermal.c
index 3eafc6b0e6c3..4e1d1799ec22 100644
--- a/drivers/thermal/intel/intel_quark_dts_thermal.c
+++ b/drivers/thermal/intel/intel_quark_dts_thermal.c
@@ -84,6 +84,7 @@
 #define QRK_DTS_MASK_TP_THRES		0xFF
 #define QRK_DTS_SHIFT_TP		8
 #define QRK_DTS_ID_TP_CRITICAL		0
+#define QRK_DTS_ID_TP_HOT		1
 #define QRK_DTS_SAFE_TP_THRES		105
 
 /* Thermal Sensor Register Lock */
@@ -104,6 +105,7 @@ struct soc_sensor_entry {
 	u32 store_ptps;
 	u32 store_dts_enable;
 	struct thermal_zone_device *tzone;
+	struct thermal_trip trips[QRK_MAX_DTS_TRIPS];
 };
 
 static struct soc_sensor_entry *soc_dts;
@@ -172,7 +174,7 @@ static int soc_dts_disable(struct thermal_zone_device *tzd)
 	return ret;
 }
 
-static int _get_trip_temp(int trip, int *temp)
+static int get_trip_temp(int trip, int *temp)
 {
 	int status;
 	u32 out;
@@ -197,17 +199,6 @@ static int _get_trip_temp(int trip, int *temp)
 	return 0;
 }
 
-static inline int sys_get_trip_temp(struct thermal_zone_device *tzd,
-				int trip, int *temp)
-{
-	return _get_trip_temp(trip, temp);
-}
-
-static inline int sys_get_crit_temp(struct thermal_zone_device *tzd, int *temp)
-{
-	return _get_trip_temp(QRK_DTS_ID_TP_CRITICAL, temp);
-}
-
 static int update_trip_temp(struct soc_sensor_entry *aux_entry,
 				int trip, int temp)
 {
@@ -262,17 +253,6 @@ static inline int sys_set_trip_temp(struct thermal_zone_device *tzd, int trip,
 	return update_trip_temp(tzd->devdata, trip, temp);
 }
 
-static int sys_get_trip_type(struct thermal_zone_device *thermal,
-		int trip, enum thermal_trip_type *type)
-{
-	if (trip)
-		*type = THERMAL_TRIP_HOT;
-	else
-		*type = THERMAL_TRIP_CRITICAL;
-
-	return 0;
-}
-
 static int sys_get_curr_temp(struct thermal_zone_device *tzd,
 				int *temp)
 {
@@ -315,10 +295,7 @@ static int sys_change_mode(struct thermal_zone_device *tzd,
 
 static struct thermal_zone_device_ops tzone_ops = {
 	.get_temp = sys_get_curr_temp,
-	.get_trip_temp = sys_get_trip_temp,
-	.get_trip_type = sys_get_trip_type,
 	.set_trip_temp = sys_set_trip_temp,
-	.get_crit_temp = sys_get_crit_temp,
 	.change_mode = sys_change_mode,
 };
 
@@ -344,7 +321,7 @@ static void free_soc_dts(struct soc_sensor_entry *aux_entry)
 static struct soc_sensor_entry *alloc_soc_dts(void)
 {
 	struct soc_sensor_entry *aux_entry;
-	int err;
+	int err, temperature;
 	u32 out;
 	int wr_mask;
 
@@ -385,10 +362,27 @@ static struct soc_sensor_entry *alloc_soc_dts(void)
 			goto err_ret;
 	}
 
-	aux_entry->tzone = thermal_zone_device_register("quark_dts",
-			QRK_MAX_DTS_TRIPS,
-			wr_mask,
-			aux_entry, &tzone_ops, NULL, 0, polling_delay);
+	err = get_trip_temp(QRK_DTS_ID_TP_CRITICAL, &temperature);
+	if (err)
+		goto err_ret;
+
+	aux_entry->trips[QRK_DTS_ID_TP_CRITICAL].temperature = temperature;
+	aux_entry->trips[QRK_DTS_ID_TP_CRITICAL].type = THERMAL_TRIP_CRITICAL;
+
+	err = get_trip_temp(QRK_DTS_ID_TP_HOT, &temperature);
+	if (err)
+		goto err_ret;
+
+	aux_entry->trips[QRK_DTS_ID_TP_HOT].temperature = temperature;
+	aux_entry->trips[QRK_DTS_ID_TP_HOT].type = THERMAL_TRIP_HOT;
+
+	aux_entry->tzone =
+		thermal_zone_device_register_with_trips("quark_dts",
+							aux_entry->trips,
+							QRK_MAX_DTS_TRIPS,
+							wr_mask,
+							aux_entry, &tzone_ops,
+							NULL, 0, polling_delay);
 	if (IS_ERR(aux_entry->tzone)) {
 		err = PTR_ERR(aux_entry->tzone);
 		goto err_ret;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2023-02-02 15:55 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-18 18:16 [PATCH 1/3] thermal/drivers/intel: Use generic trip points for quark_dts Daniel Lezcano
2023-01-18 18:16 ` [PATCH 2/3] thermal/drivers/intel: Use generic trip points for processor_thermal_device_pci Daniel Lezcano
2023-01-18 19:09   ` srinivas pandruvada
2023-01-23 18:02     ` Daniel Lezcano
2023-01-23 19:31       ` srinivas pandruvada
2023-01-26 15:18   ` Rafael J. Wysocki
2023-01-18 18:16 ` [PATCH 3/3] thermal/drivers/intel: Use generic trip points for intel_soc_dts_iosf Daniel Lezcano
2023-01-19 20:04   ` Rafael J. Wysocki
2023-01-23 18:09     ` Daniel Lezcano
2023-01-23 20:19       ` Rafael J. Wysocki
2023-01-24 10:28         ` Daniel Lezcano
2023-01-24 14:09           ` Rafael J. Wysocki
2023-01-26 16:47   ` Rafael J. Wysocki
2023-01-31 17:03     ` Daniel Lezcano
2023-01-31 19:17       ` Rafael J. Wysocki
2023-02-02 14:36         ` Daniel Lezcano
2023-02-02 14:43           ` Rafael J. Wysocki
2023-02-02 15:54             ` Daniel Lezcano
2023-01-26 14:15 ` [PATCH 1/3] thermal/drivers/intel: Use generic trip points for quark_dts Rafael J. Wysocki
2023-01-31 16:41   ` Daniel Lezcano
2023-01-31 19:11     ` Rafael J. Wysocki
2023-01-31 23:55       ` Daniel Lezcano
2023-02-01 10:42       ` Daniel Lezcano
2023-02-01 18:47         ` Rafael J. Wysocki
2023-02-01 19:27           ` Daniel Lezcano
2023-02-02 10:32             ` Rafael J. Wysocki
2023-02-02 13:31               ` Daniel Lezcano

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.