1 #ifndef __BACKPORT_LINUX_THERMAL_H
2 #define __BACKPORT_LINUX_THERMAL_H
3 #include_next <linux/thermal.h>
4 #include <linux/version.h>
6 #if LINUX_VERSION_IS_LESS(3,8,0)
7 #include <linux/errno.h>
9 struct thermal_bind_params
{
10 struct thermal_cooling_device
*cdev
;
13 int (*match
)(struct thermal_zone_device
*tz
,
14 struct thermal_cooling_device
*cdev
);
17 struct thermal_zone_params
{
19 struct thermal_bind_params
*tbp
;
22 static inline struct thermal_zone_device
*
23 backport_thermal_zone_device_register(const char *type
, int trips
, int mask
,
25 struct thermal_zone_device_ops
*ops
,
26 const struct thermal_zone_params
*tzp
,
27 int passive_delay
, int polling_delay
)
29 return ERR_PTR(-EOPNOTSUPP
);
31 #define thermal_zone_device_register backport_thermal_zone_device_register
33 static inline void thermal_notify_framework(struct thermal_zone_device
*tz
,
38 #if LINUX_VERSION_IS_LESS(3,10,0)
39 #define thermal_notify_framework notify_thermal_framework
40 #endif /* LINUX_VERSION_IS_LESS(3,10,0) */
42 #if LINUX_VERSION_IS_LESS(4,3,0)
44 typedef struct thermal_zone_device_ops old_thermal_zone_device_ops_t
;
46 /* also add a way to call the old register and unregister functions */
47 static inline struct thermal_zone_device
*old_thermal_zone_device_register(
48 const char *type
, int trips
, int mask
, void *devdata
,
49 old_thermal_zone_device_ops_t
*_ops
,
50 const struct thermal_zone_params
*_tzp
,
51 int passive_delay
, int polling_delay
)
53 struct thermal_zone_device_ops
*ops
=
54 (struct thermal_zone_device_ops
*) _ops
;
56 /* cast the const away */
57 struct thermal_zone_params
*tzp
=
58 (struct thermal_zone_params
*)_tzp
;
60 return thermal_zone_device_register(type
, trips
, mask
, devdata
,
61 ops
, tzp
, passive_delay
,
66 void old_thermal_zone_device_unregister(struct thermal_zone_device
*dev
)
68 thermal_zone_device_unregister(dev
);
71 struct backport_thermal_zone_device_ops
{
72 int (*bind
) (struct thermal_zone_device
*,
73 struct thermal_cooling_device
*);
74 int (*unbind
) (struct thermal_zone_device
*,
75 struct thermal_cooling_device
*);
76 int (*get_temp
) (struct thermal_zone_device
*, int *);
77 int (*get_mode
) (struct thermal_zone_device
*,
78 enum thermal_device_mode
*);
79 int (*set_mode
) (struct thermal_zone_device
*,
80 enum thermal_device_mode
);
81 int (*get_trip_type
) (struct thermal_zone_device
*, int,
82 enum thermal_trip_type
*);
83 int (*get_trip_temp
) (struct thermal_zone_device
*, int, int *);
84 int (*set_trip_temp
) (struct thermal_zone_device
*, int, int);
85 int (*get_trip_hyst
) (struct thermal_zone_device
*, int, int *);
86 int (*set_trip_hyst
) (struct thermal_zone_device
*, int, int);
87 int (*get_crit_temp
) (struct thermal_zone_device
*, int *);
88 int (*set_emul_temp
) (struct thermal_zone_device
*, int);
89 int (*get_trend
) (struct thermal_zone_device
*, int,
90 enum thermal_trend
*);
91 int (*notify
) (struct thermal_zone_device
*, int,
92 enum thermal_trip_type
);
94 #define thermal_zone_device_ops LINUX_BACKPORT(thermal_zone_device_ops)
96 #undef thermal_zone_device_register
97 struct thermal_zone_device
*backport_thermal_zone_device_register(
98 const char *type
, int trips
, int mask
, void *devdata
,
99 struct thermal_zone_device_ops
*ops
,
100 const struct thermal_zone_params
*tzp
,
101 int passive_delay
, int polling_delay
);
103 #define thermal_zone_device_register \
104 LINUX_BACKPORT(thermal_zone_device_register)
106 #undef thermal_zone_device_unregister
107 void backport_thermal_zone_device_unregister(struct thermal_zone_device
*);
108 #define thermal_zone_device_unregister \
109 LINUX_BACKPORT(thermal_zone_device_unregister)
111 #endif /* LINUX_VERSION_IS_LESS(4,3,0) */
112 #endif /* ! < 3.8.0 */
114 #endif /* __BACKPORT_LINUX_THERMAL_H */