Blame view
include/linux/rfkill.h
11.2 KB
cf4328cd9 [NET]: rfkill: ad... |
1 2 3 4 |
#ifndef __RFKILL_H #define __RFKILL_H /* |
fe242cfd3 [RFKILL]: Move rf... |
5 |
* Copyright (C) 2006 - 2007 Ivo van Doorn |
cf4328cd9 [NET]: rfkill: ad... |
6 |
* Copyright (C) 2007 Dmitry Torokhov |
19d337dff rfkill: rewrite |
7 |
* Copyright 2009 Johannes Berg <johannes@sipsolutions.net> |
cf4328cd9 [NET]: rfkill: ad... |
8 |
* |
8bc11b491 rfkill: relicense... |
9 10 11 |
* Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. |
cf4328cd9 [NET]: rfkill: ad... |
12 |
* |
8bc11b491 rfkill: relicense... |
13 14 15 16 17 18 19 |
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
cf4328cd9 [NET]: rfkill: ad... |
20 |
*/ |
c64fb0162 rfkill: create us... |
21 |
#include <linux/types.h> |
19d337dff rfkill: rewrite |
22 23 24 25 26 |
/* define userspace visible states */ #define RFKILL_STATE_SOFT_BLOCKED 0 #define RFKILL_STATE_UNBLOCKED 1 #define RFKILL_STATE_HARD_BLOCKED 2 |
cf4328cd9 [NET]: rfkill: ad... |
27 28 |
/** * enum rfkill_type - type of rfkill switch. |
19d337dff rfkill: rewrite |
29 |
* |
3082a2b7b rfkill: Add suppo... |
30 |
* @RFKILL_TYPE_ALL: toggles all switches (requests only - not a switch type) |
19d337dff rfkill: rewrite |
31 32 33 34 35 |
* @RFKILL_TYPE_WLAN: switch is on a 802.11 wireless network device. * @RFKILL_TYPE_BLUETOOTH: switch is on a bluetooth device. * @RFKILL_TYPE_UWB: switch is on a ultra wideband device. * @RFKILL_TYPE_WIMAX: switch is on a WiMAX device. * @RFKILL_TYPE_WWAN: switch is on a wireless WAN device. |
0878c3504 rfkill: Add missi... |
36 |
* @RFKILL_TYPE_GPS: switch is on a GPS device. |
875405a77 rfkill: Add const... |
37 |
* @RFKILL_TYPE_FM: switch is on a FM radio device. |
19d337dff rfkill: rewrite |
38 |
* @NUM_RFKILL_TYPES: number of defined rfkill types |
cf4328cd9 [NET]: rfkill: ad... |
39 40 |
*/ enum rfkill_type { |
c64fb0162 rfkill: create us... |
41 |
RFKILL_TYPE_ALL = 0, |
19d337dff rfkill: rewrite |
42 |
RFKILL_TYPE_WLAN, |
234a0ca6f [RFKILL]: Remove ... |
43 |
RFKILL_TYPE_BLUETOOTH, |
e0665486b [RFKILL]: Add sup... |
44 |
RFKILL_TYPE_UWB, |
303d9bf6b rfkill: add the W... |
45 |
RFKILL_TYPE_WIMAX, |
477576a07 rfkill: add the W... |
46 |
RFKILL_TYPE_WWAN, |
3ad201496 rfkill: add the G... |
47 |
RFKILL_TYPE_GPS, |
875405a77 rfkill: Add const... |
48 |
RFKILL_TYPE_FM, |
19d337dff rfkill: rewrite |
49 |
NUM_RFKILL_TYPES, |
cf4328cd9 [NET]: rfkill: ad... |
50 |
}; |
c64fb0162 rfkill: create us... |
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
/** * enum rfkill_operation - operation types * @RFKILL_OP_ADD: a device was added * @RFKILL_OP_DEL: a device was removed * @RFKILL_OP_CHANGE: a device's state changed -- userspace changes one device * @RFKILL_OP_CHANGE_ALL: userspace changes all devices (of a type, or all) */ enum rfkill_operation { RFKILL_OP_ADD = 0, RFKILL_OP_DEL, RFKILL_OP_CHANGE, RFKILL_OP_CHANGE_ALL, }; /** * struct rfkill_event - events for userspace on /dev/rfkill * @idx: index of dev rfkill * @type: type of the rfkill struct * @op: operation code * @hard: hard state (0/1) * @soft: soft state (0/1) * * Structure used for userspace communication on /dev/rfkill, * used for events from the kernel and control to the kernel. */ struct rfkill_event { __u32 idx; __u8 type; __u8 op; __u8 soft, hard; |
09cd2b99c header: fix broke... |
81 |
} __attribute__((packed)); |
c64fb0162 rfkill: create us... |
82 |
|
1be491fca rfkill: prep for ... |
83 84 85 86 87 88 89 90 91 92 93 94 95 |
/* * We are planning to be backward and forward compatible with changes * to the event struct, by adding new, optional, members at the end. * When reading an event (whether the kernel from userspace or vice * versa) we need to accept anything that's at least as large as the * version 1 event size, but might be able to accept other sizes in * the future. * * One exception is the kernel -- we already have two event sizes in * that we've made the 'hard' member optional since our only option * is to ignore it anyway. */ #define RFKILL_EVENT_SIZE_V1 8 |
c64fb0162 rfkill: create us... |
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
/* ioctl for turning off rfkill-input (if present) */ #define RFKILL_IOC_MAGIC 'R' #define RFKILL_IOC_NOINPUT 1 #define RFKILL_IOCTL_NOINPUT _IO(RFKILL_IOC_MAGIC, RFKILL_IOC_NOINPUT) /* and that's all userspace gets */ #ifdef __KERNEL__ /* don't allow anyone to use these in the kernel */ enum rfkill_user_states { RFKILL_USER_STATE_SOFT_BLOCKED = RFKILL_STATE_SOFT_BLOCKED, RFKILL_USER_STATE_UNBLOCKED = RFKILL_STATE_UNBLOCKED, RFKILL_USER_STATE_HARD_BLOCKED = RFKILL_STATE_HARD_BLOCKED, }; #undef RFKILL_STATE_SOFT_BLOCKED #undef RFKILL_STATE_UNBLOCKED #undef RFKILL_STATE_HARD_BLOCKED |
c64fb0162 rfkill: create us... |
112 113 114 115 116 |
#include <linux/kernel.h> #include <linux/list.h> #include <linux/mutex.h> #include <linux/device.h> #include <linux/leds.h> |
1506e30b5 rfkill: include e... |
117 |
#include <linux/err.h> |
c64fb0162 rfkill: create us... |
118 |
|
19d337dff rfkill: rewrite |
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
/* this is opaque */ struct rfkill; /** * struct rfkill_ops - rfkill driver methods * * @poll: poll the rfkill block state(s) -- only assign this method * when you need polling. When called, simply call one of the * rfkill_set{,_hw,_sw}_state family of functions. If the hw * is getting unblocked you need to take into account the return * value of those functions to make sure the software block is * properly used. * @query: query the rfkill block state(s) and call exactly one of the * rfkill_set{,_hw,_sw}_state family of functions. Assign this * method if input events can cause hardware state changes to make * the rfkill core query your driver before setting a requested * block. * @set_block: turn the transmitter on (blocked == false) or off |
c64fb0162 rfkill: create us... |
137 |
* (blocked == true) -- ignore and return 0 when hard blocked. |
19d337dff rfkill: rewrite |
138 139 140 141 142 143 |
* This callback must be assigned. */ struct rfkill_ops { void (*poll)(struct rfkill *rfkill, void *data); void (*query)(struct rfkill *rfkill, void *data); int (*set_block)(void *data, bool blocked); |
cf4328cd9 [NET]: rfkill: ad... |
144 |
}; |
19d337dff rfkill: rewrite |
145 |
#if defined(CONFIG_RFKILL) || defined(CONFIG_RFKILL_MODULE) |
cf4328cd9 [NET]: rfkill: ad... |
146 |
/** |
19d337dff rfkill: rewrite |
147 148 149 150 151 152 153 154 155 |
* rfkill_alloc - allocate rfkill structure * @name: name of the struct -- the string is not copied internally * @parent: device that has rf switch on it * @type: type of the switch (RFKILL_TYPE_*) * @ops: rfkill methods * @ops_data: data passed to each method * * This function should be called by the transmitter driver to allocate an * rfkill structure. Returns %NULL on failure. |
cf4328cd9 [NET]: rfkill: ad... |
156 |
*/ |
19d337dff rfkill: rewrite |
157 158 159 160 161 |
struct rfkill * __must_check rfkill_alloc(const char *name, struct device *parent, const enum rfkill_type type, const struct rfkill_ops *ops, void *ops_data); |
cf4328cd9 [NET]: rfkill: ad... |
162 |
|
19d337dff rfkill: rewrite |
163 164 165 166 167 |
/** * rfkill_register - Register a rfkill structure. * @rfkill: rfkill structure to be registered * * This function should be called by the transmitter driver to register |
b3fa1329e rfkill: remove se... |
168 169 170 |
* the rfkill structure. Before calling this function the driver needs * to be ready to service method calls from rfkill. * |
06d5caf47 rfkill: don't res... |
171 172 173 |
* If rfkill_init_sw_state() is not called before registration, * set_block() will be called to initialize the software blocked state * to a default value. |
b3fa1329e rfkill: remove se... |
174 175 176 |
* * If the hardware blocked state is not set before registration, * it is assumed to be unblocked. |
19d337dff rfkill: rewrite |
177 178 |
*/ int __must_check rfkill_register(struct rfkill *rfkill); |
135900c18 [RFKILL]: Add sup... |
179 |
|
19d337dff rfkill: rewrite |
180 181 182 183 184 185 186 187 |
/** * rfkill_pause_polling(struct rfkill *rfkill) * * Pause polling -- say transmitter is off for other reasons. * NOTE: not necessary for suspend/resume -- in that case the * core stops polling anyway */ void rfkill_pause_polling(struct rfkill *rfkill); |
cf4328cd9 [NET]: rfkill: ad... |
188 |
|
19d337dff rfkill: rewrite |
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 |
/** * rfkill_resume_polling(struct rfkill *rfkill) * * Pause polling -- say transmitter is off for other reasons. * NOTE: not necessary for suspend/resume -- in that case the * core stops polling anyway */ void rfkill_resume_polling(struct rfkill *rfkill); /** * rfkill_unregister - Unregister a rfkill structure. * @rfkill: rfkill structure to be unregistered * * This function should be called by the network driver during device * teardown to destroy rfkill structure. Until it returns, the driver * needs to be able to service method calls. */ |
cf4328cd9 [NET]: rfkill: ad... |
207 |
void rfkill_unregister(struct rfkill *rfkill); |
19d337dff rfkill: rewrite |
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 |
/** * rfkill_destroy - free rfkill structure * @rfkill: rfkill structure to be destroyed * * Destroys the rfkill structure. */ void rfkill_destroy(struct rfkill *rfkill); /** * rfkill_set_hw_state - Set the internal rfkill hardware block state * @rfkill: pointer to the rfkill class to modify. * @state: the current hardware block state to set * * rfkill drivers that get events when the hard-blocked state changes * use this function to notify the rfkill core (and through that also |
908209c16 rfkill: don't imp... |
223 |
* userspace) of the current state. They should also use this after |
19d337dff rfkill: rewrite |
224 225 226 227 228 229 230 231 232 233 234 |
* resume if the state could have changed. * * You need not (but may) call this function if poll_state is assigned. * * This function can be called in any context, even from within rfkill * callbacks. * * The function returns the combined block state (true if transmitter * should be blocked) so that drivers need not keep track of the soft * block state -- which they might not be able to. */ |
e56f09753 rfkill: remove to... |
235 |
bool rfkill_set_hw_state(struct rfkill *rfkill, bool blocked); |
19d337dff rfkill: rewrite |
236 237 238 239 240 241 242 243 244 |
/** * rfkill_set_sw_state - Set the internal rfkill software block state * @rfkill: pointer to the rfkill class to modify. * @state: the current software block state to set * * rfkill drivers that get events when the soft-blocked state changes * (yes, some platforms directly act on input but allow changing again) * use this function to notify the rfkill core (and through that also |
06d5caf47 rfkill: don't res... |
245 246 247 248 249 |
* userspace) of the current state. * * Drivers should also call this function after resume if the state has * been changed by the user. This only makes sense for "persistent" * devices (see rfkill_init_sw_state()). |
19d337dff rfkill: rewrite |
250 251 252 253 254 255 256 257 258 259 |
* * This function can be called in any context, even from within rfkill * callbacks. * * The function returns the combined block state (true if transmitter * should be blocked). */ bool rfkill_set_sw_state(struct rfkill *rfkill, bool blocked); /** |
06d5caf47 rfkill: don't res... |
260 261 262 263 264 265 266 267 268 |
* rfkill_init_sw_state - Initialize persistent software block state * @rfkill: pointer to the rfkill class to modify. * @state: the current software block state to set * * rfkill drivers that preserve their software block state over power off * use this function to notify the rfkill core (and through that also * userspace) of their initial state. It should only be used before * registration. * |
464902e81 rfkill: export pe... |
269 270 271 |
* In addition, it marks the device as "persistent", an attribute which * can be read by userspace. Persistent devices are expected to preserve * their own state when suspended. |
06d5caf47 rfkill: don't res... |
272 273 274 275 |
*/ void rfkill_init_sw_state(struct rfkill *rfkill, bool blocked); /** |
19d337dff rfkill: rewrite |
276 277 278 279 280 281 282 283 284 |
* rfkill_set_states - Set the internal rfkill block states * @rfkill: pointer to the rfkill class to modify. * @sw: the current software block state to set * @hw: the current hardware block state to set * * This function can be called in any context, even from within rfkill * callbacks. */ void rfkill_set_states(struct rfkill *rfkill, bool sw, bool hw); |
801e49af4 rfkill: add read-... |
285 |
|
135900c18 [RFKILL]: Add sup... |
286 |
/** |
6081162e2 rfkill: add funct... |
287 288 289 290 291 |
* rfkill_blocked - query rfkill block * * @rfkill: rfkill struct to query */ bool rfkill_blocked(struct rfkill *rfkill); |
19d337dff rfkill: rewrite |
292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 |
#else /* !RFKILL */ static inline struct rfkill * __must_check rfkill_alloc(const char *name, struct device *parent, const enum rfkill_type type, const struct rfkill_ops *ops, void *ops_data) { return ERR_PTR(-ENODEV); } static inline int __must_check rfkill_register(struct rfkill *rfkill) { if (rfkill == ERR_PTR(-ENODEV)) return 0; return -EINVAL; } static inline void rfkill_pause_polling(struct rfkill *rfkill) { } static inline void rfkill_resume_polling(struct rfkill *rfkill) { } static inline void rfkill_unregister(struct rfkill *rfkill) { } static inline void rfkill_destroy(struct rfkill *rfkill) { } static inline bool rfkill_set_hw_state(struct rfkill *rfkill, bool blocked) { return blocked; } static inline bool rfkill_set_sw_state(struct rfkill *rfkill, bool blocked) { return blocked; } |
06d5caf47 rfkill: don't res... |
335 336 337 |
static inline void rfkill_init_sw_state(struct rfkill *rfkill, bool blocked) { } |
19d337dff rfkill: rewrite |
338 339 340 |
static inline void rfkill_set_states(struct rfkill *rfkill, bool sw, bool hw) { } |
6081162e2 rfkill: add funct... |
341 342 343 344 |
static inline bool rfkill_blocked(struct rfkill *rfkill) { return false; } |
19d337dff rfkill: rewrite |
345 |
#endif /* RFKILL || RFKILL_MODULE */ |
19d337dff rfkill: rewrite |
346 |
#endif /* __KERNEL__ */ |
cf4328cd9 [NET]: rfkill: ad... |
347 |
#endif /* RFKILL_H */ |