Ivo van Doorn | cf4328c | 2007-05-07 00:34:20 -0700 | [diff] [blame] | 1 | /* |
Ivo van Doorn | fe242cf | 2007-09-27 14:57:05 -0700 | [diff] [blame] | 2 | * Copyright (C) 2006 - 2007 Ivo van Doorn |
Ivo van Doorn | cf4328c | 2007-05-07 00:34:20 -0700 | [diff] [blame] | 3 | * Copyright (C) 2007 Dmitry Torokhov |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 2 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the |
| 17 | * Free Software Foundation, Inc., |
| 18 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 19 | */ |
| 20 | |
| 21 | #include <linux/kernel.h> |
| 22 | #include <linux/module.h> |
| 23 | #include <linux/init.h> |
| 24 | #include <linux/workqueue.h> |
| 25 | #include <linux/capability.h> |
| 26 | #include <linux/list.h> |
| 27 | #include <linux/mutex.h> |
| 28 | #include <linux/rfkill.h> |
| 29 | |
Michael Buesch | 2736622 | 2007-11-02 20:18:11 +0100 | [diff] [blame] | 30 | /* Get declaration of rfkill_switch_all() to shut up sparse. */ |
| 31 | #include "rfkill-input.h" |
| 32 | |
| 33 | |
Ivo van Doorn | cf4328c | 2007-05-07 00:34:20 -0700 | [diff] [blame] | 34 | MODULE_AUTHOR("Ivo van Doorn <IvDoorn@gmail.com>"); |
| 35 | MODULE_VERSION("1.0"); |
| 36 | MODULE_DESCRIPTION("RF switch support"); |
| 37 | MODULE_LICENSE("GPL"); |
| 38 | |
| 39 | static LIST_HEAD(rfkill_list); /* list of registered rf switches */ |
| 40 | static DEFINE_MUTEX(rfkill_mutex); |
| 41 | |
Henrique de Moraes Holschuh | 5005657 | 2008-06-23 17:46:42 -0300 | [diff] [blame] | 42 | static unsigned int rfkill_default_state = RFKILL_STATE_UNBLOCKED; |
Henrique de Moraes Holschuh | e954b0b | 2008-06-23 17:22:59 -0300 | [diff] [blame] | 43 | module_param_named(default_state, rfkill_default_state, uint, 0444); |
| 44 | MODULE_PARM_DESC(default_state, |
| 45 | "Default initial state for all radio types, 0 = radio off"); |
| 46 | |
Ivo van Doorn | cf4328c | 2007-05-07 00:34:20 -0700 | [diff] [blame] | 47 | static enum rfkill_state rfkill_states[RFKILL_TYPE_MAX]; |
| 48 | |
Henrique de Moraes Holschuh | 79399a8 | 2008-06-23 17:23:03 -0300 | [diff] [blame] | 49 | static BLOCKING_NOTIFIER_HEAD(rfkill_notifier_list); |
| 50 | |
| 51 | |
| 52 | /** |
| 53 | * register_rfkill_notifier - Add notifier to rfkill notifier chain |
| 54 | * @nb: pointer to the new entry to add to the chain |
| 55 | * |
| 56 | * See blocking_notifier_chain_register() for return value and further |
| 57 | * observations. |
| 58 | * |
| 59 | * Adds a notifier to the rfkill notifier chain. The chain will be |
| 60 | * called with a pointer to the relevant rfkill structure as a parameter, |
| 61 | * refer to include/linux/rfkill.h for the possible events. |
| 62 | * |
| 63 | * Notifiers added to this chain are to always return NOTIFY_DONE. This |
| 64 | * chain is a blocking notifier chain: notifiers can sleep. |
| 65 | * |
| 66 | * Calls to this chain may have been done through a workqueue. One must |
| 67 | * assume unordered asynchronous behaviour, there is no way to know if |
| 68 | * actions related to the event that generated the notification have been |
| 69 | * carried out already. |
| 70 | */ |
| 71 | int register_rfkill_notifier(struct notifier_block *nb) |
| 72 | { |
| 73 | return blocking_notifier_chain_register(&rfkill_notifier_list, nb); |
| 74 | } |
| 75 | EXPORT_SYMBOL_GPL(register_rfkill_notifier); |
| 76 | |
| 77 | /** |
| 78 | * unregister_rfkill_notifier - remove notifier from rfkill notifier chain |
| 79 | * @nb: pointer to the entry to remove from the chain |
| 80 | * |
| 81 | * See blocking_notifier_chain_unregister() for return value and further |
| 82 | * observations. |
| 83 | * |
| 84 | * Removes a notifier from the rfkill notifier chain. |
| 85 | */ |
| 86 | int unregister_rfkill_notifier(struct notifier_block *nb) |
| 87 | { |
| 88 | return blocking_notifier_chain_unregister(&rfkill_notifier_list, nb); |
| 89 | } |
| 90 | EXPORT_SYMBOL_GPL(unregister_rfkill_notifier); |
| 91 | |
Michael Buesch | 135900c | 2007-09-27 21:33:12 +0200 | [diff] [blame] | 92 | |
| 93 | static void rfkill_led_trigger(struct rfkill *rfkill, |
| 94 | enum rfkill_state state) |
| 95 | { |
| 96 | #ifdef CONFIG_RFKILL_LEDS |
| 97 | struct led_trigger *led = &rfkill->led_trigger; |
| 98 | |
| 99 | if (!led->name) |
| 100 | return; |
Henrique de Moraes Holschuh | 5005657 | 2008-06-23 17:46:42 -0300 | [diff] [blame] | 101 | if (state != RFKILL_STATE_UNBLOCKED) |
Michael Buesch | 135900c | 2007-09-27 21:33:12 +0200 | [diff] [blame] | 102 | led_trigger_event(led, LED_OFF); |
| 103 | else |
| 104 | led_trigger_event(led, LED_FULL); |
| 105 | #endif /* CONFIG_RFKILL_LEDS */ |
| 106 | } |
| 107 | |
Dmitry Baryshkov | 9618566 | 2008-07-22 14:21:59 +0400 | [diff] [blame] | 108 | #ifdef CONFIG_RFKILL_LEDS |
| 109 | static void rfkill_led_trigger_activate(struct led_classdev *led) |
| 110 | { |
| 111 | struct rfkill *rfkill = container_of(led->trigger, |
| 112 | struct rfkill, led_trigger); |
| 113 | |
| 114 | rfkill_led_trigger(rfkill, rfkill->state); |
| 115 | } |
| 116 | #endif /* CONFIG_RFKILL_LEDS */ |
| 117 | |
Henrique de Moraes Holschuh | 79399a8 | 2008-06-23 17:23:03 -0300 | [diff] [blame] | 118 | static void notify_rfkill_state_change(struct rfkill *rfkill) |
| 119 | { |
| 120 | blocking_notifier_call_chain(&rfkill_notifier_list, |
| 121 | RFKILL_STATE_CHANGED, |
| 122 | rfkill); |
| 123 | } |
| 124 | |
Henrique de Moraes Holschuh | 801e49a | 2008-06-23 17:23:00 -0300 | [diff] [blame] | 125 | static void update_rfkill_state(struct rfkill *rfkill) |
| 126 | { |
Henrique de Moraes Holschuh | 79399a8 | 2008-06-23 17:23:03 -0300 | [diff] [blame] | 127 | enum rfkill_state newstate, oldstate; |
Henrique de Moraes Holschuh | 801e49a | 2008-06-23 17:23:00 -0300 | [diff] [blame] | 128 | |
| 129 | if (rfkill->get_state) { |
| 130 | mutex_lock(&rfkill->mutex); |
Henrique de Moraes Holschuh | 79399a8 | 2008-06-23 17:23:03 -0300 | [diff] [blame] | 131 | if (!rfkill->get_state(rfkill->data, &newstate)) { |
| 132 | oldstate = rfkill->state; |
Henrique de Moraes Holschuh | 801e49a | 2008-06-23 17:23:00 -0300 | [diff] [blame] | 133 | rfkill->state = newstate; |
Henrique de Moraes Holschuh | 79399a8 | 2008-06-23 17:23:03 -0300 | [diff] [blame] | 134 | if (oldstate != newstate) |
| 135 | notify_rfkill_state_change(rfkill); |
| 136 | } |
Henrique de Moraes Holschuh | 801e49a | 2008-06-23 17:23:00 -0300 | [diff] [blame] | 137 | mutex_unlock(&rfkill->mutex); |
| 138 | } |
| 139 | } |
| 140 | |
Henrique de Moraes Holschuh | 5005657 | 2008-06-23 17:46:42 -0300 | [diff] [blame] | 141 | /** |
| 142 | * rfkill_toggle_radio - wrapper for toggle_radio hook |
Henrique de Moraes Holschuh | 5005657 | 2008-06-23 17:46:42 -0300 | [diff] [blame] | 143 | * @rfkill: the rfkill struct to use |
| 144 | * @force: calls toggle_radio even if cache says it is not needed, |
| 145 | * and also makes sure notifications of the state will be |
| 146 | * sent even if it didn't change |
| 147 | * @state: the new state to call toggle_radio() with |
| 148 | * |
Henrique de Moraes Holschuh | 0f687e9 | 2008-07-03 13:14:56 -0300 | [diff] [blame] | 149 | * Calls rfkill->toggle_radio, enforcing the API for toggle_radio |
| 150 | * calls and handling all the red tape such as issuing notifications |
| 151 | * if the call is successful. |
| 152 | * |
Henrique de Moraes Holschuh | 435307a | 2008-07-21 21:18:22 -0300 | [diff] [blame] | 153 | * Note that the @force parameter cannot override a (possibly cached) |
| 154 | * state of RFKILL_STATE_HARD_BLOCKED. Any device making use of |
Henrique de Moraes Holschuh | 5005657 | 2008-06-23 17:46:42 -0300 | [diff] [blame] | 155 | * RFKILL_STATE_HARD_BLOCKED implements either get_state() or |
| 156 | * rfkill_force_state(), so the cache either is bypassed or valid. |
| 157 | * |
| 158 | * Note that we do call toggle_radio for RFKILL_STATE_SOFT_BLOCKED |
| 159 | * even if the radio is in RFKILL_STATE_HARD_BLOCKED state, so as to |
| 160 | * give the driver a hint that it should double-BLOCK the transmitter. |
| 161 | * |
Henrique de Moraes Holschuh | 064af11 | 2008-07-21 21:18:20 -0300 | [diff] [blame] | 162 | * Caller must have acquired rfkill->mutex. |
Henrique de Moraes Holschuh | 5005657 | 2008-06-23 17:46:42 -0300 | [diff] [blame] | 163 | */ |
Ivo van Doorn | cf4328c | 2007-05-07 00:34:20 -0700 | [diff] [blame] | 164 | static int rfkill_toggle_radio(struct rfkill *rfkill, |
Henrique de Moraes Holschuh | 526324b | 2008-06-23 17:23:02 -0300 | [diff] [blame] | 165 | enum rfkill_state state, |
| 166 | int force) |
Ivo van Doorn | cf4328c | 2007-05-07 00:34:20 -0700 | [diff] [blame] | 167 | { |
Michael Buesch | 7f4c534 | 2007-11-28 17:49:34 +0100 | [diff] [blame] | 168 | int retval = 0; |
Henrique de Moraes Holschuh | 801e49a | 2008-06-23 17:23:00 -0300 | [diff] [blame] | 169 | enum rfkill_state oldstate, newstate; |
| 170 | |
| 171 | oldstate = rfkill->state; |
| 172 | |
Henrique de Moraes Holschuh | 526324b | 2008-06-23 17:23:02 -0300 | [diff] [blame] | 173 | if (rfkill->get_state && !force && |
Henrique de Moraes Holschuh | 801e49a | 2008-06-23 17:23:00 -0300 | [diff] [blame] | 174 | !rfkill->get_state(rfkill->data, &newstate)) |
| 175 | rfkill->state = newstate; |
Ivo van Doorn | cf4328c | 2007-05-07 00:34:20 -0700 | [diff] [blame] | 176 | |
Henrique de Moraes Holschuh | 5005657 | 2008-06-23 17:46:42 -0300 | [diff] [blame] | 177 | switch (state) { |
| 178 | case RFKILL_STATE_HARD_BLOCKED: |
| 179 | /* typically happens when refreshing hardware state, |
| 180 | * such as on resume */ |
| 181 | state = RFKILL_STATE_SOFT_BLOCKED; |
| 182 | break; |
| 183 | case RFKILL_STATE_UNBLOCKED: |
| 184 | /* force can't override this, only rfkill_force_state() can */ |
| 185 | if (rfkill->state == RFKILL_STATE_HARD_BLOCKED) |
| 186 | return -EPERM; |
| 187 | break; |
| 188 | case RFKILL_STATE_SOFT_BLOCKED: |
| 189 | /* nothing to do, we want to give drivers the hint to double |
| 190 | * BLOCK even a transmitter that is already in state |
| 191 | * RFKILL_STATE_HARD_BLOCKED */ |
| 192 | break; |
| 193 | } |
| 194 | |
Henrique de Moraes Holschuh | 526324b | 2008-06-23 17:23:02 -0300 | [diff] [blame] | 195 | if (force || state != rfkill->state) { |
Ivo van Doorn | cf4328c | 2007-05-07 00:34:20 -0700 | [diff] [blame] | 196 | retval = rfkill->toggle_radio(rfkill->data, state); |
Henrique de Moraes Holschuh | 5005657 | 2008-06-23 17:46:42 -0300 | [diff] [blame] | 197 | /* never allow a HARD->SOFT downgrade! */ |
| 198 | if (!retval && rfkill->state != RFKILL_STATE_HARD_BLOCKED) |
Ivo van Doorn | cf4328c | 2007-05-07 00:34:20 -0700 | [diff] [blame] | 199 | rfkill->state = state; |
| 200 | } |
| 201 | |
Henrique de Moraes Holschuh | 79399a8 | 2008-06-23 17:23:03 -0300 | [diff] [blame] | 202 | if (force || rfkill->state != oldstate) { |
Henrique de Moraes Holschuh | 801e49a | 2008-06-23 17:23:00 -0300 | [diff] [blame] | 203 | rfkill_led_trigger(rfkill, rfkill->state); |
Henrique de Moraes Holschuh | 79399a8 | 2008-06-23 17:23:03 -0300 | [diff] [blame] | 204 | notify_rfkill_state_change(rfkill); |
| 205 | } |
Henrique de Moraes Holschuh | 801e49a | 2008-06-23 17:23:00 -0300 | [diff] [blame] | 206 | |
Ivo van Doorn | cf4328c | 2007-05-07 00:34:20 -0700 | [diff] [blame] | 207 | return retval; |
| 208 | } |
| 209 | |
| 210 | /** |
| 211 | * rfkill_switch_all - Toggle state of all switches of given type |
Henrique de Moraes Holschuh | 435307a | 2008-07-21 21:18:22 -0300 | [diff] [blame] | 212 | * @type: type of interfaces to be affected |
Ivo van Doorn | cf4328c | 2007-05-07 00:34:20 -0700 | [diff] [blame] | 213 | * @state: the new state |
| 214 | * |
Henrique de Moraes Holschuh | 435307a | 2008-07-21 21:18:22 -0300 | [diff] [blame] | 215 | * This function toggles the state of all switches of given type, |
| 216 | * unless a specific switch is claimed by userspace (in which case, |
| 217 | * that switch is left alone). |
Ivo van Doorn | cf4328c | 2007-05-07 00:34:20 -0700 | [diff] [blame] | 218 | */ |
Ivo van Doorn | cf4328c | 2007-05-07 00:34:20 -0700 | [diff] [blame] | 219 | void rfkill_switch_all(enum rfkill_type type, enum rfkill_state state) |
| 220 | { |
| 221 | struct rfkill *rfkill; |
| 222 | |
| 223 | mutex_lock(&rfkill_mutex); |
| 224 | |
| 225 | rfkill_states[type] = state; |
| 226 | |
| 227 | list_for_each_entry(rfkill, &rfkill_list, node) { |
Henrique de Moraes Holschuh | 064af11 | 2008-07-21 21:18:20 -0300 | [diff] [blame] | 228 | if ((!rfkill->user_claim) && (rfkill->type == type)) { |
| 229 | mutex_lock(&rfkill->mutex); |
Henrique de Moraes Holschuh | 526324b | 2008-06-23 17:23:02 -0300 | [diff] [blame] | 230 | rfkill_toggle_radio(rfkill, state, 0); |
Henrique de Moraes Holschuh | 064af11 | 2008-07-21 21:18:20 -0300 | [diff] [blame] | 231 | mutex_unlock(&rfkill->mutex); |
| 232 | } |
Ivo van Doorn | cf4328c | 2007-05-07 00:34:20 -0700 | [diff] [blame] | 233 | } |
| 234 | |
| 235 | mutex_unlock(&rfkill_mutex); |
| 236 | } |
| 237 | EXPORT_SYMBOL(rfkill_switch_all); |
| 238 | |
Henrique de Moraes Holschuh | 801e49a | 2008-06-23 17:23:00 -0300 | [diff] [blame] | 239 | /** |
Henrique de Moraes Holschuh | 4081f00 | 2008-06-23 17:23:07 -0300 | [diff] [blame] | 240 | * rfkill_epo - emergency power off all transmitters |
| 241 | * |
Henrique de Moraes Holschuh | 5005657 | 2008-06-23 17:46:42 -0300 | [diff] [blame] | 242 | * This kicks all rfkill devices to RFKILL_STATE_SOFT_BLOCKED, ignoring |
Henrique de Moraes Holschuh | 064af11 | 2008-07-21 21:18:20 -0300 | [diff] [blame] | 243 | * everything in its path but rfkill_mutex and rfkill->mutex. |
Henrique de Moraes Holschuh | 4081f00 | 2008-06-23 17:23:07 -0300 | [diff] [blame] | 244 | */ |
| 245 | void rfkill_epo(void) |
| 246 | { |
| 247 | struct rfkill *rfkill; |
| 248 | |
| 249 | mutex_lock(&rfkill_mutex); |
| 250 | list_for_each_entry(rfkill, &rfkill_list, node) { |
Henrique de Moraes Holschuh | 064af11 | 2008-07-21 21:18:20 -0300 | [diff] [blame] | 251 | mutex_lock(&rfkill->mutex); |
Henrique de Moraes Holschuh | 5005657 | 2008-06-23 17:46:42 -0300 | [diff] [blame] | 252 | rfkill_toggle_radio(rfkill, RFKILL_STATE_SOFT_BLOCKED, 1); |
Henrique de Moraes Holschuh | 064af11 | 2008-07-21 21:18:20 -0300 | [diff] [blame] | 253 | mutex_unlock(&rfkill->mutex); |
Henrique de Moraes Holschuh | 4081f00 | 2008-06-23 17:23:07 -0300 | [diff] [blame] | 254 | } |
| 255 | mutex_unlock(&rfkill_mutex); |
| 256 | } |
| 257 | EXPORT_SYMBOL_GPL(rfkill_epo); |
| 258 | |
| 259 | /** |
Henrique de Moraes Holschuh | 801e49a | 2008-06-23 17:23:00 -0300 | [diff] [blame] | 260 | * rfkill_force_state - Force the internal rfkill radio state |
| 261 | * @rfkill: pointer to the rfkill class to modify. |
| 262 | * @state: the current radio state the class should be forced to. |
| 263 | * |
| 264 | * This function updates the internal state of the radio cached |
| 265 | * by the rfkill class. It should be used when the driver gets |
| 266 | * a notification by the firmware/hardware of the current *real* |
| 267 | * state of the radio rfkill switch. |
| 268 | * |
Henrique de Moraes Holschuh | 2fd9b22 | 2008-07-21 21:18:17 -0300 | [diff] [blame] | 269 | * Devices which are subject to external changes on their rfkill |
| 270 | * state (such as those caused by a hardware rfkill line) MUST |
| 271 | * have their driver arrange to call rfkill_force_state() as soon |
| 272 | * as possible after such a change. |
| 273 | * |
| 274 | * This function may not be called from an atomic context. |
Henrique de Moraes Holschuh | 801e49a | 2008-06-23 17:23:00 -0300 | [diff] [blame] | 275 | */ |
| 276 | int rfkill_force_state(struct rfkill *rfkill, enum rfkill_state state) |
| 277 | { |
Henrique de Moraes Holschuh | 79399a8 | 2008-06-23 17:23:03 -0300 | [diff] [blame] | 278 | enum rfkill_state oldstate; |
| 279 | |
Henrique de Moraes Holschuh | 5005657 | 2008-06-23 17:46:42 -0300 | [diff] [blame] | 280 | if (state != RFKILL_STATE_SOFT_BLOCKED && |
| 281 | state != RFKILL_STATE_UNBLOCKED && |
| 282 | state != RFKILL_STATE_HARD_BLOCKED) |
Henrique de Moraes Holschuh | 801e49a | 2008-06-23 17:23:00 -0300 | [diff] [blame] | 283 | return -EINVAL; |
| 284 | |
| 285 | mutex_lock(&rfkill->mutex); |
Henrique de Moraes Holschuh | 79399a8 | 2008-06-23 17:23:03 -0300 | [diff] [blame] | 286 | |
| 287 | oldstate = rfkill->state; |
Henrique de Moraes Holschuh | 801e49a | 2008-06-23 17:23:00 -0300 | [diff] [blame] | 288 | rfkill->state = state; |
Henrique de Moraes Holschuh | 79399a8 | 2008-06-23 17:23:03 -0300 | [diff] [blame] | 289 | |
| 290 | if (state != oldstate) |
| 291 | notify_rfkill_state_change(rfkill); |
| 292 | |
Henrique de Moraes Holschuh | 801e49a | 2008-06-23 17:23:00 -0300 | [diff] [blame] | 293 | mutex_unlock(&rfkill->mutex); |
| 294 | |
| 295 | return 0; |
| 296 | } |
| 297 | EXPORT_SYMBOL(rfkill_force_state); |
| 298 | |
Ivo van Doorn | cf4328c | 2007-05-07 00:34:20 -0700 | [diff] [blame] | 299 | static ssize_t rfkill_name_show(struct device *dev, |
| 300 | struct device_attribute *attr, |
| 301 | char *buf) |
| 302 | { |
| 303 | struct rfkill *rfkill = to_rfkill(dev); |
| 304 | |
| 305 | return sprintf(buf, "%s\n", rfkill->name); |
| 306 | } |
| 307 | |
Henrique de Moraes Holschuh | 99c632e | 2008-06-23 17:23:04 -0300 | [diff] [blame] | 308 | static const char *rfkill_get_type_str(enum rfkill_type type) |
| 309 | { |
| 310 | switch (type) { |
| 311 | case RFKILL_TYPE_WLAN: |
| 312 | return "wlan"; |
| 313 | case RFKILL_TYPE_BLUETOOTH: |
| 314 | return "bluetooth"; |
| 315 | case RFKILL_TYPE_UWB: |
| 316 | return "ultrawideband"; |
| 317 | case RFKILL_TYPE_WIMAX: |
| 318 | return "wimax"; |
| 319 | case RFKILL_TYPE_WWAN: |
| 320 | return "wwan"; |
| 321 | default: |
| 322 | BUG(); |
| 323 | } |
| 324 | } |
| 325 | |
Ivo van Doorn | cf4328c | 2007-05-07 00:34:20 -0700 | [diff] [blame] | 326 | static ssize_t rfkill_type_show(struct device *dev, |
| 327 | struct device_attribute *attr, |
| 328 | char *buf) |
| 329 | { |
| 330 | struct rfkill *rfkill = to_rfkill(dev); |
Ivo van Doorn | cf4328c | 2007-05-07 00:34:20 -0700 | [diff] [blame] | 331 | |
Henrique de Moraes Holschuh | 99c632e | 2008-06-23 17:23:04 -0300 | [diff] [blame] | 332 | return sprintf(buf, "%s\n", rfkill_get_type_str(rfkill->type)); |
Ivo van Doorn | cf4328c | 2007-05-07 00:34:20 -0700 | [diff] [blame] | 333 | } |
| 334 | |
| 335 | static ssize_t rfkill_state_show(struct device *dev, |
| 336 | struct device_attribute *attr, |
| 337 | char *buf) |
| 338 | { |
| 339 | struct rfkill *rfkill = to_rfkill(dev); |
| 340 | |
Henrique de Moraes Holschuh | 801e49a | 2008-06-23 17:23:00 -0300 | [diff] [blame] | 341 | update_rfkill_state(rfkill); |
Ivo van Doorn | cf4328c | 2007-05-07 00:34:20 -0700 | [diff] [blame] | 342 | return sprintf(buf, "%d\n", rfkill->state); |
| 343 | } |
| 344 | |
| 345 | static ssize_t rfkill_state_store(struct device *dev, |
| 346 | struct device_attribute *attr, |
| 347 | const char *buf, size_t count) |
| 348 | { |
| 349 | struct rfkill *rfkill = to_rfkill(dev); |
| 350 | unsigned int state = simple_strtoul(buf, NULL, 0); |
| 351 | int error; |
| 352 | |
| 353 | if (!capable(CAP_NET_ADMIN)) |
| 354 | return -EPERM; |
| 355 | |
Henrique de Moraes Holschuh | 5005657 | 2008-06-23 17:46:42 -0300 | [diff] [blame] | 356 | /* RFKILL_STATE_HARD_BLOCKED is illegal here... */ |
| 357 | if (state != RFKILL_STATE_UNBLOCKED && |
| 358 | state != RFKILL_STATE_SOFT_BLOCKED) |
| 359 | return -EINVAL; |
| 360 | |
Michael Buesch | 7f4c534 | 2007-11-28 17:49:34 +0100 | [diff] [blame] | 361 | if (mutex_lock_interruptible(&rfkill->mutex)) |
| 362 | return -ERESTARTSYS; |
Henrique de Moraes Holschuh | 5005657 | 2008-06-23 17:46:42 -0300 | [diff] [blame] | 363 | error = rfkill_toggle_radio(rfkill, state, 0); |
Michael Buesch | 7f4c534 | 2007-11-28 17:49:34 +0100 | [diff] [blame] | 364 | mutex_unlock(&rfkill->mutex); |
Ivo van Doorn | cf4328c | 2007-05-07 00:34:20 -0700 | [diff] [blame] | 365 | |
Michael Buesch | 7f4c534 | 2007-11-28 17:49:34 +0100 | [diff] [blame] | 366 | return error ? error : count; |
Ivo van Doorn | cf4328c | 2007-05-07 00:34:20 -0700 | [diff] [blame] | 367 | } |
| 368 | |
| 369 | static ssize_t rfkill_claim_show(struct device *dev, |
| 370 | struct device_attribute *attr, |
| 371 | char *buf) |
| 372 | { |
| 373 | struct rfkill *rfkill = to_rfkill(dev); |
| 374 | |
| 375 | return sprintf(buf, "%d", rfkill->user_claim); |
| 376 | } |
| 377 | |
| 378 | static ssize_t rfkill_claim_store(struct device *dev, |
| 379 | struct device_attribute *attr, |
| 380 | const char *buf, size_t count) |
| 381 | { |
| 382 | struct rfkill *rfkill = to_rfkill(dev); |
| 383 | bool claim = !!simple_strtoul(buf, NULL, 0); |
| 384 | int error; |
| 385 | |
| 386 | if (!capable(CAP_NET_ADMIN)) |
| 387 | return -EPERM; |
| 388 | |
Henrique de Moraes Holschuh | 064af11 | 2008-07-21 21:18:20 -0300 | [diff] [blame] | 389 | if (rfkill->user_claim_unsupported) |
| 390 | return -EOPNOTSUPP; |
| 391 | |
Ivo van Doorn | cf4328c | 2007-05-07 00:34:20 -0700 | [diff] [blame] | 392 | /* |
| 393 | * Take the global lock to make sure the kernel is not in |
| 394 | * the middle of rfkill_switch_all |
| 395 | */ |
| 396 | error = mutex_lock_interruptible(&rfkill_mutex); |
| 397 | if (error) |
| 398 | return error; |
| 399 | |
| 400 | if (rfkill->user_claim != claim) { |
Henrique de Moraes Holschuh | 064af11 | 2008-07-21 21:18:20 -0300 | [diff] [blame] | 401 | if (!claim) { |
| 402 | mutex_lock(&rfkill->mutex); |
Ivo van Doorn | cf4328c | 2007-05-07 00:34:20 -0700 | [diff] [blame] | 403 | rfkill_toggle_radio(rfkill, |
Henrique de Moraes Holschuh | 526324b | 2008-06-23 17:23:02 -0300 | [diff] [blame] | 404 | rfkill_states[rfkill->type], |
| 405 | 0); |
Henrique de Moraes Holschuh | 064af11 | 2008-07-21 21:18:20 -0300 | [diff] [blame] | 406 | mutex_unlock(&rfkill->mutex); |
| 407 | } |
Ivo van Doorn | cf4328c | 2007-05-07 00:34:20 -0700 | [diff] [blame] | 408 | rfkill->user_claim = claim; |
| 409 | } |
| 410 | |
| 411 | mutex_unlock(&rfkill_mutex); |
| 412 | |
Michael Buesch | 20405c0 | 2007-09-27 21:34:23 +0200 | [diff] [blame] | 413 | return error ? error : count; |
Ivo van Doorn | cf4328c | 2007-05-07 00:34:20 -0700 | [diff] [blame] | 414 | } |
| 415 | |
| 416 | static struct device_attribute rfkill_dev_attrs[] = { |
| 417 | __ATTR(name, S_IRUGO, rfkill_name_show, NULL), |
| 418 | __ATTR(type, S_IRUGO, rfkill_type_show, NULL), |
Ivo van Doorn | c81de6a | 2007-07-18 15:38:03 -0700 | [diff] [blame] | 419 | __ATTR(state, S_IRUGO|S_IWUSR, rfkill_state_show, rfkill_state_store), |
Ivo van Doorn | cf4328c | 2007-05-07 00:34:20 -0700 | [diff] [blame] | 420 | __ATTR(claim, S_IRUGO|S_IWUSR, rfkill_claim_show, rfkill_claim_store), |
| 421 | __ATTR_NULL |
| 422 | }; |
| 423 | |
| 424 | static void rfkill_release(struct device *dev) |
| 425 | { |
| 426 | struct rfkill *rfkill = to_rfkill(dev); |
| 427 | |
| 428 | kfree(rfkill); |
| 429 | module_put(THIS_MODULE); |
| 430 | } |
| 431 | |
| 432 | #ifdef CONFIG_PM |
| 433 | static int rfkill_suspend(struct device *dev, pm_message_t state) |
| 434 | { |
| 435 | struct rfkill *rfkill = to_rfkill(dev); |
| 436 | |
| 437 | if (dev->power.power_state.event != state.event) { |
Rafael J. Wysocki | 3a2d5b7 | 2008-02-23 19:13:25 +0100 | [diff] [blame] | 438 | if (state.event & PM_EVENT_SLEEP) { |
Henrique de Moraes Holschuh | 526324b | 2008-06-23 17:23:02 -0300 | [diff] [blame] | 439 | /* Stop transmitter, keep state, no notifies */ |
| 440 | update_rfkill_state(rfkill); |
| 441 | |
Ivo van Doorn | cf4328c | 2007-05-07 00:34:20 -0700 | [diff] [blame] | 442 | mutex_lock(&rfkill->mutex); |
Henrique de Moraes Holschuh | 5005657 | 2008-06-23 17:46:42 -0300 | [diff] [blame] | 443 | rfkill->toggle_radio(rfkill->data, |
| 444 | RFKILL_STATE_SOFT_BLOCKED); |
Ivo van Doorn | cf4328c | 2007-05-07 00:34:20 -0700 | [diff] [blame] | 445 | mutex_unlock(&rfkill->mutex); |
| 446 | } |
| 447 | |
| 448 | dev->power.power_state = state; |
| 449 | } |
| 450 | |
| 451 | return 0; |
| 452 | } |
| 453 | |
| 454 | static int rfkill_resume(struct device *dev) |
| 455 | { |
| 456 | struct rfkill *rfkill = to_rfkill(dev); |
| 457 | |
| 458 | if (dev->power.power_state.event != PM_EVENT_ON) { |
| 459 | mutex_lock(&rfkill->mutex); |
| 460 | |
Henrique de Moraes Holschuh | 526324b | 2008-06-23 17:23:02 -0300 | [diff] [blame] | 461 | /* restore radio state AND notify everybody */ |
| 462 | rfkill_toggle_radio(rfkill, rfkill->state, 1); |
Ivo van Doorn | cf4328c | 2007-05-07 00:34:20 -0700 | [diff] [blame] | 463 | |
| 464 | mutex_unlock(&rfkill->mutex); |
| 465 | } |
| 466 | |
| 467 | dev->power.power_state = PMSG_ON; |
| 468 | return 0; |
| 469 | } |
| 470 | #else |
| 471 | #define rfkill_suspend NULL |
| 472 | #define rfkill_resume NULL |
| 473 | #endif |
| 474 | |
Henrique de Moraes Holschuh | ffb67c3 | 2008-06-23 17:23:05 -0300 | [diff] [blame] | 475 | static int rfkill_blocking_uevent_notifier(struct notifier_block *nb, |
| 476 | unsigned long eventid, |
| 477 | void *data) |
| 478 | { |
| 479 | struct rfkill *rfkill = (struct rfkill *)data; |
| 480 | |
| 481 | switch (eventid) { |
| 482 | case RFKILL_STATE_CHANGED: |
| 483 | kobject_uevent(&rfkill->dev.kobj, KOBJ_CHANGE); |
| 484 | break; |
| 485 | default: |
| 486 | break; |
| 487 | } |
| 488 | |
| 489 | return NOTIFY_DONE; |
| 490 | } |
| 491 | |
| 492 | static struct notifier_block rfkill_blocking_uevent_nb = { |
| 493 | .notifier_call = rfkill_blocking_uevent_notifier, |
| 494 | .priority = 0, |
| 495 | }; |
| 496 | |
| 497 | static int rfkill_dev_uevent(struct device *dev, struct kobj_uevent_env *env) |
| 498 | { |
| 499 | struct rfkill *rfkill = to_rfkill(dev); |
| 500 | int error; |
| 501 | |
| 502 | error = add_uevent_var(env, "RFKILL_NAME=%s", rfkill->name); |
| 503 | if (error) |
| 504 | return error; |
| 505 | error = add_uevent_var(env, "RFKILL_TYPE=%s", |
| 506 | rfkill_get_type_str(rfkill->type)); |
| 507 | if (error) |
| 508 | return error; |
| 509 | error = add_uevent_var(env, "RFKILL_STATE=%d", rfkill->state); |
| 510 | return error; |
| 511 | } |
| 512 | |
Ivo van Doorn | cf4328c | 2007-05-07 00:34:20 -0700 | [diff] [blame] | 513 | static struct class rfkill_class = { |
| 514 | .name = "rfkill", |
| 515 | .dev_release = rfkill_release, |
| 516 | .dev_attrs = rfkill_dev_attrs, |
| 517 | .suspend = rfkill_suspend, |
| 518 | .resume = rfkill_resume, |
Henrique de Moraes Holschuh | ffb67c3 | 2008-06-23 17:23:05 -0300 | [diff] [blame] | 519 | .dev_uevent = rfkill_dev_uevent, |
Ivo van Doorn | cf4328c | 2007-05-07 00:34:20 -0700 | [diff] [blame] | 520 | }; |
| 521 | |
| 522 | static int rfkill_add_switch(struct rfkill *rfkill) |
| 523 | { |
Michael Buesch | 7319f1e | 2007-10-28 15:16:50 +0100 | [diff] [blame] | 524 | mutex_lock(&rfkill_mutex); |
Ivo van Doorn | cf4328c | 2007-05-07 00:34:20 -0700 | [diff] [blame] | 525 | |
Henrique de Moraes Holschuh | fd4484a | 2008-07-03 13:14:57 -0300 | [diff] [blame] | 526 | rfkill_toggle_radio(rfkill, rfkill_states[rfkill->type], 0); |
| 527 | |
| 528 | list_add_tail(&rfkill->node, &rfkill_list); |
Ivo van Doorn | cf4328c | 2007-05-07 00:34:20 -0700 | [diff] [blame] | 529 | |
Ivo van Doorn | cf4328c | 2007-05-07 00:34:20 -0700 | [diff] [blame] | 530 | mutex_unlock(&rfkill_mutex); |
Michael Buesch | 7319f1e | 2007-10-28 15:16:50 +0100 | [diff] [blame] | 531 | |
Henrique de Moraes Holschuh | fd4484a | 2008-07-03 13:14:57 -0300 | [diff] [blame] | 532 | return 0; |
Ivo van Doorn | cf4328c | 2007-05-07 00:34:20 -0700 | [diff] [blame] | 533 | } |
| 534 | |
| 535 | static void rfkill_remove_switch(struct rfkill *rfkill) |
| 536 | { |
| 537 | mutex_lock(&rfkill_mutex); |
| 538 | list_del_init(&rfkill->node); |
Ivo van Doorn | cf4328c | 2007-05-07 00:34:20 -0700 | [diff] [blame] | 539 | mutex_unlock(&rfkill_mutex); |
Henrique de Moraes Holschuh | 064af11 | 2008-07-21 21:18:20 -0300 | [diff] [blame] | 540 | |
| 541 | mutex_lock(&rfkill->mutex); |
| 542 | rfkill_toggle_radio(rfkill, RFKILL_STATE_SOFT_BLOCKED, 1); |
| 543 | mutex_unlock(&rfkill->mutex); |
Ivo van Doorn | cf4328c | 2007-05-07 00:34:20 -0700 | [diff] [blame] | 544 | } |
| 545 | |
| 546 | /** |
| 547 | * rfkill_allocate - allocate memory for rfkill structure. |
| 548 | * @parent: device that has rf switch on it |
Ivo van Doorn | 234a0ca | 2007-09-13 09:20:42 +0200 | [diff] [blame] | 549 | * @type: type of the switch (RFKILL_TYPE_*) |
Ivo van Doorn | cf4328c | 2007-05-07 00:34:20 -0700 | [diff] [blame] | 550 | * |
| 551 | * This function should be called by the network driver when it needs |
Henrique de Moraes Holschuh | 435307a | 2008-07-21 21:18:22 -0300 | [diff] [blame] | 552 | * rfkill structure. Once the structure is allocated the driver should |
| 553 | * finish its initialization by setting the name, private data, enable_radio |
Ivo van Doorn | cf4328c | 2007-05-07 00:34:20 -0700 | [diff] [blame] | 554 | * and disable_radio methods and then register it with rfkill_register(). |
Henrique de Moraes Holschuh | 435307a | 2008-07-21 21:18:22 -0300 | [diff] [blame] | 555 | * |
Ivo van Doorn | cf4328c | 2007-05-07 00:34:20 -0700 | [diff] [blame] | 556 | * NOTE: If registration fails the structure shoudl be freed by calling |
| 557 | * rfkill_free() otherwise rfkill_unregister() should be used. |
| 558 | */ |
| 559 | struct rfkill *rfkill_allocate(struct device *parent, enum rfkill_type type) |
| 560 | { |
| 561 | struct rfkill *rfkill; |
| 562 | struct device *dev; |
| 563 | |
| 564 | rfkill = kzalloc(sizeof(struct rfkill), GFP_KERNEL); |
Ivo van Doorn | d007da1 | 2007-05-19 12:24:39 -0700 | [diff] [blame] | 565 | if (!rfkill) |
Ivo van Doorn | cf4328c | 2007-05-07 00:34:20 -0700 | [diff] [blame] | 566 | return NULL; |
| 567 | |
| 568 | mutex_init(&rfkill->mutex); |
| 569 | INIT_LIST_HEAD(&rfkill->node); |
| 570 | rfkill->type = type; |
| 571 | |
| 572 | dev = &rfkill->dev; |
| 573 | dev->class = &rfkill_class; |
| 574 | dev->parent = parent; |
| 575 | device_initialize(dev); |
| 576 | |
| 577 | __module_get(THIS_MODULE); |
| 578 | |
| 579 | return rfkill; |
| 580 | } |
| 581 | EXPORT_SYMBOL(rfkill_allocate); |
| 582 | |
| 583 | /** |
| 584 | * rfkill_free - Mark rfkill structure for deletion |
| 585 | * @rfkill: rfkill structure to be destroyed |
| 586 | * |
Henrique de Moraes Holschuh | 435307a | 2008-07-21 21:18:22 -0300 | [diff] [blame] | 587 | * Decrements reference count of the rfkill structure so it is destroyed. |
Ivo van Doorn | cf4328c | 2007-05-07 00:34:20 -0700 | [diff] [blame] | 588 | * Note that rfkill_free() should _not_ be called after rfkill_unregister(). |
| 589 | */ |
| 590 | void rfkill_free(struct rfkill *rfkill) |
| 591 | { |
| 592 | if (rfkill) |
| 593 | put_device(&rfkill->dev); |
| 594 | } |
| 595 | EXPORT_SYMBOL(rfkill_free); |
| 596 | |
Michael Buesch | 135900c | 2007-09-27 21:33:12 +0200 | [diff] [blame] | 597 | static void rfkill_led_trigger_register(struct rfkill *rfkill) |
| 598 | { |
| 599 | #ifdef CONFIG_RFKILL_LEDS |
| 600 | int error; |
| 601 | |
Dmitry Baryshkov | 7c4f457 | 2008-07-22 14:17:37 +0400 | [diff] [blame] | 602 | if (!rfkill->led_trigger.name) |
| 603 | rfkill->led_trigger.name = rfkill->dev.bus_id; |
Dmitry Baryshkov | 9618566 | 2008-07-22 14:21:59 +0400 | [diff] [blame] | 604 | if (!rfkill->led_trigger.activate) |
| 605 | rfkill->led_trigger.activate = rfkill_led_trigger_activate; |
Michael Buesch | 135900c | 2007-09-27 21:33:12 +0200 | [diff] [blame] | 606 | error = led_trigger_register(&rfkill->led_trigger); |
| 607 | if (error) |
| 608 | rfkill->led_trigger.name = NULL; |
| 609 | #endif /* CONFIG_RFKILL_LEDS */ |
| 610 | } |
| 611 | |
| 612 | static void rfkill_led_trigger_unregister(struct rfkill *rfkill) |
| 613 | { |
| 614 | #ifdef CONFIG_RFKILL_LEDS |
Henrique de Moraes Holschuh | 37f55e9 | 2008-07-21 21:18:18 -0300 | [diff] [blame] | 615 | if (rfkill->led_trigger.name) { |
Michael Buesch | 135900c | 2007-09-27 21:33:12 +0200 | [diff] [blame] | 616 | led_trigger_unregister(&rfkill->led_trigger); |
Henrique de Moraes Holschuh | 37f55e9 | 2008-07-21 21:18:18 -0300 | [diff] [blame] | 617 | rfkill->led_trigger.name = NULL; |
| 618 | } |
Michael Buesch | 135900c | 2007-09-27 21:33:12 +0200 | [diff] [blame] | 619 | #endif |
| 620 | } |
| 621 | |
Ivo van Doorn | cf4328c | 2007-05-07 00:34:20 -0700 | [diff] [blame] | 622 | /** |
| 623 | * rfkill_register - Register a rfkill structure. |
| 624 | * @rfkill: rfkill structure to be registered |
| 625 | * |
| 626 | * This function should be called by the network driver when the rfkill |
| 627 | * structure needs to be registered. Immediately from registration the |
| 628 | * switch driver should be able to service calls to toggle_radio. |
| 629 | */ |
| 630 | int rfkill_register(struct rfkill *rfkill) |
| 631 | { |
| 632 | static atomic_t rfkill_no = ATOMIC_INIT(0); |
| 633 | struct device *dev = &rfkill->dev; |
| 634 | int error; |
| 635 | |
| 636 | if (!rfkill->toggle_radio) |
| 637 | return -EINVAL; |
Michael Buesch | 7319f1e | 2007-10-28 15:16:50 +0100 | [diff] [blame] | 638 | if (rfkill->type >= RFKILL_TYPE_MAX) |
| 639 | return -EINVAL; |
Ivo van Doorn | cf4328c | 2007-05-07 00:34:20 -0700 | [diff] [blame] | 640 | |
Michael Buesch | 8a8f1c0 | 2007-10-28 13:07:54 +0100 | [diff] [blame] | 641 | snprintf(dev->bus_id, sizeof(dev->bus_id), |
| 642 | "rfkill%ld", (long)atomic_inc_return(&rfkill_no) - 1); |
| 643 | |
| 644 | rfkill_led_trigger_register(rfkill); |
| 645 | |
Ivo van Doorn | cf4328c | 2007-05-07 00:34:20 -0700 | [diff] [blame] | 646 | error = rfkill_add_switch(rfkill); |
Eric Paris | 632041f | 2008-01-13 16:20:56 -0500 | [diff] [blame] | 647 | if (error) { |
| 648 | rfkill_led_trigger_unregister(rfkill); |
Ivo van Doorn | cf4328c | 2007-05-07 00:34:20 -0700 | [diff] [blame] | 649 | return error; |
Eric Paris | 632041f | 2008-01-13 16:20:56 -0500 | [diff] [blame] | 650 | } |
Ivo van Doorn | cf4328c | 2007-05-07 00:34:20 -0700 | [diff] [blame] | 651 | |
Ivo van Doorn | cf4328c | 2007-05-07 00:34:20 -0700 | [diff] [blame] | 652 | error = device_add(dev); |
| 653 | if (error) { |
| 654 | rfkill_remove_switch(rfkill); |
Henrique de Moraes Holschuh | 37f55e9 | 2008-07-21 21:18:18 -0300 | [diff] [blame] | 655 | rfkill_led_trigger_unregister(rfkill); |
Ivo van Doorn | cf4328c | 2007-05-07 00:34:20 -0700 | [diff] [blame] | 656 | return error; |
| 657 | } |
| 658 | |
| 659 | return 0; |
| 660 | } |
| 661 | EXPORT_SYMBOL(rfkill_register); |
| 662 | |
| 663 | /** |
Henrique de Moraes Holschuh | c8fcd90 | 2008-06-23 17:22:57 -0300 | [diff] [blame] | 664 | * rfkill_unregister - Unregister a rfkill structure. |
Ivo van Doorn | cf4328c | 2007-05-07 00:34:20 -0700 | [diff] [blame] | 665 | * @rfkill: rfkill structure to be unregistered |
| 666 | * |
| 667 | * This function should be called by the network driver during device |
| 668 | * teardown to destroy rfkill structure. Note that rfkill_free() should |
| 669 | * _not_ be called after rfkill_unregister(). |
| 670 | */ |
| 671 | void rfkill_unregister(struct rfkill *rfkill) |
| 672 | { |
Ivo van Doorn | cf4328c | 2007-05-07 00:34:20 -0700 | [diff] [blame] | 673 | device_del(&rfkill->dev); |
| 674 | rfkill_remove_switch(rfkill); |
Michael Buesch | 8a8f1c0 | 2007-10-28 13:07:54 +0100 | [diff] [blame] | 675 | rfkill_led_trigger_unregister(rfkill); |
Ivo van Doorn | cf4328c | 2007-05-07 00:34:20 -0700 | [diff] [blame] | 676 | put_device(&rfkill->dev); |
| 677 | } |
| 678 | EXPORT_SYMBOL(rfkill_unregister); |
| 679 | |
| 680 | /* |
| 681 | * Rfkill module initialization/deinitialization. |
| 682 | */ |
| 683 | static int __init rfkill_init(void) |
| 684 | { |
| 685 | int error; |
| 686 | int i; |
| 687 | |
Henrique de Moraes Holschuh | 5005657 | 2008-06-23 17:46:42 -0300 | [diff] [blame] | 688 | /* RFKILL_STATE_HARD_BLOCKED is illegal here... */ |
| 689 | if (rfkill_default_state != RFKILL_STATE_SOFT_BLOCKED && |
| 690 | rfkill_default_state != RFKILL_STATE_UNBLOCKED) |
Henrique de Moraes Holschuh | e954b0b | 2008-06-23 17:22:59 -0300 | [diff] [blame] | 691 | return -EINVAL; |
| 692 | |
Ivo van Doorn | cf4328c | 2007-05-07 00:34:20 -0700 | [diff] [blame] | 693 | for (i = 0; i < ARRAY_SIZE(rfkill_states); i++) |
Henrique de Moraes Holschuh | e954b0b | 2008-06-23 17:22:59 -0300 | [diff] [blame] | 694 | rfkill_states[i] = rfkill_default_state; |
Ivo van Doorn | cf4328c | 2007-05-07 00:34:20 -0700 | [diff] [blame] | 695 | |
| 696 | error = class_register(&rfkill_class); |
| 697 | if (error) { |
| 698 | printk(KERN_ERR "rfkill: unable to register rfkill class\n"); |
| 699 | return error; |
| 700 | } |
| 701 | |
Henrique de Moraes Holschuh | ffb67c3 | 2008-06-23 17:23:05 -0300 | [diff] [blame] | 702 | register_rfkill_notifier(&rfkill_blocking_uevent_nb); |
| 703 | |
Ivo van Doorn | cf4328c | 2007-05-07 00:34:20 -0700 | [diff] [blame] | 704 | return 0; |
| 705 | } |
| 706 | |
| 707 | static void __exit rfkill_exit(void) |
| 708 | { |
Henrique de Moraes Holschuh | ffb67c3 | 2008-06-23 17:23:05 -0300 | [diff] [blame] | 709 | unregister_rfkill_notifier(&rfkill_blocking_uevent_nb); |
Ivo van Doorn | cf4328c | 2007-05-07 00:34:20 -0700 | [diff] [blame] | 710 | class_unregister(&rfkill_class); |
| 711 | } |
| 712 | |
Michael Buesch | 2bf236d | 2007-10-28 14:39:02 +0100 | [diff] [blame] | 713 | subsys_initcall(rfkill_init); |
Ivo van Doorn | cf4328c | 2007-05-07 00:34:20 -0700 | [diff] [blame] | 714 | module_exit(rfkill_exit); |