108a8cfee44f616546e0dfc8c78889a7d292a509
[openwrt/staging/blogic.git] / backport / backport-include / linux / thermal.h
1 #ifndef __BACKPORT_LINUX_THERMAL_H
2 #define __BACKPORT_LINUX_THERMAL_H
3 #include_next <linux/thermal.h>
4 #include <linux/version.h>
5
6 #if LINUX_VERSION_IS_LESS(3,8,0)
7 #include <linux/errno.h>
8
9 struct thermal_bind_params {
10 struct thermal_cooling_device *cdev;
11 int weight;
12 int trip_mask;
13 int (*match)(struct thermal_zone_device *tz,
14 struct thermal_cooling_device *cdev);
15 };
16
17 struct thermal_zone_params {
18 int num_tbps;
19 struct thermal_bind_params *tbp;
20 };
21
22 static inline struct thermal_zone_device *
23 backport_thermal_zone_device_register(const char *type, int trips, int mask,
24 void *devdata,
25 struct thermal_zone_device_ops *ops,
26 const struct thermal_zone_params *tzp,
27 int passive_delay, int polling_delay)
28 {
29 return ERR_PTR(-EOPNOTSUPP);
30 }
31 #define thermal_zone_device_register backport_thermal_zone_device_register
32
33 static inline void thermal_notify_framework(struct thermal_zone_device *tz,
34 int trip)
35 { }
36 #else /* < 3.8.0 */
37
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) */
41
42 #if LINUX_VERSION_IS_LESS(4,3,0)
43
44 typedef struct thermal_zone_device_ops old_thermal_zone_device_ops_t;
45
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)
52 {
53 struct thermal_zone_device_ops *ops =
54 (struct thermal_zone_device_ops *) _ops;
55
56 /* cast the const away */
57 struct thermal_zone_params *tzp =
58 (struct thermal_zone_params *)_tzp;
59
60 return thermal_zone_device_register(type, trips, mask, devdata,
61 ops, tzp, passive_delay,
62 polling_delay);
63 }
64
65 static inline
66 void old_thermal_zone_device_unregister(struct thermal_zone_device *dev)
67 {
68 thermal_zone_device_unregister(dev);
69 }
70
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);
93 };
94 #define thermal_zone_device_ops LINUX_BACKPORT(thermal_zone_device_ops)
95
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);
102
103 #define thermal_zone_device_register \
104 LINUX_BACKPORT(thermal_zone_device_register)
105
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)
110
111 #endif /* LINUX_VERSION_IS_LESS(4,3,0) */
112 #endif /* ! < 3.8.0 */
113
114 #endif /* __BACKPORT_LINUX_THERMAL_H */