diff mbox series

[42/74] backports: adjust thermal APIs to 6.9

Message ID 20240524190907.b25de3dd9bcf.Ifa45e067fb399ab7fe131a183c462a8a19b867a4@changeid (mailing list archive)
State New, archived
Headers show
Series backport updates from Intel | expand

Commit Message

Johannes Berg May 24, 2024, 5:07 p.m. UTC
From: Miri Korenblit <miriam.rachel.korenblit@intel.com>

- for_each_thermal_trip was added in 6.9, backport it for kernel
  versions that are < 6.9.0 and >= 6.0.0. Kernel versions < 6.0.0
  have the trips internal to the thermal core, so no access to it, on
  the other hand, the local (driver allocated) trips have invalid
  temperature values anyway, so no point iterating those trips,
  so added an empty backport for these kernels.
- struct thermal_trip has a few new fields, add these fields and extend
  the 6.0.0 to 6.9.0
- thermal_zone_device_register_with_trips is no longer supporting the
  mask argument, instead we have:
- THERMAL_TRIP_FLAG_RW_TEMP as a flag of a thermal_trip

Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
 backport/backport-include/linux/thermal.h     | 45 ++++++++++++++++---
 backport/compat/Makefile                      |  2 +-
 .../compat/{backport-6.0.c => backport-6.9.c} |  4 +-
 3 files changed, 42 insertions(+), 9 deletions(-)
 rename backport/compat/{backport-6.0.c => backport-6.9.c} (79%)
diff mbox series

Patch

diff --git a/backport/backport-include/linux/thermal.h b/backport/backport-include/linux/thermal.h
index 39b7ca476a3c..942883dc1f40 100644
--- a/backport/backport-include/linux/thermal.h
+++ b/backport/backport-include/linux/thermal.h
@@ -14,24 +14,57 @@  static inline int thermal_zone_device_disable(struct thermal_zone_device *tz)
 { return 0; }
 #endif /* < 5.9 */
 
-#if LINUX_VERSION_IS_LESS(6,0,0) && LINUX_VERSION_IS_GEQ(5,10,0)
+#if LINUX_VERSION_IS_LESS(6,9,0) && LINUX_VERSION_IS_GEQ(5,10,0)
 struct thermal_trip {
 	int temperature;
 	int hysteresis;
+	int threshold;
 	enum thermal_trip_type type;
+	u8 flags;
+	void *priv;
 };
 #endif
 
-#if LINUX_VERSION_IS_LESS(6,0,0)
+#if LINUX_VERSION_IS_LESS(6,9,0)
+#define THERMAL_TRIP_FLAG_RW_TEMP       BIT(0)
 struct thermal_zone_device *
 thermal_zone_device_register_with_trips(const char *type,
 					struct thermal_trip *trips,
-					int num_trips, int mask, void *devdata,
+					int num_trips, void *devdata,
 					struct thermal_zone_device_ops *ops,
 					struct thermal_zone_params *tzp,
 					int passive_delay,
 					int polling_delay);
-#endif /* <6,0,0 */
+#endif /* <6,9,0 */
+
+#if LINUX_VERSION_IS_LESS(6,6,0) && LINUX_VERSION_IS_GEQ(6,0,0)
+static inline
+int for_each_thermal_trip(struct thermal_zone_device *tz,
+			  int (*cb)(struct thermal_trip *, void *),
+			  void *data)
+{
+	int ret;
+
+	for (trip = tz->trips; trip - tz->trips < tz->num_trips; trip++) {
+		ret = cb(trip, data);
+		if (ret)
+			return ret;
+	}
+
+	return 0;
+}
+#endif /* < 6,6,0 && >= 6,0,0 */
+
+/* for < 6,0,0 the trips are invalid anyway*/
+#if LINUX_VERSION_IS_LESS(6,0,0)
+static inline
+int for_each_thermal_trip(struct thermal_zone_device *tz,
+			  int (*cb)(struct thermal_trip *, void *),
+			  void *data)
+{
+	return 0;
+}
+#endif
 
 #if LINUX_VERSION_IS_LESS(6,4,0)
 #define thermal_zone_device_priv LINUX_BACKPORT(thermal_zone_device_priv)
@@ -51,12 +84,12 @@  static inline int thermal_zone_device_disable(struct thermal_zone_device *tz)
 { return -ENODEV; }
 #endif /* < 5.9 */
 
-#if LINUX_VERSION_IS_LESS(6,0,0)
+#if LINUX_VERSION_IS_LESS(6,9,0)
 #define thermal_zone_device_register_with_trips LINUX_BACKPORT(thermal_zone_device_register_with_trips)
 static inline struct thermal_zone_device *
 thermal_zone_device_register_with_trips(const char *type,
 					struct thermal_trip *trips,
-					int num_trips, int mask, void *devdata,
+					int num_trips, void *devdata,
 					struct thermal_zone_device_ops *ops,
 					struct thermal_zone_params *tzp,
 					int passive_delay,
diff --git a/backport/compat/Makefile b/backport/compat/Makefile
index 30f6180b3dea..bb6fb57edc7e 100644
--- a/backport/compat/Makefile
+++ b/backport/compat/Makefile
@@ -16,7 +16,7 @@  compat-$(CPTCFG_KERNEL_5_10) += backport-5.10.o
 compat-$(CPTCFG_KERNEL_5_11) += backport-5.11.o
 compat-$(CPTCFG_KERNEL_5_13) += backport-5.13.o
 compat-$(CPTCFG_KERNEL_5_15) += backport-5.15.o
-compat-$(CPTCFG_KERNEL_6_0) += backport-6.0.o
+compat-$(CPTCFG_KERNEL_6_9) += backport-6.9.o
 compat-$(CPTCFG_KERNEL_6_5) += backport-6.5.o
 
 compat-$(CPTCFG_BPAUTO_BUILD_SYSTEM_DATA_VERIFICATION) += verification/verify.o
diff --git a/backport/compat/backport-6.0.c b/backport/compat/backport-6.9.c
similarity index 79%
rename from backport/compat/backport-6.0.c
rename to backport/compat/backport-6.9.c
index 7cb699fc0007..6ae485da3975 100644
--- a/backport/compat/backport-6.0.c
+++ b/backport/compat/backport-6.9.c
@@ -7,12 +7,12 @@ 
 struct thermal_zone_device *
 thermal_zone_device_register_with_trips(const char *type,
 					struct thermal_trip *trips,
-					int num_trips, int mask, void *devdata,
+					int num_trips, void *devdata,
 					struct thermal_zone_device_ops *ops,
 					struct thermal_zone_params *tzp, int passive_delay,
 					int polling_delay)
 {
-	return thermal_zone_device_register(type, num_trips, mask, devdata, ops, tzp,
+	return thermal_zone_device_register(type, num_trips, 0, devdata, ops, tzp,
 					    passive_delay, polling_delay);
 }
 EXPORT_SYMBOL_GPL(thermal_zone_device_register_with_trips);