aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless
diff options
context:
space:
mode:
authorIvo van Doorn <ivdoorn@gmail.com>2008-07-04 08:51:39 -0400
committerJohn W. Linville <linville@tuxdriver.com>2008-07-08 14:16:03 -0400
commit50db7875d9dcd89f7624b13535738612faf8db0c (patch)
tree40533fe7fc13cad3a343754644757b5809a213c4 /drivers/net/wireless
parentf2cae6c5e41a979f85463aff60877b31fa3a383d (diff)
rt2x00: Remove input_polldev requirements for rfkill
With the new rfkill interface there is no longer a need for the input_polldev. Create a delayed_work structure which we can put on the mac80211 workqueue and poll the hardware every 1000ms. v2: Decrease poll frequency from 100ms to 1000ms Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless')
-rw-r--r--drivers/net/wireless/rt2x00/Kconfig8
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00.h2
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00dev.c2
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00lib.h12
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00rfkill.c107
5 files changed, 38 insertions, 93 deletions
diff --git a/drivers/net/wireless/rt2x00/Kconfig b/drivers/net/wireless/rt2x00/Kconfig
index 3a9b1d72caf8..d485a86bba75 100644
--- a/drivers/net/wireless/rt2x00/Kconfig
+++ b/drivers/net/wireless/rt2x00/Kconfig
@@ -36,9 +36,7 @@ config RT2X00_LIB_FIRMWARE
36config RT2X00_LIB_RFKILL 36config RT2X00_LIB_RFKILL
37 boolean 37 boolean
38 depends on RT2X00_LIB 38 depends on RT2X00_LIB
39 depends on INPUT
40 select RFKILL 39 select RFKILL
41 select INPUT_POLLDEV
42 40
43config RT2X00_LIB_LEDS 41config RT2X00_LIB_LEDS
44 boolean 42 boolean
@@ -57,7 +55,7 @@ config RT2400PCI
57 55
58config RT2400PCI_RFKILL 56config RT2400PCI_RFKILL
59 bool "Ralink rt2400 rfkill support" 57 bool "Ralink rt2400 rfkill support"
60 depends on RT2400PCI && INPUT 58 depends on RT2400PCI
61 select RT2X00_LIB_RFKILL 59 select RT2X00_LIB_RFKILL
62 ---help--- 60 ---help---
63 This adds support for integrated rt2400 hardware that features a 61 This adds support for integrated rt2400 hardware that features a
@@ -85,7 +83,7 @@ config RT2500PCI
85 83
86config RT2500PCI_RFKILL 84config RT2500PCI_RFKILL
87 bool "Ralink rt2500 rfkill support" 85 bool "Ralink rt2500 rfkill support"
88 depends on RT2500PCI && INPUT 86 depends on RT2500PCI
89 select RT2X00_LIB_RFKILL 87 select RT2X00_LIB_RFKILL
90 ---help--- 88 ---help---
91 This adds support for integrated rt2500 hardware that features a 89 This adds support for integrated rt2500 hardware that features a
@@ -115,7 +113,7 @@ config RT61PCI
115 113
116config RT61PCI_RFKILL 114config RT61PCI_RFKILL
117 bool "Ralink rt2501/rt61 rfkill support" 115 bool "Ralink rt2501/rt61 rfkill support"
118 depends on RT61PCI && INPUT 116 depends on RT61PCI
119 select RT2X00_LIB_RFKILL 117 select RT2X00_LIB_RFKILL
120 ---help--- 118 ---help---
121 This adds support for integrated rt61 hardware that features a 119 This adds support for integrated rt61 hardware that features a
diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
index 6842464dcf3e..1b28dad7f204 100644
--- a/drivers/net/wireless/rt2x00/rt2x00.h
+++ b/drivers/net/wireless/rt2x00/rt2x00.h
@@ -649,7 +649,7 @@ struct rt2x00_dev {
649#define RFKILL_STATE_ALLOCATED 1 649#define RFKILL_STATE_ALLOCATED 1
650#define RFKILL_STATE_REGISTERED 2 650#define RFKILL_STATE_REGISTERED 2
651 struct rfkill *rfkill; 651 struct rfkill *rfkill;
652 struct input_polled_dev *poll_dev; 652 struct delayed_work rfkill_work;
653#endif /* CONFIG_RT2X00_LIB_RFKILL */ 653#endif /* CONFIG_RT2X00_LIB_RFKILL */
654 654
655 /* 655 /*
diff --git a/drivers/net/wireless/rt2x00/rt2x00dev.c b/drivers/net/wireless/rt2x00/rt2x00dev.c
index ae8ab71fe474..41b3289b8281 100644
--- a/drivers/net/wireless/rt2x00/rt2x00dev.c
+++ b/drivers/net/wireless/rt2x00/rt2x00dev.c
@@ -1179,7 +1179,6 @@ int rt2x00lib_suspend(struct rt2x00_dev *rt2x00dev, pm_message_t state)
1179 * Suspend/disable extra components. 1179 * Suspend/disable extra components.
1180 */ 1180 */
1181 rt2x00leds_suspend(rt2x00dev); 1181 rt2x00leds_suspend(rt2x00dev);
1182 rt2x00rfkill_suspend(rt2x00dev);
1183 rt2x00debug_deregister(rt2x00dev); 1182 rt2x00debug_deregister(rt2x00dev);
1184 1183
1185exit: 1184exit:
@@ -1235,7 +1234,6 @@ int rt2x00lib_resume(struct rt2x00_dev *rt2x00dev)
1235 * Restore/enable extra components. 1234 * Restore/enable extra components.
1236 */ 1235 */
1237 rt2x00debug_register(rt2x00dev); 1236 rt2x00debug_register(rt2x00dev);
1238 rt2x00rfkill_resume(rt2x00dev);
1239 rt2x00leds_resume(rt2x00dev); 1237 rt2x00leds_resume(rt2x00dev);
1240 1238
1241 /* 1239 /*
diff --git a/drivers/net/wireless/rt2x00/rt2x00lib.h b/drivers/net/wireless/rt2x00/rt2x00lib.h
index 1d1f0749375e..eae5ce1d4de3 100644
--- a/drivers/net/wireless/rt2x00/rt2x00lib.h
+++ b/drivers/net/wireless/rt2x00/rt2x00lib.h
@@ -33,7 +33,7 @@
33 * Both the link tuner as the rfkill will be called once per second. 33 * Both the link tuner as the rfkill will be called once per second.
34 */ 34 */
35#define LINK_TUNE_INTERVAL ( round_jiffies_relative(HZ) ) 35#define LINK_TUNE_INTERVAL ( round_jiffies_relative(HZ) )
36#define RFKILL_POLL_INTERVAL ( 1000 ) 36#define RFKILL_POLL_INTERVAL ( round_jiffies_relative(HZ) )
37 37
38/* 38/*
39 * rt2x00_rate: Per rate device information 39 * rt2x00_rate: Per rate device information
@@ -204,8 +204,6 @@ void rt2x00rfkill_register(struct rt2x00_dev *rt2x00dev);
204void rt2x00rfkill_unregister(struct rt2x00_dev *rt2x00dev); 204void rt2x00rfkill_unregister(struct rt2x00_dev *rt2x00dev);
205void rt2x00rfkill_allocate(struct rt2x00_dev *rt2x00dev); 205void rt2x00rfkill_allocate(struct rt2x00_dev *rt2x00dev);
206void rt2x00rfkill_free(struct rt2x00_dev *rt2x00dev); 206void rt2x00rfkill_free(struct rt2x00_dev *rt2x00dev);
207void rt2x00rfkill_suspend(struct rt2x00_dev *rt2x00dev);
208void rt2x00rfkill_resume(struct rt2x00_dev *rt2x00dev);
209#else 207#else
210static inline void rt2x00rfkill_register(struct rt2x00_dev *rt2x00dev) 208static inline void rt2x00rfkill_register(struct rt2x00_dev *rt2x00dev)
211{ 209{
@@ -222,14 +220,6 @@ static inline void rt2x00rfkill_allocate(struct rt2x00_dev *rt2x00dev)
222static inline void rt2x00rfkill_free(struct rt2x00_dev *rt2x00dev) 220static inline void rt2x00rfkill_free(struct rt2x00_dev *rt2x00dev)
223{ 221{
224} 222}
225
226static inline void rt2x00rfkill_suspend(struct rt2x00_dev *rt2x00dev)
227{
228}
229
230static inline void rt2x00rfkill_resume(struct rt2x00_dev *rt2x00dev)
231{
232}
233#endif /* CONFIG_RT2X00_LIB_RFKILL */ 223#endif /* CONFIG_RT2X00_LIB_RFKILL */
234 224
235/* 225/*
diff --git a/drivers/net/wireless/rt2x00/rt2x00rfkill.c b/drivers/net/wireless/rt2x00/rt2x00rfkill.c
index 207281cfa8b7..04b29716d356 100644
--- a/drivers/net/wireless/rt2x00/rt2x00rfkill.c
+++ b/drivers/net/wireless/rt2x00/rt2x00rfkill.c
@@ -23,7 +23,6 @@
23 Abstract: rt2x00 rfkill routines. 23 Abstract: rt2x00 rfkill routines.
24 */ 24 */
25 25
26#include <linux/input-polldev.h>
27#include <linux/kernel.h> 26#include <linux/kernel.h>
28#include <linux/module.h> 27#include <linux/module.h>
29#include <linux/rfkill.h> 28#include <linux/rfkill.h>
@@ -61,15 +60,35 @@ static int rt2x00rfkill_toggle_radio(void *data, enum rfkill_state state)
61 return retval; 60 return retval;
62} 61}
63 62
64static void rt2x00rfkill_poll(struct input_polled_dev *poll_dev) 63static int rt2x00rfkill_get_state(void *data, enum rfkill_state *state)
65{ 64{
66 struct rt2x00_dev *rt2x00dev = poll_dev->private; 65 struct rt2x00_dev *rt2x00dev = data;
67 int state = rt2x00dev->ops->lib->rfkill_poll(rt2x00dev);
68 66
69 if (rt2x00dev->rfkill->state != state) { 67 *state = rt2x00dev->rfkill->state;
70 input_report_key(poll_dev->input, KEY_WLAN, 1); 68
71 input_report_key(poll_dev->input, KEY_WLAN, 0); 69 return 0;
72 } 70}
71
72static void rt2x00rfkill_poll(struct work_struct *work)
73{
74 struct rt2x00_dev *rt2x00dev =
75 container_of(work, struct rt2x00_dev, rfkill_work.work);
76 int state;
77
78 if (!test_bit(RFKILL_STATE_REGISTERED, &rt2x00dev->rfkill_state))
79 return;
80
81 /*
82 * rfkill_poll reports 1 when the key has been pressed and the
83 * radio should be blocked.
84 */
85 state = !rt2x00dev->ops->lib->rfkill_poll(rt2x00dev) ?
86 RFKILL_STATE_UNBLOCKED : RFKILL_STATE_SOFT_BLOCKED;
87
88 rfkill_force_state(rt2x00dev->rfkill, state);
89
90 queue_delayed_work(rt2x00dev->hw->workqueue,
91 &rt2x00dev->rfkill_work, RFKILL_POLL_INTERVAL);
73} 92}
74 93
75void rt2x00rfkill_register(struct rt2x00_dev *rt2x00dev) 94void rt2x00rfkill_register(struct rt2x00_dev *rt2x00dev)
@@ -83,12 +102,6 @@ void rt2x00rfkill_register(struct rt2x00_dev *rt2x00dev)
83 return; 102 return;
84 } 103 }
85 104
86 if (input_register_polled_device(rt2x00dev->poll_dev)) {
87 ERROR(rt2x00dev, "Failed to register polled device.\n");
88 rfkill_unregister(rt2x00dev->rfkill);
89 return;
90 }
91
92 __set_bit(RFKILL_STATE_REGISTERED, &rt2x00dev->rfkill_state); 105 __set_bit(RFKILL_STATE_REGISTERED, &rt2x00dev->rfkill_state);
93 106
94 /* 107 /*
@@ -96,7 +109,7 @@ void rt2x00rfkill_register(struct rt2x00_dev *rt2x00dev)
96 * and correctly sends the signal to the rfkill layer about this 109 * and correctly sends the signal to the rfkill layer about this
97 * state. 110 * state.
98 */ 111 */
99 rt2x00rfkill_poll(rt2x00dev->poll_dev); 112 rt2x00rfkill_poll(&rt2x00dev->rfkill_work.work);
100} 113}
101 114
102void rt2x00rfkill_unregister(struct rt2x00_dev *rt2x00dev) 115void rt2x00rfkill_unregister(struct rt2x00_dev *rt2x00dev)
@@ -105,38 +118,13 @@ void rt2x00rfkill_unregister(struct rt2x00_dev *rt2x00dev)
105 !test_bit(RFKILL_STATE_REGISTERED, &rt2x00dev->rfkill_state)) 118 !test_bit(RFKILL_STATE_REGISTERED, &rt2x00dev->rfkill_state))
106 return; 119 return;
107 120
108 input_unregister_polled_device(rt2x00dev->poll_dev); 121 cancel_delayed_work_sync(&rt2x00dev->rfkill_work);
122
109 rfkill_unregister(rt2x00dev->rfkill); 123 rfkill_unregister(rt2x00dev->rfkill);
110 124
111 __clear_bit(RFKILL_STATE_REGISTERED, &rt2x00dev->rfkill_state); 125 __clear_bit(RFKILL_STATE_REGISTERED, &rt2x00dev->rfkill_state);
112} 126}
113 127
114static struct input_polled_dev *
115rt2x00rfkill_allocate_polldev(struct rt2x00_dev *rt2x00dev)
116{
117 struct input_polled_dev *poll_dev;
118
119 poll_dev = input_allocate_polled_device();
120 if (!poll_dev)
121 return NULL;
122
123 poll_dev->private = rt2x00dev;
124 poll_dev->poll = rt2x00rfkill_poll;
125 poll_dev->poll_interval = RFKILL_POLL_INTERVAL;
126
127 poll_dev->input->name = rt2x00dev->ops->name;
128 poll_dev->input->phys = wiphy_name(rt2x00dev->hw->wiphy);
129 poll_dev->input->id.bustype = BUS_HOST;
130 poll_dev->input->id.vendor = 0x1814;
131 poll_dev->input->id.product = rt2x00dev->chip.rt;
132 poll_dev->input->id.version = rt2x00dev->chip.rev;
133 poll_dev->input->dev.parent = wiphy_dev(rt2x00dev->hw->wiphy);
134 poll_dev->input->evbit[0] = BIT(EV_KEY);
135 set_bit(KEY_WLAN, poll_dev->input->keybit);
136
137 return poll_dev;
138}
139
140void rt2x00rfkill_allocate(struct rt2x00_dev *rt2x00dev) 128void rt2x00rfkill_allocate(struct rt2x00_dev *rt2x00dev)
141{ 129{
142 if (!test_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags)) 130 if (!test_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags))
@@ -153,14 +141,9 @@ void rt2x00rfkill_allocate(struct rt2x00_dev *rt2x00dev)
153 rt2x00dev->rfkill->data = rt2x00dev; 141 rt2x00dev->rfkill->data = rt2x00dev;
154 rt2x00dev->rfkill->state = -1; 142 rt2x00dev->rfkill->state = -1;
155 rt2x00dev->rfkill->toggle_radio = rt2x00rfkill_toggle_radio; 143 rt2x00dev->rfkill->toggle_radio = rt2x00rfkill_toggle_radio;
144 rt2x00dev->rfkill->get_state = rt2x00rfkill_get_state;
156 145
157 rt2x00dev->poll_dev = rt2x00rfkill_allocate_polldev(rt2x00dev); 146 INIT_DELAYED_WORK(&rt2x00dev->rfkill_work, rt2x00rfkill_poll);
158 if (!rt2x00dev->poll_dev) {
159 ERROR(rt2x00dev, "Failed to allocate polled device.\n");
160 rfkill_free(rt2x00dev->rfkill);
161 rt2x00dev->rfkill = NULL;
162 return;
163 }
164 147
165 return; 148 return;
166} 149}
@@ -171,32 +154,8 @@ void rt2x00rfkill_free(struct rt2x00_dev *rt2x00dev)
171 !test_bit(RFKILL_STATE_ALLOCATED, &rt2x00dev->rfkill_state)) 154 !test_bit(RFKILL_STATE_ALLOCATED, &rt2x00dev->rfkill_state))
172 return; 155 return;
173 156
174 input_free_polled_device(rt2x00dev->poll_dev); 157 cancel_delayed_work_sync(&rt2x00dev->rfkill_work);
175 rt2x00dev->poll_dev = NULL;
176 158
177 rfkill_free(rt2x00dev->rfkill); 159 rfkill_free(rt2x00dev->rfkill);
178 rt2x00dev->rfkill = NULL; 160 rt2x00dev->rfkill = NULL;
179} 161}
180
181void rt2x00rfkill_suspend(struct rt2x00_dev *rt2x00dev)
182{
183 if (!test_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags) ||
184 !test_bit(RFKILL_STATE_ALLOCATED, &rt2x00dev->rfkill_state))
185 return;
186
187 input_free_polled_device(rt2x00dev->poll_dev);
188 rt2x00dev->poll_dev = NULL;
189}
190
191void rt2x00rfkill_resume(struct rt2x00_dev *rt2x00dev)
192{
193 if (!test_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags) ||
194 !test_bit(RFKILL_STATE_ALLOCATED, &rt2x00dev->rfkill_state))
195 return;
196
197 rt2x00dev->poll_dev = rt2x00rfkill_allocate_polldev(rt2x00dev);
198 if (!rt2x00dev->poll_dev) {
199 ERROR(rt2x00dev, "Failed to allocate polled device.\n");
200 return;
201 }
202}