Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
rfkill.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006 - 2007 Ivo van Doorn
3  * Copyright (C) 2007 Dmitry Torokhov
4  * Copyright 2009 Johannes Berg <[email protected]>
5  *
6  * Permission to use, copy, modify, and/or distribute this software for any
7  * purpose with or without fee is hereby granted, provided that the above
8  * copyright notice and this permission notice appear in all copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17  */
18 #ifndef __RFKILL_H
19 #define __RFKILL_H
20 
21 #include <uapi/linux/rfkill.h>
22 
23 /* don't allow anyone to use these in the kernel */
28 };
29 #undef RFKILL_STATE_SOFT_BLOCKED
30 #undef RFKILL_STATE_UNBLOCKED
31 #undef RFKILL_STATE_HARD_BLOCKED
32 
33 #include <linux/kernel.h>
34 #include <linux/list.h>
35 #include <linux/mutex.h>
36 #include <linux/leds.h>
37 #include <linux/err.h>
38 
39 struct device;
40 /* this is opaque */
41 struct rfkill;
42 
61 struct rfkill_ops {
62  void (*poll)(struct rfkill *rfkill, void *data);
63  void (*query)(struct rfkill *rfkill, void *data);
64  int (*set_block)(void *data, bool blocked);
65 };
66 
67 #if defined(CONFIG_RFKILL) || defined(CONFIG_RFKILL_MODULE)
68 
79 struct rfkill * __must_check rfkill_alloc(const char *name,
80  struct device *parent,
81  const enum rfkill_type type,
82  const struct rfkill_ops *ops,
83  void *ops_data);
84 
101 
109 void rfkill_pause_polling(struct rfkill *rfkill);
110 
118 void rfkill_resume_polling(struct rfkill *rfkill);
119 
120 
129 void rfkill_unregister(struct rfkill *rfkill);
130 
137 void rfkill_destroy(struct rfkill *rfkill);
138 
158 bool rfkill_set_hw_state(struct rfkill *rfkill, bool blocked);
159 
180 bool rfkill_set_sw_state(struct rfkill *rfkill, bool blocked);
181 
196 void rfkill_init_sw_state(struct rfkill *rfkill, bool blocked);
197 
207 void rfkill_set_states(struct rfkill *rfkill, bool sw, bool hw);
208 
214 bool rfkill_blocked(struct rfkill *rfkill);
215 #else /* !RFKILL */
216 static inline struct rfkill * __must_check
217 rfkill_alloc(const char *name,
218  struct device *parent,
219  const enum rfkill_type type,
220  const struct rfkill_ops *ops,
221  void *ops_data)
222 {
223  return ERR_PTR(-ENODEV);
224 }
225 
226 static inline int __must_check rfkill_register(struct rfkill *rfkill)
227 {
228  if (rfkill == ERR_PTR(-ENODEV))
229  return 0;
230  return -EINVAL;
231 }
232 
233 static inline void rfkill_pause_polling(struct rfkill *rfkill)
234 {
235 }
236 
237 static inline void rfkill_resume_polling(struct rfkill *rfkill)
238 {
239 }
240 
241 static inline void rfkill_unregister(struct rfkill *rfkill)
242 {
243 }
244 
245 static inline void rfkill_destroy(struct rfkill *rfkill)
246 {
247 }
248 
249 static inline bool rfkill_set_hw_state(struct rfkill *rfkill, bool blocked)
250 {
251  return blocked;
252 }
253 
254 static inline bool rfkill_set_sw_state(struct rfkill *rfkill, bool blocked)
255 {
256  return blocked;
257 }
258 
259 static inline void rfkill_init_sw_state(struct rfkill *rfkill, bool blocked)
260 {
261 }
262 
263 static inline void rfkill_set_states(struct rfkill *rfkill, bool sw, bool hw)
264 {
265 }
266 
267 static inline bool rfkill_blocked(struct rfkill *rfkill)
268 {
269  return false;
270 }
271 #endif /* RFKILL || RFKILL_MODULE */
272 
273 
274 #ifdef CONFIG_RFKILL_LEDS
275 
280 const char *rfkill_get_led_trigger_name(struct rfkill *rfkill);
281 
291 void rfkill_set_led_trigger_name(struct rfkill *rfkill, const char *name);
292 #else
293 static inline const char *rfkill_get_led_trigger_name(struct rfkill *rfkill)
294 {
295  return NULL;
296 }
297 
298 static inline void
299 rfkill_set_led_trigger_name(struct rfkill *rfkill, const char *name)
300 {
301 }
302 #endif
303 
304 #endif /* RFKILL_H */