]>
Commit | Line | Data |
---|---|---|
0db643ce SS |
1 | From fd06998396d631f028fd8f8d7bcb2b442c578292 Mon Sep 17 00:00:00 2001 |
2 | From: Johannes Berg <johannes@sipsolutions.net> | |
3 | Date: Thu, 8 Jan 2015 09:02:42 +0100 | |
4 | Subject: use uapi rfkill.h | |
5 | ||
6 | --- | |
7 | rfkill.h | 295 ++------------------------------------------------------------- | |
8 | 1 file changed, 6 insertions(+), 289 deletions(-) | |
9 | ||
10 | diff --git a/rfkill.h b/rfkill.h | |
11 | index d253b4e..058757f 100644 | |
12 | --- a/rfkill.h | |
13 | +++ b/rfkill.h | |
14 | @@ -1,6 +1,3 @@ | |
15 | -#ifndef __RFKILL_H | |
16 | -#define __RFKILL_H | |
17 | - | |
18 | /* | |
19 | * Copyright (C) 2006 - 2007 Ivo van Doorn | |
20 | * Copyright (C) 2007 Dmitry Torokhov | |
21 | @@ -18,6 +15,9 @@ | |
22 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |
23 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
24 | */ | |
25 | +#ifndef _UAPI__RFKILL_H | |
26 | +#define _UAPI__RFKILL_H | |
27 | + | |
28 | ||
29 | #include <linux/types.h> | |
30 | ||
31 | @@ -29,7 +29,7 @@ | |
32 | /** | |
33 | * enum rfkill_type - type of rfkill switch. | |
34 | * | |
35 | - * @RFKILL_TYPE_ALL: toggles all switches (userspace only) | |
36 | + * @RFKILL_TYPE_ALL: toggles all switches (requests only - not a switch type) | |
37 | * @RFKILL_TYPE_WLAN: switch is on a 802.11 wireless network device. | |
38 | * @RFKILL_TYPE_BLUETOOTH: switch is on a bluetooth device. | |
39 | * @RFKILL_TYPE_UWB: switch is on a ultra wideband device. | |
40 | @@ -83,7 +83,7 @@ struct rfkill_event { | |
41 | __u8 type; | |
42 | __u8 op; | |
43 | __u8 soft, hard; | |
44 | -} __packed; | |
45 | +} __attribute__((packed)); | |
46 | ||
47 | /* | |
48 | * We are planning to be backward and forward compatible with changes | |
49 | @@ -105,288 +105,5 @@ struct rfkill_event { | |
50 | #define RFKILL_IOCTL_NOINPUT _IO(RFKILL_IOC_MAGIC, RFKILL_IOC_NOINPUT) | |
51 | ||
52 | /* and that's all userspace gets */ | |
53 | -#ifdef __KERNEL__ | |
54 | -/* don't allow anyone to use these in the kernel */ | |
55 | -enum rfkill_user_states { | |
56 | - RFKILL_USER_STATE_SOFT_BLOCKED = RFKILL_STATE_SOFT_BLOCKED, | |
57 | - RFKILL_USER_STATE_UNBLOCKED = RFKILL_STATE_UNBLOCKED, | |
58 | - RFKILL_USER_STATE_HARD_BLOCKED = RFKILL_STATE_HARD_BLOCKED, | |
59 | -}; | |
60 | -#undef RFKILL_STATE_SOFT_BLOCKED | |
61 | -#undef RFKILL_STATE_UNBLOCKED | |
62 | -#undef RFKILL_STATE_HARD_BLOCKED | |
63 | - | |
64 | -#include <linux/kernel.h> | |
65 | -#include <linux/list.h> | |
66 | -#include <linux/mutex.h> | |
67 | -#include <linux/device.h> | |
68 | -#include <linux/leds.h> | |
69 | -#include <linux/err.h> | |
70 | - | |
71 | -/* this is opaque */ | |
72 | -struct rfkill; | |
73 | - | |
74 | -/** | |
75 | - * struct rfkill_ops - rfkill driver methods | |
76 | - * | |
77 | - * @poll: poll the rfkill block state(s) -- only assign this method | |
78 | - * when you need polling. When called, simply call one of the | |
79 | - * rfkill_set{,_hw,_sw}_state family of functions. If the hw | |
80 | - * is getting unblocked you need to take into account the return | |
81 | - * value of those functions to make sure the software block is | |
82 | - * properly used. | |
83 | - * @query: query the rfkill block state(s) and call exactly one of the | |
84 | - * rfkill_set{,_hw,_sw}_state family of functions. Assign this | |
85 | - * method if input events can cause hardware state changes to make | |
86 | - * the rfkill core query your driver before setting a requested | |
87 | - * block. | |
88 | - * @set_block: turn the transmitter on (blocked == false) or off | |
89 | - * (blocked == true) -- ignore and return 0 when hard blocked. | |
90 | - * This callback must be assigned. | |
91 | - */ | |
92 | -struct rfkill_ops { | |
93 | - void (*poll)(struct rfkill *rfkill, void *data); | |
94 | - void (*query)(struct rfkill *rfkill, void *data); | |
95 | - int (*set_block)(void *data, bool blocked); | |
96 | -}; | |
97 | - | |
98 | -#if defined(CONFIG_RFKILL) || defined(CONFIG_RFKILL_MODULE) | |
99 | -/** | |
100 | - * rfkill_alloc - allocate rfkill structure | |
101 | - * @name: name of the struct -- the string is not copied internally | |
102 | - * @parent: device that has rf switch on it | |
103 | - * @type: type of the switch (RFKILL_TYPE_*) | |
104 | - * @ops: rfkill methods | |
105 | - * @ops_data: data passed to each method | |
106 | - * | |
107 | - * This function should be called by the transmitter driver to allocate an | |
108 | - * rfkill structure. Returns %NULL on failure. | |
109 | - */ | |
110 | -struct rfkill * __must_check rfkill_alloc(const char *name, | |
111 | - struct device *parent, | |
112 | - const enum rfkill_type type, | |
113 | - const struct rfkill_ops *ops, | |
114 | - void *ops_data); | |
115 | - | |
116 | -/** | |
117 | - * rfkill_register - Register a rfkill structure. | |
118 | - * @rfkill: rfkill structure to be registered | |
119 | - * | |
120 | - * This function should be called by the transmitter driver to register | |
121 | - * the rfkill structure. Before calling this function the driver needs | |
122 | - * to be ready to service method calls from rfkill. | |
123 | - * | |
124 | - * If rfkill_init_sw_state() is not called before registration, | |
125 | - * set_block() will be called to initialize the software blocked state | |
126 | - * to a default value. | |
127 | - * | |
128 | - * If the hardware blocked state is not set before registration, | |
129 | - * it is assumed to be unblocked. | |
130 | - */ | |
131 | -int __must_check rfkill_register(struct rfkill *rfkill); | |
132 | - | |
133 | -/** | |
134 | - * rfkill_pause_polling(struct rfkill *rfkill) | |
135 | - * | |
136 | - * Pause polling -- say transmitter is off for other reasons. | |
137 | - * NOTE: not necessary for suspend/resume -- in that case the | |
138 | - * core stops polling anyway | |
139 | - */ | |
140 | -void rfkill_pause_polling(struct rfkill *rfkill); | |
141 | - | |
142 | -/** | |
143 | - * rfkill_resume_polling(struct rfkill *rfkill) | |
144 | - * | |
145 | - * Pause polling -- say transmitter is off for other reasons. | |
146 | - * NOTE: not necessary for suspend/resume -- in that case the | |
147 | - * core stops polling anyway | |
148 | - */ | |
149 | -void rfkill_resume_polling(struct rfkill *rfkill); | |
150 | - | |
151 | - | |
152 | -/** | |
153 | - * rfkill_unregister - Unregister a rfkill structure. | |
154 | - * @rfkill: rfkill structure to be unregistered | |
155 | - * | |
156 | - * This function should be called by the network driver during device | |
157 | - * teardown to destroy rfkill structure. Until it returns, the driver | |
158 | - * needs to be able to service method calls. | |
159 | - */ | |
160 | -void rfkill_unregister(struct rfkill *rfkill); | |
161 | - | |
162 | -/** | |
163 | - * rfkill_destroy - free rfkill structure | |
164 | - * @rfkill: rfkill structure to be destroyed | |
165 | - * | |
166 | - * Destroys the rfkill structure. | |
167 | - */ | |
168 | -void rfkill_destroy(struct rfkill *rfkill); | |
169 | - | |
170 | -/** | |
171 | - * rfkill_set_hw_state - Set the internal rfkill hardware block state | |
172 | - * @rfkill: pointer to the rfkill class to modify. | |
173 | - * @state: the current hardware block state to set | |
174 | - * | |
175 | - * rfkill drivers that get events when the hard-blocked state changes | |
176 | - * use this function to notify the rfkill core (and through that also | |
177 | - * userspace) of the current state. They should also use this after | |
178 | - * resume if the state could have changed. | |
179 | - * | |
180 | - * You need not (but may) call this function if poll_state is assigned. | |
181 | - * | |
182 | - * This function can be called in any context, even from within rfkill | |
183 | - * callbacks. | |
184 | - * | |
185 | - * The function returns the combined block state (true if transmitter | |
186 | - * should be blocked) so that drivers need not keep track of the soft | |
187 | - * block state -- which they might not be able to. | |
188 | - */ | |
189 | -bool rfkill_set_hw_state(struct rfkill *rfkill, bool blocked); | |
190 | - | |
191 | -/** | |
192 | - * rfkill_set_sw_state - Set the internal rfkill software block state | |
193 | - * @rfkill: pointer to the rfkill class to modify. | |
194 | - * @state: the current software block state to set | |
195 | - * | |
196 | - * rfkill drivers that get events when the soft-blocked state changes | |
197 | - * (yes, some platforms directly act on input but allow changing again) | |
198 | - * use this function to notify the rfkill core (and through that also | |
199 | - * userspace) of the current state. | |
200 | - * | |
201 | - * Drivers should also call this function after resume if the state has | |
202 | - * been changed by the user. This only makes sense for "persistent" | |
203 | - * devices (see rfkill_init_sw_state()). | |
204 | - * | |
205 | - * This function can be called in any context, even from within rfkill | |
206 | - * callbacks. | |
207 | - * | |
208 | - * The function returns the combined block state (true if transmitter | |
209 | - * should be blocked). | |
210 | - */ | |
211 | -bool rfkill_set_sw_state(struct rfkill *rfkill, bool blocked); | |
212 | - | |
213 | -/** | |
214 | - * rfkill_init_sw_state - Initialize persistent software block state | |
215 | - * @rfkill: pointer to the rfkill class to modify. | |
216 | - * @state: the current software block state to set | |
217 | - * | |
218 | - * rfkill drivers that preserve their software block state over power off | |
219 | - * use this function to notify the rfkill core (and through that also | |
220 | - * userspace) of their initial state. It should only be used before | |
221 | - * registration. | |
222 | - * | |
223 | - * In addition, it marks the device as "persistent", an attribute which | |
224 | - * can be read by userspace. Persistent devices are expected to preserve | |
225 | - * their own state when suspended. | |
226 | - */ | |
227 | -void rfkill_init_sw_state(struct rfkill *rfkill, bool blocked); | |
228 | - | |
229 | -/** | |
230 | - * rfkill_set_states - Set the internal rfkill block states | |
231 | - * @rfkill: pointer to the rfkill class to modify. | |
232 | - * @sw: the current software block state to set | |
233 | - * @hw: the current hardware block state to set | |
234 | - * | |
235 | - * This function can be called in any context, even from within rfkill | |
236 | - * callbacks. | |
237 | - */ | |
238 | -void rfkill_set_states(struct rfkill *rfkill, bool sw, bool hw); | |
239 | - | |
240 | -/** | |
241 | - * rfkill_blocked - query rfkill block | |
242 | - * | |
243 | - * @rfkill: rfkill struct to query | |
244 | - */ | |
245 | -bool rfkill_blocked(struct rfkill *rfkill); | |
246 | -#else /* !RFKILL */ | |
247 | -static inline struct rfkill * __must_check | |
248 | -rfkill_alloc(const char *name, | |
249 | - struct device *parent, | |
250 | - const enum rfkill_type type, | |
251 | - const struct rfkill_ops *ops, | |
252 | - void *ops_data) | |
253 | -{ | |
254 | - return ERR_PTR(-ENODEV); | |
255 | -} | |
256 | - | |
257 | -static inline int __must_check rfkill_register(struct rfkill *rfkill) | |
258 | -{ | |
259 | - if (rfkill == ERR_PTR(-ENODEV)) | |
260 | - return 0; | |
261 | - return -EINVAL; | |
262 | -} | |
263 | - | |
264 | -static inline void rfkill_pause_polling(struct rfkill *rfkill) | |
265 | -{ | |
266 | -} | |
267 | - | |
268 | -static inline void rfkill_resume_polling(struct rfkill *rfkill) | |
269 | -{ | |
270 | -} | |
271 | - | |
272 | -static inline void rfkill_unregister(struct rfkill *rfkill) | |
273 | -{ | |
274 | -} | |
275 | - | |
276 | -static inline void rfkill_destroy(struct rfkill *rfkill) | |
277 | -{ | |
278 | -} | |
279 | - | |
280 | -static inline bool rfkill_set_hw_state(struct rfkill *rfkill, bool blocked) | |
281 | -{ | |
282 | - return blocked; | |
283 | -} | |
284 | - | |
285 | -static inline bool rfkill_set_sw_state(struct rfkill *rfkill, bool blocked) | |
286 | -{ | |
287 | - return blocked; | |
288 | -} | |
289 | - | |
290 | -static inline void rfkill_init_sw_state(struct rfkill *rfkill, bool blocked) | |
291 | -{ | |
292 | -} | |
293 | - | |
294 | -static inline void rfkill_set_states(struct rfkill *rfkill, bool sw, bool hw) | |
295 | -{ | |
296 | -} | |
297 | - | |
298 | -static inline bool rfkill_blocked(struct rfkill *rfkill) | |
299 | -{ | |
300 | - return false; | |
301 | -} | |
302 | -#endif /* RFKILL || RFKILL_MODULE */ | |
303 | - | |
304 | - | |
305 | -#ifdef CONFIG_RFKILL_LEDS | |
306 | -/** | |
307 | - * rfkill_get_led_trigger_name - Get the LED trigger name for the button's LED. | |
308 | - * This function might return a NULL pointer if registering of the | |
309 | - * LED trigger failed. Use this as "default_trigger" for the LED. | |
310 | - */ | |
311 | -const char *rfkill_get_led_trigger_name(struct rfkill *rfkill); | |
312 | - | |
313 | -/** | |
314 | - * rfkill_set_led_trigger_name -- set the LED trigger name | |
315 | - * @rfkill: rfkill struct | |
316 | - * @name: LED trigger name | |
317 | - * | |
318 | - * This function sets the LED trigger name of the radio LED | |
319 | - * trigger that rfkill creates. It is optional, but if called | |
320 | - * must be called before rfkill_register() to be effective. | |
321 | - */ | |
322 | -void rfkill_set_led_trigger_name(struct rfkill *rfkill, const char *name); | |
323 | -#else | |
324 | -static inline const char *rfkill_get_led_trigger_name(struct rfkill *rfkill) | |
325 | -{ | |
326 | - return NULL; | |
327 | -} | |
328 | - | |
329 | -static inline void | |
330 | -rfkill_set_led_trigger_name(struct rfkill *rfkill, const char *name) | |
331 | -{ | |
332 | -} | |
333 | -#endif | |
334 | - | |
335 | -#endif /* __KERNEL__ */ | |
336 | ||
337 | -#endif /* RFKILL_H */ | |
338 | +#endif /* _UAPI__RFKILL_H */ | |
339 | -- | |
340 | cgit v1.2.1 | |
341 |