2 * Copyright (C) 2006 - 2007 Ivo van Doorn
3 * Copyright (C) 2007 Dmitry Torokhov
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.
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.
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.
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>
30 /* Get declaration of rfkill_switch_all() to shut up sparse. */
31 #include "rfkill-input.h"
34 MODULE_AUTHOR("Ivo van Doorn <IvDoorn@gmail.com>");
35 MODULE_VERSION("1.0");
36 MODULE_DESCRIPTION("RF switch support");
37 MODULE_LICENSE("GPL");
39 static LIST_HEAD(rfkill_list); /* list of registered rf switches */
40 static DEFINE_MUTEX(rfkill_global_mutex);
42 static unsigned int rfkill_default_state = RFKILL_STATE_UNBLOCKED;
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");
47 struct rfkill_gsw_state {
48 enum rfkill_state current_state;
49 enum rfkill_state default_state;
52 static struct rfkill_gsw_state rfkill_global_states[RFKILL_TYPE_MAX];
53 static unsigned long rfkill_states_lockdflt[BITS_TO_LONGS(RFKILL_TYPE_MAX)];
54 static bool rfkill_epo_lock_active;
57 #ifdef CONFIG_RFKILL_LEDS
58 static void rfkill_led_trigger(struct rfkill *rfkill,
59 enum rfkill_state state)
61 struct led_trigger *led = &rfkill->led_trigger;
65 if (state != RFKILL_STATE_UNBLOCKED)
66 led_trigger_event(led, LED_OFF);
68 led_trigger_event(led, LED_FULL);
71 static void rfkill_led_trigger_activate(struct led_classdev *led)
73 struct rfkill *rfkill = container_of(led->trigger,
74 struct rfkill, led_trigger);
76 rfkill_led_trigger(rfkill, rfkill->state);
78 #endif /* CONFIG_RFKILL_LEDS */
80 static void rfkill_uevent(struct rfkill *rfkill)
82 kobject_uevent(&rfkill->dev.kobj, KOBJ_CHANGE);
85 static void update_rfkill_state(struct rfkill *rfkill)
87 enum rfkill_state newstate, oldstate;
89 if (rfkill->get_state) {
90 mutex_lock(&rfkill->mutex);
91 if (!rfkill->get_state(rfkill->data, &newstate)) {
92 oldstate = rfkill->state;
93 rfkill->state = newstate;
94 if (oldstate != newstate)
95 rfkill_uevent(rfkill);
97 mutex_unlock(&rfkill->mutex);
99 rfkill_led_trigger(rfkill, rfkill->state);
103 * rfkill_toggle_radio - wrapper for toggle_radio hook
104 * @rfkill: the rfkill struct to use
105 * @force: calls toggle_radio even if cache says it is not needed,
106 * and also makes sure notifications of the state will be
107 * sent even if it didn't change
108 * @state: the new state to call toggle_radio() with
110 * Calls rfkill->toggle_radio, enforcing the API for toggle_radio
111 * calls and handling all the red tape such as issuing notifications
112 * if the call is successful.
114 * Suspended devices are not touched at all, and -EAGAIN is returned.
116 * Note that the @force parameter cannot override a (possibly cached)
117 * state of RFKILL_STATE_HARD_BLOCKED. Any device making use of
118 * RFKILL_STATE_HARD_BLOCKED implements either get_state() or
119 * rfkill_force_state(), so the cache either is bypassed or valid.
121 * Note that we do call toggle_radio for RFKILL_STATE_SOFT_BLOCKED
122 * even if the radio is in RFKILL_STATE_HARD_BLOCKED state, so as to
123 * give the driver a hint that it should double-BLOCK the transmitter.
125 * Caller must have acquired rfkill->mutex.
127 static int rfkill_toggle_radio(struct rfkill *rfkill,
128 enum rfkill_state state,
132 enum rfkill_state oldstate, newstate;
134 if (unlikely(rfkill->dev.power.power_state.event & PM_EVENT_SLEEP))
137 oldstate = rfkill->state;
139 if (rfkill->get_state && !force &&
140 !rfkill->get_state(rfkill->data, &newstate)) {
141 rfkill->state = newstate;
145 case RFKILL_STATE_HARD_BLOCKED:
146 /* typically happens when refreshing hardware state,
147 * such as on resume */
148 state = RFKILL_STATE_SOFT_BLOCKED;
150 case RFKILL_STATE_UNBLOCKED:
151 /* force can't override this, only rfkill_force_state() can */
152 if (rfkill->state == RFKILL_STATE_HARD_BLOCKED)
155 case RFKILL_STATE_SOFT_BLOCKED:
156 /* nothing to do, we want to give drivers the hint to double
157 * BLOCK even a transmitter that is already in state
158 * RFKILL_STATE_HARD_BLOCKED */
162 "rfkill: illegal state %d passed as parameter "
163 "to rfkill_toggle_radio\n", state);
167 if (force || state != rfkill->state) {
168 retval = rfkill->toggle_radio(rfkill->data, state);
169 /* never allow a HARD->SOFT downgrade! */
170 if (!retval && rfkill->state != RFKILL_STATE_HARD_BLOCKED)
171 rfkill->state = state;
174 if (force || rfkill->state != oldstate)
175 rfkill_uevent(rfkill);
177 rfkill_led_trigger(rfkill, rfkill->state);
182 * __rfkill_switch_all - Toggle state of all switches of given type
183 * @type: type of interfaces to be affected
184 * @state: the new state
186 * This function toggles the state of all switches of given type,
187 * unless a specific switch is claimed by userspace (in which case,
188 * that switch is left alone) or suspended.
190 * Caller must have acquired rfkill_global_mutex.
192 static void __rfkill_switch_all(const enum rfkill_type type,
193 const enum rfkill_state state)
195 struct rfkill *rfkill;
197 if (WARN((state >= RFKILL_STATE_MAX || type >= RFKILL_TYPE_MAX),
199 "rfkill: illegal state %d or type %d "
200 "passed as parameter to __rfkill_switch_all\n",
204 rfkill_global_states[type].current_state = state;
205 list_for_each_entry(rfkill, &rfkill_list, node) {
206 if (rfkill->type == type) {
207 mutex_lock(&rfkill->mutex);
208 rfkill_toggle_radio(rfkill, state, 0);
209 mutex_unlock(&rfkill->mutex);
210 rfkill_led_trigger(rfkill, rfkill->state);
216 * rfkill_switch_all - Toggle state of all switches of given type
217 * @type: type of interfaces to be affected
218 * @state: the new state
220 * Acquires rfkill_global_mutex and calls __rfkill_switch_all(@type, @state).
221 * Please refer to __rfkill_switch_all() for details.
223 * Does nothing if the EPO lock is active.
225 void rfkill_switch_all(enum rfkill_type type, enum rfkill_state state)
227 mutex_lock(&rfkill_global_mutex);
228 if (!rfkill_epo_lock_active)
229 __rfkill_switch_all(type, state);
230 mutex_unlock(&rfkill_global_mutex);
232 EXPORT_SYMBOL(rfkill_switch_all);
235 * rfkill_epo - emergency power off all transmitters
237 * This kicks all non-suspended rfkill devices to RFKILL_STATE_SOFT_BLOCKED,
238 * ignoring everything in its path but rfkill_global_mutex and rfkill->mutex.
240 * The global state before the EPO is saved and can be restored later
241 * using rfkill_restore_states().
243 void rfkill_epo(void)
245 struct rfkill *rfkill;
248 mutex_lock(&rfkill_global_mutex);
250 rfkill_epo_lock_active = true;
251 list_for_each_entry(rfkill, &rfkill_list, node) {
252 mutex_lock(&rfkill->mutex);
253 rfkill_toggle_radio(rfkill, RFKILL_STATE_SOFT_BLOCKED, 1);
254 mutex_unlock(&rfkill->mutex);
256 for (i = 0; i < RFKILL_TYPE_MAX; i++) {
257 rfkill_global_states[i].default_state =
258 rfkill_global_states[i].current_state;
259 rfkill_global_states[i].current_state =
260 RFKILL_STATE_SOFT_BLOCKED;
262 mutex_unlock(&rfkill_global_mutex);
263 rfkill_led_trigger(rfkill, rfkill->state);
265 EXPORT_SYMBOL_GPL(rfkill_epo);
268 * rfkill_restore_states - restore global states
270 * Restore (and sync switches to) the global state from the
271 * states in rfkill_default_states. This can undo the effects of
272 * a call to rfkill_epo().
274 void rfkill_restore_states(void)
278 mutex_lock(&rfkill_global_mutex);
280 rfkill_epo_lock_active = false;
281 for (i = 0; i < RFKILL_TYPE_MAX; i++)
282 __rfkill_switch_all(i, rfkill_global_states[i].default_state);
283 mutex_unlock(&rfkill_global_mutex);
285 EXPORT_SYMBOL_GPL(rfkill_restore_states);
288 * rfkill_remove_epo_lock - unlock state changes
290 * Used by rfkill-input manually unlock state changes, when
291 * the EPO switch is deactivated.
293 void rfkill_remove_epo_lock(void)
295 mutex_lock(&rfkill_global_mutex);
296 rfkill_epo_lock_active = false;
297 mutex_unlock(&rfkill_global_mutex);
299 EXPORT_SYMBOL_GPL(rfkill_remove_epo_lock);
302 * rfkill_is_epo_lock_active - returns true EPO is active
304 * Returns 0 (false) if there is NOT an active EPO contidion,
305 * and 1 (true) if there is an active EPO contition, which
306 * locks all radios in one of the BLOCKED states.
308 * Can be called in atomic context.
310 bool rfkill_is_epo_lock_active(void)
312 return rfkill_epo_lock_active;
314 EXPORT_SYMBOL_GPL(rfkill_is_epo_lock_active);
317 * rfkill_get_global_state - returns global state for a type
318 * @type: the type to get the global state of
320 * Returns the current global state for a given wireless
323 enum rfkill_state rfkill_get_global_state(const enum rfkill_type type)
325 return rfkill_global_states[type].current_state;
327 EXPORT_SYMBOL_GPL(rfkill_get_global_state);
330 * rfkill_force_state - Force the internal rfkill radio state
331 * @rfkill: pointer to the rfkill class to modify.
332 * @state: the current radio state the class should be forced to.
334 * This function updates the internal state of the radio cached
335 * by the rfkill class. It should be used when the driver gets
336 * a notification by the firmware/hardware of the current *real*
337 * state of the radio rfkill switch.
339 * Devices which are subject to external changes on their rfkill
340 * state (such as those caused by a hardware rfkill line) MUST
341 * have their driver arrange to call rfkill_force_state() as soon
342 * as possible after such a change.
344 * This function may not be called from an atomic context.
346 int rfkill_force_state(struct rfkill *rfkill, enum rfkill_state state)
348 enum rfkill_state oldstate;
351 if (WARN((state >= RFKILL_STATE_MAX),
353 "rfkill: illegal state %d passed as parameter "
354 "to rfkill_force_state\n", state))
357 mutex_lock(&rfkill->mutex);
359 oldstate = rfkill->state;
360 rfkill->state = state;
362 if (state != oldstate)
363 rfkill_uevent(rfkill);
365 mutex_unlock(&rfkill->mutex);
366 rfkill_led_trigger(rfkill, rfkill->state);
370 EXPORT_SYMBOL(rfkill_force_state);
372 static ssize_t rfkill_name_show(struct device *dev,
373 struct device_attribute *attr,
376 struct rfkill *rfkill = to_rfkill(dev);
378 return sprintf(buf, "%s\n", rfkill->name);
381 static const char *rfkill_get_type_str(enum rfkill_type type)
384 case RFKILL_TYPE_WLAN:
386 case RFKILL_TYPE_BLUETOOTH:
388 case RFKILL_TYPE_UWB:
389 return "ultrawideband";
390 case RFKILL_TYPE_WIMAX:
392 case RFKILL_TYPE_WWAN:
399 static ssize_t rfkill_type_show(struct device *dev,
400 struct device_attribute *attr,
403 struct rfkill *rfkill = to_rfkill(dev);
405 return sprintf(buf, "%s\n", rfkill_get_type_str(rfkill->type));
408 static ssize_t rfkill_state_show(struct device *dev,
409 struct device_attribute *attr,
412 struct rfkill *rfkill = to_rfkill(dev);
414 update_rfkill_state(rfkill);
415 return sprintf(buf, "%d\n", rfkill->state);
418 static ssize_t rfkill_state_store(struct device *dev,
419 struct device_attribute *attr,
420 const char *buf, size_t count)
422 struct rfkill *rfkill = to_rfkill(dev);
426 if (!capable(CAP_NET_ADMIN))
429 error = strict_strtoul(buf, 0, &state);
433 /* RFKILL_STATE_HARD_BLOCKED is illegal here... */
434 if (state != RFKILL_STATE_UNBLOCKED &&
435 state != RFKILL_STATE_SOFT_BLOCKED)
438 error = mutex_lock_killable(&rfkill->mutex);
442 if (!rfkill_epo_lock_active)
443 error = rfkill_toggle_radio(rfkill, state, 0);
447 mutex_unlock(&rfkill->mutex);
449 return error ? error : count;
452 static ssize_t rfkill_claim_show(struct device *dev,
453 struct device_attribute *attr,
456 return sprintf(buf, "%d\n", 0);
459 static ssize_t rfkill_claim_store(struct device *dev,
460 struct device_attribute *attr,
461 const char *buf, size_t count)
466 static struct device_attribute rfkill_dev_attrs[] = {
467 __ATTR(name, S_IRUGO, rfkill_name_show, NULL),
468 __ATTR(type, S_IRUGO, rfkill_type_show, NULL),
469 __ATTR(state, S_IRUGO|S_IWUSR, rfkill_state_show, rfkill_state_store),
470 __ATTR(claim, S_IRUGO|S_IWUSR, rfkill_claim_show, rfkill_claim_store),
474 static void rfkill_release(struct device *dev)
476 struct rfkill *rfkill = to_rfkill(dev);
479 module_put(THIS_MODULE);
483 static int rfkill_suspend(struct device *dev, pm_message_t state)
485 struct rfkill *rfkill = to_rfkill(dev);
487 /* mark class device as suspended */
488 if (dev->power.power_state.event != state.event)
489 dev->power.power_state = state;
491 /* store state for the resume handler */
492 rfkill->state_for_resume = rfkill->state;
497 static int rfkill_resume(struct device *dev)
499 struct rfkill *rfkill = to_rfkill(dev);
500 enum rfkill_state newstate;
502 if (dev->power.power_state.event != PM_EVENT_ON) {
503 mutex_lock(&rfkill->mutex);
505 dev->power.power_state.event = PM_EVENT_ON;
508 * rfkill->state could have been modified before we got
509 * called, and won't be updated by rfkill_toggle_radio()
510 * in force mode. Sync it FIRST.
512 if (rfkill->get_state &&
513 !rfkill->get_state(rfkill->data, &newstate))
514 rfkill->state = newstate;
517 * If we are under EPO, kick transmitter offline,
518 * otherwise restore to pre-suspend state.
520 * Issue a notification in any case
522 rfkill_toggle_radio(rfkill,
523 rfkill_epo_lock_active ?
524 RFKILL_STATE_SOFT_BLOCKED :
525 rfkill->state_for_resume,
528 mutex_unlock(&rfkill->mutex);
529 rfkill_led_trigger(rfkill, rfkill->state);
535 #define rfkill_suspend NULL
536 #define rfkill_resume NULL
539 static int rfkill_dev_uevent(struct device *dev, struct kobj_uevent_env *env)
541 struct rfkill *rfkill = to_rfkill(dev);
544 error = add_uevent_var(env, "RFKILL_NAME=%s", rfkill->name);
547 error = add_uevent_var(env, "RFKILL_TYPE=%s",
548 rfkill_get_type_str(rfkill->type));
551 error = add_uevent_var(env, "RFKILL_STATE=%d", rfkill->state);
555 static struct class rfkill_class = {
557 .dev_release = rfkill_release,
558 .dev_attrs = rfkill_dev_attrs,
559 .suspend = rfkill_suspend,
560 .resume = rfkill_resume,
561 .dev_uevent = rfkill_dev_uevent,
564 static int rfkill_check_duplicity(const struct rfkill *rfkill)
567 unsigned long seen[BITS_TO_LONGS(RFKILL_TYPE_MAX)];
569 memset(seen, 0, sizeof(seen));
571 list_for_each_entry(p, &rfkill_list, node) {
572 if (WARN((p == rfkill), KERN_WARNING
573 "rfkill: illegal attempt to register "
574 "an already registered rfkill struct\n"))
576 set_bit(p->type, seen);
579 /* 0: first switch of its kind */
580 return (test_bit(rfkill->type, seen)) ? 1 : 0;
583 static int rfkill_add_switch(struct rfkill *rfkill)
587 mutex_lock(&rfkill_global_mutex);
589 error = rfkill_check_duplicity(rfkill);
594 /* lock default after first use */
595 set_bit(rfkill->type, rfkill_states_lockdflt);
596 rfkill_global_states[rfkill->type].current_state =
597 rfkill_global_states[rfkill->type].default_state;
600 rfkill_toggle_radio(rfkill,
601 rfkill_global_states[rfkill->type].current_state,
604 list_add_tail(&rfkill->node, &rfkill_list);
608 mutex_unlock(&rfkill_global_mutex);
613 static void rfkill_remove_switch(struct rfkill *rfkill)
615 mutex_lock(&rfkill_global_mutex);
616 list_del_init(&rfkill->node);
617 mutex_unlock(&rfkill_global_mutex);
619 mutex_lock(&rfkill->mutex);
620 rfkill_toggle_radio(rfkill, RFKILL_STATE_SOFT_BLOCKED, 1);
621 mutex_unlock(&rfkill->mutex);
625 * rfkill_allocate - allocate memory for rfkill structure.
626 * @parent: device that has rf switch on it
627 * @type: type of the switch (RFKILL_TYPE_*)
629 * This function should be called by the network driver when it needs
630 * rfkill structure. Once the structure is allocated the driver should
631 * finish its initialization by setting the name, private data, enable_radio
632 * and disable_radio methods and then register it with rfkill_register().
634 * NOTE: If registration fails the structure shoudl be freed by calling
635 * rfkill_free() otherwise rfkill_unregister() should be used.
637 struct rfkill * __must_check rfkill_allocate(struct device *parent,
638 enum rfkill_type type)
640 struct rfkill *rfkill;
643 if (WARN((type >= RFKILL_TYPE_MAX),
645 "rfkill: illegal type %d passed as parameter "
646 "to rfkill_allocate\n", type))
649 rfkill = kzalloc(sizeof(struct rfkill), GFP_KERNEL);
653 mutex_init(&rfkill->mutex);
654 INIT_LIST_HEAD(&rfkill->node);
658 dev->class = &rfkill_class;
659 dev->parent = parent;
660 device_initialize(dev);
662 __module_get(THIS_MODULE);
666 EXPORT_SYMBOL(rfkill_allocate);
669 * rfkill_free - Mark rfkill structure for deletion
670 * @rfkill: rfkill structure to be destroyed
672 * Decrements reference count of the rfkill structure so it is destroyed.
673 * Note that rfkill_free() should _not_ be called after rfkill_unregister().
675 void rfkill_free(struct rfkill *rfkill)
678 put_device(&rfkill->dev);
680 EXPORT_SYMBOL(rfkill_free);
682 static void rfkill_led_trigger_register(struct rfkill *rfkill)
684 #ifdef CONFIG_RFKILL_LEDS
687 if (!rfkill->led_trigger.name)
688 rfkill->led_trigger.name = dev_name(&rfkill->dev);
689 if (!rfkill->led_trigger.activate)
690 rfkill->led_trigger.activate = rfkill_led_trigger_activate;
691 error = led_trigger_register(&rfkill->led_trigger);
693 rfkill->led_trigger.name = NULL;
694 #endif /* CONFIG_RFKILL_LEDS */
697 static void rfkill_led_trigger_unregister(struct rfkill *rfkill)
699 #ifdef CONFIG_RFKILL_LEDS
700 if (rfkill->led_trigger.name) {
701 led_trigger_unregister(&rfkill->led_trigger);
702 rfkill->led_trigger.name = NULL;
708 * rfkill_register - Register a rfkill structure.
709 * @rfkill: rfkill structure to be registered
711 * This function should be called by the network driver when the rfkill
712 * structure needs to be registered. Immediately from registration the
713 * switch driver should be able to service calls to toggle_radio.
715 int __must_check rfkill_register(struct rfkill *rfkill)
717 static atomic_t rfkill_no = ATOMIC_INIT(0);
718 struct device *dev = &rfkill->dev;
721 if (WARN((!rfkill || !rfkill->toggle_radio ||
722 rfkill->type >= RFKILL_TYPE_MAX ||
723 rfkill->state >= RFKILL_STATE_MAX),
725 "rfkill: attempt to register a "
726 "badly initialized rfkill struct\n"))
729 dev_set_name(dev, "rfkill%ld", (long)atomic_inc_return(&rfkill_no) - 1);
731 rfkill_led_trigger_register(rfkill);
733 error = rfkill_add_switch(rfkill);
735 rfkill_led_trigger_unregister(rfkill);
739 error = device_add(dev);
741 rfkill_remove_switch(rfkill);
742 rfkill_led_trigger_unregister(rfkill);
748 EXPORT_SYMBOL(rfkill_register);
751 * rfkill_unregister - Unregister a rfkill structure.
752 * @rfkill: rfkill structure to be unregistered
754 * This function should be called by the network driver during device
755 * teardown to destroy rfkill structure. Note that rfkill_free() should
756 * _not_ be called after rfkill_unregister().
758 void rfkill_unregister(struct rfkill *rfkill)
761 device_del(&rfkill->dev);
762 rfkill_remove_switch(rfkill);
763 rfkill_led_trigger_unregister(rfkill);
764 put_device(&rfkill->dev);
766 EXPORT_SYMBOL(rfkill_unregister);
769 * rfkill_set_default - set initial value for a switch type
770 * @type - the type of switch to set the default state of
771 * @state - the new default state for that group of switches
773 * Sets the initial state rfkill should use for a given type.
774 * The following initial states are allowed: RFKILL_STATE_SOFT_BLOCKED
775 * and RFKILL_STATE_UNBLOCKED.
777 * This function is meant to be used by platform drivers for platforms
778 * that can save switch state across power down/reboot.
780 * The default state for each switch type can be changed exactly once.
781 * After a switch of that type is registered, the default state cannot
782 * be changed anymore. This guards against multiple drivers it the
783 * same platform trying to set the initial switch default state, which
786 * Returns -EPERM if the state has already been set once or is in use,
787 * so drivers likely want to either ignore or at most printk(KERN_NOTICE)
788 * if this function returns -EPERM.
790 * Returns 0 if the new default state was set, or an error if it
793 int rfkill_set_default(enum rfkill_type type, enum rfkill_state state)
797 if (WARN((type >= RFKILL_TYPE_MAX ||
798 (state != RFKILL_STATE_SOFT_BLOCKED &&
799 state != RFKILL_STATE_UNBLOCKED)),
801 "rfkill: illegal state %d or type %d passed as "
802 "parameter to rfkill_set_default\n", state, type))
805 mutex_lock(&rfkill_global_mutex);
807 if (!test_and_set_bit(type, rfkill_states_lockdflt)) {
808 rfkill_global_states[type].default_state = state;
809 rfkill_global_states[type].current_state = state;
814 mutex_unlock(&rfkill_global_mutex);
817 EXPORT_SYMBOL_GPL(rfkill_set_default);
820 * Rfkill module initialization/deinitialization.
822 static int __init rfkill_init(void)
827 /* RFKILL_STATE_HARD_BLOCKED is illegal here... */
828 if (rfkill_default_state != RFKILL_STATE_SOFT_BLOCKED &&
829 rfkill_default_state != RFKILL_STATE_UNBLOCKED)
832 for (i = 0; i < RFKILL_TYPE_MAX; i++)
833 rfkill_global_states[i].default_state = rfkill_default_state;
835 error = class_register(&rfkill_class);
837 printk(KERN_ERR "rfkill: unable to register rfkill class\n");
844 static void __exit rfkill_exit(void)
846 class_unregister(&rfkill_class);
849 subsys_initcall(rfkill_init);
850 module_exit(rfkill_exit);