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
7 rfkill.h | 295 ++-------------------------------------------------------------
8 1 file changed, 6 insertions(+), 289 deletions(-)
10 diff --git a/rfkill.h b/rfkill.h
11 index d253b4e..058757f 100644
19 * Copyright (C) 2006 - 2007 Ivo van Doorn
20 * Copyright (C) 2007 Dmitry Torokhov
22 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
23 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
25 +#ifndef _UAPI__RFKILL_H
26 +#define _UAPI__RFKILL_H
29 #include <linux/types.h>
33 * enum rfkill_type - type of rfkill switch.
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 {
45 +} __attribute__((packed));
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)
52 /* and that's all userspace gets */
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,
60 -#undef RFKILL_STATE_SOFT_BLOCKED
61 -#undef RFKILL_STATE_UNBLOCKED
62 -#undef RFKILL_STATE_HARD_BLOCKED
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>
75 - * struct rfkill_ops - rfkill driver methods
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
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
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.
93 - void (*poll)(struct rfkill *rfkill, void *data);
94 - void (*query)(struct rfkill *rfkill, void *data);
95 - int (*set_block)(void *data, bool blocked);
98 -#if defined(CONFIG_RFKILL) || defined(CONFIG_RFKILL_MODULE)
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
107 - * This function should be called by the transmitter driver to allocate an
108 - * rfkill structure. Returns %NULL on failure.
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,
117 - * rfkill_register - Register a rfkill structure.
118 - * @rfkill: rfkill structure to be registered
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.
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.
128 - * If the hardware blocked state is not set before registration,
129 - * it is assumed to be unblocked.
131 -int __must_check rfkill_register(struct rfkill *rfkill);
134 - * rfkill_pause_polling(struct rfkill *rfkill)
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
140 -void rfkill_pause_polling(struct rfkill *rfkill);
143 - * rfkill_resume_polling(struct rfkill *rfkill)
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
149 -void rfkill_resume_polling(struct rfkill *rfkill);
153 - * rfkill_unregister - Unregister a rfkill structure.
154 - * @rfkill: rfkill structure to be unregistered
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.
160 -void rfkill_unregister(struct rfkill *rfkill);
163 - * rfkill_destroy - free rfkill structure
164 - * @rfkill: rfkill structure to be destroyed
166 - * Destroys the rfkill structure.
168 -void rfkill_destroy(struct rfkill *rfkill);
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
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.
180 - * You need not (but may) call this function if poll_state is assigned.
182 - * This function can be called in any context, even from within rfkill
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.
189 -bool rfkill_set_hw_state(struct rfkill *rfkill, bool blocked);
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
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.
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()).
205 - * This function can be called in any context, even from within rfkill
208 - * The function returns the combined block state (true if transmitter
209 - * should be blocked).
211 -bool rfkill_set_sw_state(struct rfkill *rfkill, bool blocked);
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
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
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.
227 -void rfkill_init_sw_state(struct rfkill *rfkill, bool blocked);
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
235 - * This function can be called in any context, even from within rfkill
238 -void rfkill_set_states(struct rfkill *rfkill, bool sw, bool hw);
241 - * rfkill_blocked - query rfkill block
243 - * @rfkill: rfkill struct to query
245 -bool rfkill_blocked(struct rfkill *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,
254 - return ERR_PTR(-ENODEV);
257 -static inline int __must_check rfkill_register(struct rfkill *rfkill)
259 - if (rfkill == ERR_PTR(-ENODEV))
264 -static inline void rfkill_pause_polling(struct rfkill *rfkill)
268 -static inline void rfkill_resume_polling(struct rfkill *rfkill)
272 -static inline void rfkill_unregister(struct rfkill *rfkill)
276 -static inline void rfkill_destroy(struct rfkill *rfkill)
280 -static inline bool rfkill_set_hw_state(struct rfkill *rfkill, bool blocked)
285 -static inline bool rfkill_set_sw_state(struct rfkill *rfkill, bool blocked)
290 -static inline void rfkill_init_sw_state(struct rfkill *rfkill, bool blocked)
294 -static inline void rfkill_set_states(struct rfkill *rfkill, bool sw, bool hw)
298 -static inline bool rfkill_blocked(struct rfkill *rfkill)
302 -#endif /* RFKILL || RFKILL_MODULE */
305 -#ifdef CONFIG_RFKILL_LEDS
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.
311 -const char *rfkill_get_led_trigger_name(struct rfkill *rfkill);
314 - * rfkill_set_led_trigger_name -- set the LED trigger name
315 - * @rfkill: rfkill struct
316 - * @name: LED trigger name
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.
322 -void rfkill_set_led_trigger_name(struct rfkill *rfkill, const char *name);
324 -static inline const char *rfkill_get_led_trigger_name(struct rfkill *rfkill)
330 -rfkill_set_led_trigger_name(struct rfkill *rfkill, const char *name)
335 -#endif /* __KERNEL__ */
337 -#endif /* RFKILL_H */
338 +#endif /* _UAPI__RFKILL_H */