diff mbox series

[39/74] backports: handle thermal_zone_device_priv() for kernels < 6.4

Message ID 20240524190907.ba6770df16be.I6eb167fc3c298f366fbee88e246be20c58beb6f4@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: Gregory Greenman <gregory.greenman@intel.com>

This function was added in v6.4-rc1.

Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
 backport/backport-include/linux/thermal.h | 12 ++++++++++++
 backport/compat/backport-6.4.c            |  9 +++++++++
 2 files changed, 21 insertions(+)
diff mbox series

Patch

diff --git a/backport/backport-include/linux/thermal.h b/backport/backport-include/linux/thermal.h
index 76d4f231aa5a..2e0fcb6b3d28 100644
--- a/backport/backport-include/linux/thermal.h
+++ b/backport/backport-include/linux/thermal.h
@@ -13,6 +13,10 @@  static inline int thermal_zone_device_enable(struct thermal_zone_device *tz)
 static inline int thermal_zone_device_disable(struct thermal_zone_device *tz)
 { return 0; }
 #endif /* < 5.9 */
+
+#if LINUX_VERSION_IS_LESS(6,4,0)
+void *thermal_zone_device_priv(struct thermal_zone_device *tzd);
+#endif /* < 6.4.0 */
 #else /* CONFIG_THERMAL */
 #if LINUX_VERSION_IS_LESS(5,9,0)
 #define thermal_zone_device_enable LINUX_BACKPORT(thermal_zone_device_enable)
@@ -23,6 +27,14 @@  static inline int thermal_zone_device_enable(struct thermal_zone_device *tz)
 static inline int thermal_zone_device_disable(struct thermal_zone_device *tz)
 { return -ENODEV; }
 #endif /* < 5.9 */
+
+#if LINUX_VERSION_IS_LESS(6,4,0)
+#define thermal_zone_device_priv LINUX_BACKPORT(thermal_zone_device_priv)
+static inline void *thermal_zone_device_priv(struct thermal_zone_device *tzd)
+{
+	return NULL;
+}
+#endif /* < 6.4.0 */
 #endif /* CONFIG_THERMAL */
 
 #endif /* __BACKPORT_LINUX_THERMAL_H */
diff --git a/backport/compat/backport-6.4.c b/backport/compat/backport-6.4.c
index d26f46ebddde..af872e5de04d 100644
--- a/backport/compat/backport-6.4.c
+++ b/backport/compat/backport-6.4.c
@@ -3,6 +3,7 @@ 
 #include <linux/types.h>
 #include <linux/netdevice.h>
 #include <net/dropreason.h>
+#include <linux/thermal.h>
 
 #if LINUX_VERSION_IS_GEQ(6,2,0) && defined(CONFIG_KUNIT)
 #include <kunit/test.h>
@@ -53,3 +54,11 @@  EXPORT_SYMBOL_GPL(drop_reasons_register_subsys);
 void drop_reasons_unregister_subsys(enum skb_drop_reason_subsys subsys)
 {}
 EXPORT_SYMBOL_GPL(drop_reasons_unregister_subsys);
+
+#ifdef CONFIG_THERMAL
+void *thermal_zone_device_priv(struct thermal_zone_device *tzd)
+{
+	return tzd->devdata;
+}
+EXPORT_SYMBOL_GPL(thermal_zone_device_priv);
+#endif /* CONFIG_THERMAL */