From: Miri Korenblit <miriam.rachel.korenblit@xxxxxxxxx> - backport struct thermal_trip also for kernel versions 5.10-, to have the flags field. - backport for_each_thermal_trip also for kernel versions [6.6, 6.9), Since for this kernels we use the backported thermal_trip struct Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@xxxxxxxxx> Signed-off-by: Johannes Berg <johannes.berg@xxxxxxxxx> --- backport/backport-include/linux/thermal.h | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/backport/backport-include/linux/thermal.h b/backport/backport-include/linux/thermal.h index 942883dc1f40..546caca8108c 100644 --- a/backport/backport-include/linux/thermal.h +++ b/backport/backport-include/linux/thermal.h @@ -14,8 +14,8 @@ static inline int thermal_zone_device_disable(struct thermal_zone_device *tz) { return 0; } #endif /* < 5.9 */ -#if LINUX_VERSION_IS_LESS(6,9,0) && LINUX_VERSION_IS_GEQ(5,10,0) -struct thermal_trip { +#if LINUX_VERSION_IS_LESS(6,9,0) +struct backport_thermal_trip { int temperature; int hysteresis; int threshold; @@ -23,10 +23,11 @@ struct thermal_trip { u8 flags; void *priv; }; -#endif +#define thermal_trip backport_thermal_trip -#if LINUX_VERSION_IS_LESS(6,9,0) #define THERMAL_TRIP_FLAG_RW_TEMP BIT(0) + +#define thermal_zone_device_register_with_trips LINUX_BACKPORT(thermal_zone_device_register_with_trips) struct thermal_zone_device * thermal_zone_device_register_with_trips(const char *type, struct thermal_trip *trips, @@ -37,15 +38,18 @@ thermal_zone_device_register_with_trips(const char *type, int polling_delay); #endif /* <6,9,0 */ -#if LINUX_VERSION_IS_LESS(6,6,0) && LINUX_VERSION_IS_GEQ(6,0,0) +#if LINUX_VERSION_IS_LESS(6,9,0) && LINUX_VERSION_IS_GEQ(6,0,0) +#define for_each_thermal_trip LINUX_BACKPORT(for_each_thermal_trip) static inline int for_each_thermal_trip(struct thermal_zone_device *tz, int (*cb)(struct thermal_trip *, void *), void *data) { + struct thermal_trip *trip; + struct thermal_trip *trips = (void *)tz->trips; int ret; - for (trip = tz->trips; trip - tz->trips < tz->num_trips; trip++) { + for (trip = trips; trip - trips < tz->num_trips; trip++) { ret = cb(trip, data); if (ret) return ret; @@ -53,7 +57,7 @@ int for_each_thermal_trip(struct thermal_zone_device *tz, return 0; } -#endif /* < 6,6,0 && >= 6,0,0 */ +#endif /* < 6,9,0 && >= 6,0,0 */ /* for < 6,0,0 the trips are invalid anyway*/ #if LINUX_VERSION_IS_LESS(6,0,0) -- 2.45.1