diff options
author | Durgadoss R <durgadoss.r@intel.com> | 2012-09-18 01:34:52 -0400 |
---|---|---|
committer | Zhang Rui <rui.zhang@intel.com> | 2012-11-05 00:56:32 -0500 |
commit | 23064088d6aea049746755e9851760620921a80b (patch) | |
tree | b9c48464c7b8b6cf907ec77d23b8eab3e552cd0d | |
parent | 3d70f8c617a436c7146ecb81df2265b4626dfe89 (diff) |
Thermal: Refactor thermal.h file
This patch rearranges the code in thermal.h file,
in the following order, so that it is easy to
read/maintain.
1. All #defines
2. All enums
3. All fops structures
4. All device structures
5. All function declarations
Signed-off-by: Durgadoss R <durgadoss.r@intel.com>
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
-rw-r--r-- | include/linux/thermal.h | 78 |
1 files changed, 43 insertions, 35 deletions
diff --git a/include/linux/thermal.h b/include/linux/thermal.h index 91b34812cd84..8611e3eba60c 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h | |||
@@ -29,6 +29,23 @@ | |||
29 | #include <linux/device.h> | 29 | #include <linux/device.h> |
30 | #include <linux/workqueue.h> | 30 | #include <linux/workqueue.h> |
31 | 31 | ||
32 | #define THERMAL_TRIPS_NONE -1 | ||
33 | #define THERMAL_MAX_TRIPS 12 | ||
34 | #define THERMAL_NAME_LENGTH 20 | ||
35 | |||
36 | /* No upper/lower limit requirement */ | ||
37 | #define THERMAL_NO_LIMIT -1UL | ||
38 | |||
39 | /* Unit conversion macros */ | ||
40 | #define KELVIN_TO_CELSIUS(t) (long)(((long)t-2732 >= 0) ? \ | ||
41 | ((long)t-2732+5)/10 : ((long)t-2732-5)/10) | ||
42 | #define CELSIUS_TO_KELVIN(t) ((t)*10+2732) | ||
43 | |||
44 | /* Adding event notification support elements */ | ||
45 | #define THERMAL_GENL_FAMILY_NAME "thermal_event" | ||
46 | #define THERMAL_GENL_VERSION 0x01 | ||
47 | #define THERMAL_GENL_MCAST_GROUP_NAME "thermal_mc_group" | ||
48 | |||
32 | struct thermal_zone_device; | 49 | struct thermal_zone_device; |
33 | struct thermal_cooling_device; | 50 | struct thermal_cooling_device; |
34 | 51 | ||
@@ -50,6 +67,30 @@ enum thermal_trend { | |||
50 | THERMAL_TREND_DROPPING, /* temperature is dropping */ | 67 | THERMAL_TREND_DROPPING, /* temperature is dropping */ |
51 | }; | 68 | }; |
52 | 69 | ||
70 | /* Events supported by Thermal Netlink */ | ||
71 | enum events { | ||
72 | THERMAL_AUX0, | ||
73 | THERMAL_AUX1, | ||
74 | THERMAL_CRITICAL, | ||
75 | THERMAL_DEV_FAULT, | ||
76 | }; | ||
77 | |||
78 | /* attributes of thermal_genl_family */ | ||
79 | enum { | ||
80 | THERMAL_GENL_ATTR_UNSPEC, | ||
81 | THERMAL_GENL_ATTR_EVENT, | ||
82 | __THERMAL_GENL_ATTR_MAX, | ||
83 | }; | ||
84 | #define THERMAL_GENL_ATTR_MAX (__THERMAL_GENL_ATTR_MAX - 1) | ||
85 | |||
86 | /* commands supported by the thermal_genl_family */ | ||
87 | enum { | ||
88 | THERMAL_GENL_CMD_UNSPEC, | ||
89 | THERMAL_GENL_CMD_EVENT, | ||
90 | __THERMAL_GENL_CMD_MAX, | ||
91 | }; | ||
92 | #define THERMAL_GENL_CMD_MAX (__THERMAL_GENL_CMD_MAX - 1) | ||
93 | |||
53 | struct thermal_zone_device_ops { | 94 | struct thermal_zone_device_ops { |
54 | int (*bind) (struct thermal_zone_device *, | 95 | int (*bind) (struct thermal_zone_device *, |
55 | struct thermal_cooling_device *); | 96 | struct thermal_cooling_device *); |
@@ -83,11 +124,6 @@ struct thermal_cooling_device_ops { | |||
83 | int (*set_cur_state) (struct thermal_cooling_device *, unsigned long); | 124 | int (*set_cur_state) (struct thermal_cooling_device *, unsigned long); |
84 | }; | 125 | }; |
85 | 126 | ||
86 | #define THERMAL_NO_LIMIT -1UL /* no upper/lower limit requirement */ | ||
87 | |||
88 | #define THERMAL_TRIPS_NONE -1 | ||
89 | #define THERMAL_MAX_TRIPS 12 | ||
90 | #define THERMAL_NAME_LENGTH 20 | ||
91 | struct thermal_cooling_device { | 127 | struct thermal_cooling_device { |
92 | int id; | 128 | int id; |
93 | char type[THERMAL_NAME_LENGTH]; | 129 | char type[THERMAL_NAME_LENGTH]; |
@@ -100,10 +136,6 @@ struct thermal_cooling_device { | |||
100 | struct list_head node; | 136 | struct list_head node; |
101 | }; | 137 | }; |
102 | 138 | ||
103 | #define KELVIN_TO_CELSIUS(t) (long)(((long)t-2732 >= 0) ? \ | ||
104 | ((long)t-2732+5)/10 : ((long)t-2732-5)/10) | ||
105 | #define CELSIUS_TO_KELVIN(t) ((t)*10+2732) | ||
106 | |||
107 | struct thermal_attr { | 139 | struct thermal_attr { |
108 | struct device_attribute attr; | 140 | struct device_attribute attr; |
109 | char name[THERMAL_NAME_LENGTH]; | 141 | char name[THERMAL_NAME_LENGTH]; |
@@ -131,38 +163,13 @@ struct thermal_zone_device { | |||
131 | struct list_head node; | 163 | struct list_head node; |
132 | struct delayed_work poll_queue; | 164 | struct delayed_work poll_queue; |
133 | }; | 165 | }; |
134 | /* Adding event notification support elements */ | ||
135 | #define THERMAL_GENL_FAMILY_NAME "thermal_event" | ||
136 | #define THERMAL_GENL_VERSION 0x01 | ||
137 | #define THERMAL_GENL_MCAST_GROUP_NAME "thermal_mc_group" | ||
138 | |||
139 | enum events { | ||
140 | THERMAL_AUX0, | ||
141 | THERMAL_AUX1, | ||
142 | THERMAL_CRITICAL, | ||
143 | THERMAL_DEV_FAULT, | ||
144 | }; | ||
145 | 166 | ||
146 | struct thermal_genl_event { | 167 | struct thermal_genl_event { |
147 | u32 orig; | 168 | u32 orig; |
148 | enum events event; | 169 | enum events event; |
149 | }; | 170 | }; |
150 | /* attributes of thermal_genl_family */ | ||
151 | enum { | ||
152 | THERMAL_GENL_ATTR_UNSPEC, | ||
153 | THERMAL_GENL_ATTR_EVENT, | ||
154 | __THERMAL_GENL_ATTR_MAX, | ||
155 | }; | ||
156 | #define THERMAL_GENL_ATTR_MAX (__THERMAL_GENL_ATTR_MAX - 1) | ||
157 | |||
158 | /* commands supported by the thermal_genl_family */ | ||
159 | enum { | ||
160 | THERMAL_GENL_CMD_UNSPEC, | ||
161 | THERMAL_GENL_CMD_EVENT, | ||
162 | __THERMAL_GENL_CMD_MAX, | ||
163 | }; | ||
164 | #define THERMAL_GENL_CMD_MAX (__THERMAL_GENL_CMD_MAX - 1) | ||
165 | 171 | ||
172 | /* Function declarations */ | ||
166 | struct thermal_zone_device *thermal_zone_device_register(const char *, int, int, | 173 | struct thermal_zone_device *thermal_zone_device_register(const char *, int, int, |
167 | void *, const struct thermal_zone_device_ops *, int, int); | 174 | void *, const struct thermal_zone_device_ops *, int, int); |
168 | void thermal_zone_device_unregister(struct thermal_zone_device *); | 175 | void thermal_zone_device_unregister(struct thermal_zone_device *); |
@@ -173,6 +180,7 @@ int thermal_zone_bind_cooling_device(struct thermal_zone_device *, int, | |||
173 | int thermal_zone_unbind_cooling_device(struct thermal_zone_device *, int, | 180 | int thermal_zone_unbind_cooling_device(struct thermal_zone_device *, int, |
174 | struct thermal_cooling_device *); | 181 | struct thermal_cooling_device *); |
175 | void thermal_zone_device_update(struct thermal_zone_device *); | 182 | void thermal_zone_device_update(struct thermal_zone_device *); |
183 | |||
176 | struct thermal_cooling_device *thermal_cooling_device_register(char *, void *, | 184 | struct thermal_cooling_device *thermal_cooling_device_register(char *, void *, |
177 | const struct thermal_cooling_device_ops *); | 185 | const struct thermal_cooling_device_ops *); |
178 | void thermal_cooling_device_unregister(struct thermal_cooling_device *); | 186 | void thermal_cooling_device_unregister(struct thermal_cooling_device *); |