diff options
Diffstat (limited to 'net/rfkill')
-rw-r--r-- | net/rfkill/rfkill.c | 83 |
1 files changed, 5 insertions, 78 deletions
diff --git a/net/rfkill/rfkill.c b/net/rfkill/rfkill.c index 051d2c9ea66b..3c94f76d5525 100644 --- a/net/rfkill/rfkill.c +++ b/net/rfkill/rfkill.c | |||
@@ -53,51 +53,6 @@ static struct rfkill_gsw_state rfkill_global_states[RFKILL_TYPE_MAX]; | |||
53 | static unsigned long rfkill_states_lockdflt[BITS_TO_LONGS(RFKILL_TYPE_MAX)]; | 53 | static unsigned long rfkill_states_lockdflt[BITS_TO_LONGS(RFKILL_TYPE_MAX)]; |
54 | static bool rfkill_epo_lock_active; | 54 | static bool rfkill_epo_lock_active; |
55 | 55 | ||
56 | static BLOCKING_NOTIFIER_HEAD(rfkill_notifier_list); | ||
57 | |||
58 | |||
59 | /** | ||
60 | * register_rfkill_notifier - Add notifier to rfkill notifier chain | ||
61 | * @nb: pointer to the new entry to add to the chain | ||
62 | * | ||
63 | * See blocking_notifier_chain_register() for return value and further | ||
64 | * observations. | ||
65 | * | ||
66 | * Adds a notifier to the rfkill notifier chain. The chain will be | ||
67 | * called with a pointer to the relevant rfkill structure as a parameter, | ||
68 | * refer to include/linux/rfkill.h for the possible events. | ||
69 | * | ||
70 | * Notifiers added to this chain are to always return NOTIFY_DONE. This | ||
71 | * chain is a blocking notifier chain: notifiers can sleep. | ||
72 | * | ||
73 | * Calls to this chain may have been done through a workqueue. One must | ||
74 | * assume unordered asynchronous behaviour, there is no way to know if | ||
75 | * actions related to the event that generated the notification have been | ||
76 | * carried out already. | ||
77 | */ | ||
78 | int register_rfkill_notifier(struct notifier_block *nb) | ||
79 | { | ||
80 | BUG_ON(!nb); | ||
81 | return blocking_notifier_chain_register(&rfkill_notifier_list, nb); | ||
82 | } | ||
83 | EXPORT_SYMBOL_GPL(register_rfkill_notifier); | ||
84 | |||
85 | /** | ||
86 | * unregister_rfkill_notifier - remove notifier from rfkill notifier chain | ||
87 | * @nb: pointer to the entry to remove from the chain | ||
88 | * | ||
89 | * See blocking_notifier_chain_unregister() for return value and further | ||
90 | * observations. | ||
91 | * | ||
92 | * Removes a notifier from the rfkill notifier chain. | ||
93 | */ | ||
94 | int unregister_rfkill_notifier(struct notifier_block *nb) | ||
95 | { | ||
96 | BUG_ON(!nb); | ||
97 | return blocking_notifier_chain_unregister(&rfkill_notifier_list, nb); | ||
98 | } | ||
99 | EXPORT_SYMBOL_GPL(unregister_rfkill_notifier); | ||
100 | |||
101 | 56 | ||
102 | static void rfkill_led_trigger(struct rfkill *rfkill, | 57 | static void rfkill_led_trigger(struct rfkill *rfkill, |
103 | enum rfkill_state state) | 58 | enum rfkill_state state) |
@@ -124,12 +79,9 @@ static void rfkill_led_trigger_activate(struct led_classdev *led) | |||
124 | } | 79 | } |
125 | #endif /* CONFIG_RFKILL_LEDS */ | 80 | #endif /* CONFIG_RFKILL_LEDS */ |
126 | 81 | ||
127 | static void notify_rfkill_state_change(struct rfkill *rfkill) | 82 | static void rfkill_uevent(struct rfkill *rfkill) |
128 | { | 83 | { |
129 | rfkill_led_trigger(rfkill, rfkill->state); | 84 | kobject_uevent(&rfkill->dev.kobj, KOBJ_CHANGE); |
130 | blocking_notifier_call_chain(&rfkill_notifier_list, | ||
131 | RFKILL_STATE_CHANGED, | ||
132 | rfkill); | ||
133 | } | 85 | } |
134 | 86 | ||
135 | static void update_rfkill_state(struct rfkill *rfkill) | 87 | static void update_rfkill_state(struct rfkill *rfkill) |
@@ -142,7 +94,7 @@ static void update_rfkill_state(struct rfkill *rfkill) | |||
142 | oldstate = rfkill->state; | 94 | oldstate = rfkill->state; |
143 | rfkill->state = newstate; | 95 | rfkill->state = newstate; |
144 | if (oldstate != newstate) | 96 | if (oldstate != newstate) |
145 | notify_rfkill_state_change(rfkill); | 97 | rfkill_uevent(rfkill); |
146 | } | 98 | } |
147 | mutex_unlock(&rfkill->mutex); | 99 | mutex_unlock(&rfkill->mutex); |
148 | } | 100 | } |
@@ -220,7 +172,7 @@ static int rfkill_toggle_radio(struct rfkill *rfkill, | |||
220 | } | 172 | } |
221 | 173 | ||
222 | if (force || rfkill->state != oldstate) | 174 | if (force || rfkill->state != oldstate) |
223 | notify_rfkill_state_change(rfkill); | 175 | rfkill_uevent(rfkill); |
224 | 176 | ||
225 | return retval; | 177 | return retval; |
226 | } | 178 | } |
@@ -405,7 +357,7 @@ int rfkill_force_state(struct rfkill *rfkill, enum rfkill_state state) | |||
405 | rfkill->state = state; | 357 | rfkill->state = state; |
406 | 358 | ||
407 | if (state != oldstate) | 359 | if (state != oldstate) |
408 | notify_rfkill_state_change(rfkill); | 360 | rfkill_uevent(rfkill); |
409 | 361 | ||
410 | mutex_unlock(&rfkill->mutex); | 362 | mutex_unlock(&rfkill->mutex); |
411 | 363 | ||
@@ -618,28 +570,6 @@ static int rfkill_resume(struct device *dev) | |||
618 | #define rfkill_resume NULL | 570 | #define rfkill_resume NULL |
619 | #endif | 571 | #endif |
620 | 572 | ||
621 | static int rfkill_blocking_uevent_notifier(struct notifier_block *nb, | ||
622 | unsigned long eventid, | ||
623 | void *data) | ||
624 | { | ||
625 | struct rfkill *rfkill = (struct rfkill *)data; | ||
626 | |||
627 | switch (eventid) { | ||
628 | case RFKILL_STATE_CHANGED: | ||
629 | kobject_uevent(&rfkill->dev.kobj, KOBJ_CHANGE); | ||
630 | break; | ||
631 | default: | ||
632 | break; | ||
633 | } | ||
634 | |||
635 | return NOTIFY_DONE; | ||
636 | } | ||
637 | |||
638 | static struct notifier_block rfkill_blocking_uevent_nb = { | ||
639 | .notifier_call = rfkill_blocking_uevent_notifier, | ||
640 | .priority = 0, | ||
641 | }; | ||
642 | |||
643 | static int rfkill_dev_uevent(struct device *dev, struct kobj_uevent_env *env) | 573 | static int rfkill_dev_uevent(struct device *dev, struct kobj_uevent_env *env) |
644 | { | 574 | { |
645 | struct rfkill *rfkill = to_rfkill(dev); | 575 | struct rfkill *rfkill = to_rfkill(dev); |
@@ -942,14 +872,11 @@ static int __init rfkill_init(void) | |||
942 | return error; | 872 | return error; |
943 | } | 873 | } |
944 | 874 | ||
945 | register_rfkill_notifier(&rfkill_blocking_uevent_nb); | ||
946 | |||
947 | return 0; | 875 | return 0; |
948 | } | 876 | } |
949 | 877 | ||
950 | static void __exit rfkill_exit(void) | 878 | static void __exit rfkill_exit(void) |
951 | { | 879 | { |
952 | unregister_rfkill_notifier(&rfkill_blocking_uevent_nb); | ||
953 | class_unregister(&rfkill_class); | 880 | class_unregister(&rfkill_class); |
954 | } | 881 | } |
955 | 882 | ||