aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/Kbuild1
-rw-r--r--include/linux/ieee80211.h1
-rw-r--r--include/linux/notifier.h1
-rw-r--r--include/linux/rfkill.h381
4 files changed, 306 insertions, 78 deletions
diff --git a/include/linux/Kbuild b/include/linux/Kbuild
index 3f0eaa397ef5..7e09c5c1ed02 100644
--- a/include/linux/Kbuild
+++ b/include/linux/Kbuild
@@ -311,6 +311,7 @@ unifdef-y += ptrace.h
311unifdef-y += qnx4_fs.h 311unifdef-y += qnx4_fs.h
312unifdef-y += quota.h 312unifdef-y += quota.h
313unifdef-y += random.h 313unifdef-y += random.h
314unifdef-y += rfkill.h
314unifdef-y += irqnr.h 315unifdef-y += irqnr.h
315unifdef-y += reboot.h 316unifdef-y += reboot.h
316unifdef-y += reiserfs_fs.h 317unifdef-y += reiserfs_fs.h
diff --git a/include/linux/ieee80211.h b/include/linux/ieee80211.h
index 34de8b21f6d4..a9173d5434d1 100644
--- a/include/linux/ieee80211.h
+++ b/include/linux/ieee80211.h
@@ -1092,6 +1092,7 @@ enum ieee80211_key_len {
1092 WLAN_KEY_LEN_WEP104 = 13, 1092 WLAN_KEY_LEN_WEP104 = 13,
1093 WLAN_KEY_LEN_CCMP = 16, 1093 WLAN_KEY_LEN_CCMP = 16,
1094 WLAN_KEY_LEN_TKIP = 32, 1094 WLAN_KEY_LEN_TKIP = 32,
1095 WLAN_KEY_LEN_AES_CMAC = 16,
1095}; 1096};
1096 1097
1097/* 1098/*
diff --git a/include/linux/notifier.h b/include/linux/notifier.h
index b86fa2ffca0c..81bc252dc8ac 100644
--- a/include/linux/notifier.h
+++ b/include/linux/notifier.h
@@ -198,6 +198,7 @@ static inline int notifier_to_errno(int ret)
198#define NETDEV_CHANGENAME 0x000A 198#define NETDEV_CHANGENAME 0x000A
199#define NETDEV_FEAT_CHANGE 0x000B 199#define NETDEV_FEAT_CHANGE 0x000B
200#define NETDEV_BONDING_FAILOVER 0x000C 200#define NETDEV_BONDING_FAILOVER 0x000C
201#define NETDEV_PRE_UP 0x000D
201 202
202#define SYS_DOWN 0x0001 /* Notify of system down */ 203#define SYS_DOWN 0x0001 /* Notify of system down */
203#define SYS_RESTART SYS_DOWN 204#define SYS_RESTART SYS_DOWN
diff --git a/include/linux/rfkill.h b/include/linux/rfkill.h
index de18ef227e00..ee3eddea8568 100644
--- a/include/linux/rfkill.h
+++ b/include/linux/rfkill.h
@@ -4,6 +4,7 @@
4/* 4/*
5 * Copyright (C) 2006 - 2007 Ivo van Doorn 5 * Copyright (C) 2006 - 2007 Ivo van Doorn
6 * Copyright (C) 2007 Dmitry Torokhov 6 * Copyright (C) 2007 Dmitry Torokhov
7 * Copyright 2009 Johannes Berg <johannes@sipsolutions.net>
7 * 8 *
8 * This program is free software; you can redistribute it and/or modify 9 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by 10 * it under the terms of the GNU General Public License as published by
@@ -22,117 +23,341 @@
22 */ 23 */
23 24
24#include <linux/types.h> 25#include <linux/types.h>
25#include <linux/kernel.h> 26
26#include <linux/list.h> 27/* define userspace visible states */
27#include <linux/mutex.h> 28#define RFKILL_STATE_SOFT_BLOCKED 0
28#include <linux/device.h> 29#define RFKILL_STATE_UNBLOCKED 1
29#include <linux/leds.h> 30#define RFKILL_STATE_HARD_BLOCKED 2
30 31
31/** 32/**
32 * enum rfkill_type - type of rfkill switch. 33 * enum rfkill_type - type of rfkill switch.
33 * RFKILL_TYPE_WLAN: switch is on a 802.11 wireless network device. 34 *
34 * RFKILL_TYPE_BLUETOOTH: switch is on a bluetooth device. 35 * @RFKILL_TYPE_ALL: toggles all switches (userspace only)
35 * RFKILL_TYPE_UWB: switch is on a ultra wideband device. 36 * @RFKILL_TYPE_WLAN: switch is on a 802.11 wireless network device.
36 * RFKILL_TYPE_WIMAX: switch is on a WiMAX device. 37 * @RFKILL_TYPE_BLUETOOTH: switch is on a bluetooth device.
37 * RFKILL_TYPE_WWAN: switch is on a wireless WAN device. 38 * @RFKILL_TYPE_UWB: switch is on a ultra wideband device.
39 * @RFKILL_TYPE_WIMAX: switch is on a WiMAX device.
40 * @RFKILL_TYPE_WWAN: switch is on a wireless WAN device.
41 * @NUM_RFKILL_TYPES: number of defined rfkill types
38 */ 42 */
39enum rfkill_type { 43enum rfkill_type {
40 RFKILL_TYPE_WLAN , 44 RFKILL_TYPE_ALL = 0,
45 RFKILL_TYPE_WLAN,
41 RFKILL_TYPE_BLUETOOTH, 46 RFKILL_TYPE_BLUETOOTH,
42 RFKILL_TYPE_UWB, 47 RFKILL_TYPE_UWB,
43 RFKILL_TYPE_WIMAX, 48 RFKILL_TYPE_WIMAX,
44 RFKILL_TYPE_WWAN, 49 RFKILL_TYPE_WWAN,
45 RFKILL_TYPE_MAX, 50 NUM_RFKILL_TYPES,
46}; 51};
47 52
48enum rfkill_state { 53/**
49 RFKILL_STATE_SOFT_BLOCKED = 0, /* Radio output blocked */ 54 * enum rfkill_operation - operation types
50 RFKILL_STATE_UNBLOCKED = 1, /* Radio output allowed */ 55 * @RFKILL_OP_ADD: a device was added
51 RFKILL_STATE_HARD_BLOCKED = 2, /* Output blocked, non-overrideable */ 56 * @RFKILL_OP_DEL: a device was removed
52 RFKILL_STATE_MAX, /* marker for last valid state */ 57 * @RFKILL_OP_CHANGE: a device's state changed -- userspace changes one device
58 * @RFKILL_OP_CHANGE_ALL: userspace changes all devices (of a type, or all)
59 */
60enum rfkill_operation {
61 RFKILL_OP_ADD = 0,
62 RFKILL_OP_DEL,
63 RFKILL_OP_CHANGE,
64 RFKILL_OP_CHANGE_ALL,
53}; 65};
54 66
55/** 67/**
56 * struct rfkill - rfkill control structure. 68 * struct rfkill_event - events for userspace on /dev/rfkill
57 * @name: Name of the switch. 69 * @idx: index of dev rfkill
58 * @type: Radio type which the button controls, the value stored 70 * @type: type of the rfkill struct
59 * here should be a value from enum rfkill_type. 71 * @op: operation code
60 * @state: State of the switch, "UNBLOCKED" means radio can operate. 72 * @hard: hard state (0/1)
61 * @mutex: Guards switch state transitions. It serializes callbacks 73 * @soft: soft state (0/1)
62 * and also protects the state. 74 *
63 * @data: Pointer to the RF button drivers private data which will be 75 * Structure used for userspace communication on /dev/rfkill,
64 * passed along when toggling radio state. 76 * used for events from the kernel and control to the kernel.
65 * @toggle_radio(): Mandatory handler to control state of the radio. 77 */
66 * only RFKILL_STATE_SOFT_BLOCKED and RFKILL_STATE_UNBLOCKED are 78struct rfkill_event {
67 * valid parameters. 79 __u32 idx;
68 * @get_state(): handler to read current radio state from hardware, 80 __u8 type;
69 * may be called from atomic context, should return 0 on success. 81 __u8 op;
70 * Either this handler OR judicious use of rfkill_force_state() is 82 __u8 soft, hard;
71 * MANDATORY for any driver capable of RFKILL_STATE_HARD_BLOCKED. 83} __packed;
72 * @led_trigger: A LED trigger for this button's LED.
73 * @dev: Device structure integrating the switch into device tree.
74 * @node: Used to place switch into list of all switches known to the
75 * the system.
76 *
77 * This structure represents a RF switch located on a network device.
78 */
79struct rfkill {
80 const char *name;
81 enum rfkill_type type;
82
83 /* the mutex serializes callbacks and also protects
84 * the state */
85 struct mutex mutex;
86 enum rfkill_state state;
87 void *data;
88 int (*toggle_radio)(void *data, enum rfkill_state state);
89 int (*get_state)(void *data, enum rfkill_state *state);
90 84
91#ifdef CONFIG_RFKILL_LEDS 85/* ioctl for turning off rfkill-input (if present) */
92 struct led_trigger led_trigger; 86#define RFKILL_IOC_MAGIC 'R'
93#endif 87#define RFKILL_IOC_NOINPUT 1
88#define RFKILL_IOCTL_NOINPUT _IO(RFKILL_IOC_MAGIC, RFKILL_IOC_NOINPUT)
94 89
95 struct device dev; 90/* and that's all userspace gets */
96 struct list_head node; 91#ifdef __KERNEL__
97 enum rfkill_state state_for_resume; 92/* don't allow anyone to use these in the kernel */
93enum rfkill_user_states {
94 RFKILL_USER_STATE_SOFT_BLOCKED = RFKILL_STATE_SOFT_BLOCKED,
95 RFKILL_USER_STATE_UNBLOCKED = RFKILL_STATE_UNBLOCKED,
96 RFKILL_USER_STATE_HARD_BLOCKED = RFKILL_STATE_HARD_BLOCKED,
98}; 97};
99#define to_rfkill(d) container_of(d, struct rfkill, dev) 98#undef RFKILL_STATE_SOFT_BLOCKED
99#undef RFKILL_STATE_UNBLOCKED
100#undef RFKILL_STATE_HARD_BLOCKED
101
102#include <linux/types.h>
103#include <linux/kernel.h>
104#include <linux/list.h>
105#include <linux/mutex.h>
106#include <linux/device.h>
107#include <linux/leds.h>
108
109/* this is opaque */
110struct rfkill;
111
112/**
113 * struct rfkill_ops - rfkill driver methods
114 *
115 * @poll: poll the rfkill block state(s) -- only assign this method
116 * when you need polling. When called, simply call one of the
117 * rfkill_set{,_hw,_sw}_state family of functions. If the hw
118 * is getting unblocked you need to take into account the return
119 * value of those functions to make sure the software block is
120 * properly used.
121 * @query: query the rfkill block state(s) and call exactly one of the
122 * rfkill_set{,_hw,_sw}_state family of functions. Assign this
123 * method if input events can cause hardware state changes to make
124 * the rfkill core query your driver before setting a requested
125 * block.
126 * @set_block: turn the transmitter on (blocked == false) or off
127 * (blocked == true) -- ignore and return 0 when hard blocked.
128 * This callback must be assigned.
129 */
130struct rfkill_ops {
131 void (*poll)(struct rfkill *rfkill, void *data);
132 void (*query)(struct rfkill *rfkill, void *data);
133 int (*set_block)(void *data, bool blocked);
134};
135
136#if defined(CONFIG_RFKILL) || defined(CONFIG_RFKILL_MODULE)
137/**
138 * rfkill_alloc - allocate rfkill structure
139 * @name: name of the struct -- the string is not copied internally
140 * @parent: device that has rf switch on it
141 * @type: type of the switch (RFKILL_TYPE_*)
142 * @ops: rfkill methods
143 * @ops_data: data passed to each method
144 *
145 * This function should be called by the transmitter driver to allocate an
146 * rfkill structure. Returns %NULL on failure.
147 */
148struct rfkill * __must_check rfkill_alloc(const char *name,
149 struct device *parent,
150 const enum rfkill_type type,
151 const struct rfkill_ops *ops,
152 void *ops_data);
100 153
101struct rfkill * __must_check rfkill_allocate(struct device *parent, 154/**
102 enum rfkill_type type); 155 * rfkill_register - Register a rfkill structure.
103void rfkill_free(struct rfkill *rfkill); 156 * @rfkill: rfkill structure to be registered
157 *
158 * This function should be called by the transmitter driver to register
159 * the rfkill structure needs to be registered. Before calling this function
160 * the driver needs to be ready to service method calls from rfkill.
161 */
104int __must_check rfkill_register(struct rfkill *rfkill); 162int __must_check rfkill_register(struct rfkill *rfkill);
163
164/**
165 * rfkill_pause_polling(struct rfkill *rfkill)
166 *
167 * Pause polling -- say transmitter is off for other reasons.
168 * NOTE: not necessary for suspend/resume -- in that case the
169 * core stops polling anyway
170 */
171void rfkill_pause_polling(struct rfkill *rfkill);
172
173/**
174 * rfkill_resume_polling(struct rfkill *rfkill)
175 *
176 * Pause polling -- say transmitter is off for other reasons.
177 * NOTE: not necessary for suspend/resume -- in that case the
178 * core stops polling anyway
179 */
180void rfkill_resume_polling(struct rfkill *rfkill);
181
182
183/**
184 * rfkill_unregister - Unregister a rfkill structure.
185 * @rfkill: rfkill structure to be unregistered
186 *
187 * This function should be called by the network driver during device
188 * teardown to destroy rfkill structure. Until it returns, the driver
189 * needs to be able to service method calls.
190 */
105void rfkill_unregister(struct rfkill *rfkill); 191void rfkill_unregister(struct rfkill *rfkill);
106 192
107int rfkill_force_state(struct rfkill *rfkill, enum rfkill_state state); 193/**
108int rfkill_set_default(enum rfkill_type type, enum rfkill_state state); 194 * rfkill_destroy - free rfkill structure
195 * @rfkill: rfkill structure to be destroyed
196 *
197 * Destroys the rfkill structure.
198 */
199void rfkill_destroy(struct rfkill *rfkill);
200
201/**
202 * rfkill_set_hw_state - Set the internal rfkill hardware block state
203 * @rfkill: pointer to the rfkill class to modify.
204 * @state: the current hardware block state to set
205 *
206 * rfkill drivers that get events when the hard-blocked state changes
207 * use this function to notify the rfkill core (and through that also
208 * userspace) of the current state -- they should also use this after
209 * resume if the state could have changed.
210 *
211 * You need not (but may) call this function if poll_state is assigned.
212 *
213 * This function can be called in any context, even from within rfkill
214 * callbacks.
215 *
216 * The function returns the combined block state (true if transmitter
217 * should be blocked) so that drivers need not keep track of the soft
218 * block state -- which they might not be able to.
219 */
220bool __must_check rfkill_set_hw_state(struct rfkill *rfkill, bool blocked);
221
222/**
223 * rfkill_set_sw_state - Set the internal rfkill software block state
224 * @rfkill: pointer to the rfkill class to modify.
225 * @state: the current software block state to set
226 *
227 * rfkill drivers that get events when the soft-blocked state changes
228 * (yes, some platforms directly act on input but allow changing again)
229 * use this function to notify the rfkill core (and through that also
230 * userspace) of the current state -- they should also use this after
231 * resume if the state could have changed.
232 *
233 * This function can be called in any context, even from within rfkill
234 * callbacks.
235 *
236 * The function returns the combined block state (true if transmitter
237 * should be blocked).
238 */
239bool rfkill_set_sw_state(struct rfkill *rfkill, bool blocked);
240
241/**
242 * rfkill_set_states - Set the internal rfkill block states
243 * @rfkill: pointer to the rfkill class to modify.
244 * @sw: the current software block state to set
245 * @hw: the current hardware block state to set
246 *
247 * This function can be called in any context, even from within rfkill
248 * callbacks.
249 */
250void rfkill_set_states(struct rfkill *rfkill, bool sw, bool hw);
109 251
110/** 252/**
111 * rfkill_state_complement - return complementar state 253 * rfkill_set_global_sw_state - set global sw block default
112 * @state: state to return the complement of 254 * @type: rfkill type to set default for
255 * @blocked: default to set
113 * 256 *
114 * Returns RFKILL_STATE_SOFT_BLOCKED if @state is RFKILL_STATE_UNBLOCKED, 257 * This function sets the global default -- use at boot if your platform has
115 * returns RFKILL_STATE_UNBLOCKED otherwise. 258 * an rfkill switch. If not early enough this call may be ignored.
259 *
260 * XXX: instead of ignoring -- how about just updating all currently
261 * registered drivers?
116 */ 262 */
117static inline enum rfkill_state rfkill_state_complement(enum rfkill_state state) 263void rfkill_set_global_sw_state(const enum rfkill_type type, bool blocked);
264
265/**
266 * rfkill_blocked - query rfkill block
267 *
268 * @rfkill: rfkill struct to query
269 */
270bool rfkill_blocked(struct rfkill *rfkill);
271#else /* !RFKILL */
272static inline struct rfkill * __must_check
273rfkill_alloc(const char *name,
274 struct device *parent,
275 const enum rfkill_type type,
276 const struct rfkill_ops *ops,
277 void *ops_data)
278{
279 return ERR_PTR(-ENODEV);
280}
281
282static inline int __must_check rfkill_register(struct rfkill *rfkill)
283{
284 if (rfkill == ERR_PTR(-ENODEV))
285 return 0;
286 return -EINVAL;
287}
288
289static inline void rfkill_pause_polling(struct rfkill *rfkill)
290{
291}
292
293static inline void rfkill_resume_polling(struct rfkill *rfkill)
294{
295}
296
297static inline void rfkill_unregister(struct rfkill *rfkill)
298{
299}
300
301static inline void rfkill_destroy(struct rfkill *rfkill)
302{
303}
304
305static inline bool rfkill_set_hw_state(struct rfkill *rfkill, bool blocked)
306{
307 return blocked;
308}
309
310static inline bool rfkill_set_sw_state(struct rfkill *rfkill, bool blocked)
311{
312 return blocked;
313}
314
315static inline void rfkill_set_states(struct rfkill *rfkill, bool sw, bool hw)
118{ 316{
119 return (state == RFKILL_STATE_UNBLOCKED) ?
120 RFKILL_STATE_SOFT_BLOCKED : RFKILL_STATE_UNBLOCKED;
121} 317}
122 318
319static inline void rfkill_set_global_sw_state(const enum rfkill_type type,
320 bool blocked)
321{
322}
323
324static inline bool rfkill_blocked(struct rfkill *rfkill)
325{
326 return false;
327}
328#endif /* RFKILL || RFKILL_MODULE */
329
330
331#ifdef CONFIG_RFKILL_LEDS
123/** 332/**
124 * rfkill_get_led_name - Get the LED trigger name for the button's LED. 333 * rfkill_get_led_trigger_name - Get the LED trigger name for the button's LED.
125 * This function might return a NULL pointer if registering of the 334 * This function might return a NULL pointer if registering of the
126 * LED trigger failed. 335 * LED trigger failed. Use this as "default_trigger" for the LED.
127 * Use this as "default_trigger" for the LED.
128 */ 336 */
129static inline char *rfkill_get_led_name(struct rfkill *rfkill) 337const char *rfkill_get_led_trigger_name(struct rfkill *rfkill);
130{ 338
131#ifdef CONFIG_RFKILL_LEDS 339/**
132 return (char *)(rfkill->led_trigger.name); 340 * rfkill_set_led_trigger_name -- set the LED trigger name
341 * @rfkill: rfkill struct
342 * @name: LED trigger name
343 *
344 * This function sets the LED trigger name of the radio LED
345 * trigger that rfkill creates. It is optional, but if called
346 * must be called before rfkill_register() to be effective.
347 */
348void rfkill_set_led_trigger_name(struct rfkill *rfkill, const char *name);
133#else 349#else
350static inline const char *rfkill_get_led_trigger_name(struct rfkill *rfkill)
351{
134 return NULL; 352 return NULL;
135#endif
136} 353}
137 354
355static inline void
356rfkill_set_led_trigger_name(struct rfkill *rfkill, const char *name)
357{
358}
359#endif
360
361#endif /* __KERNEL__ */
362
138#endif /* RFKILL_H */ 363#endif /* RFKILL_H */