aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/rt2x00/rt2x00rfkill.c
diff options
context:
space:
mode:
authorIvo van Doorn <ivdoorn@gmail.com>2007-10-27 07:40:25 -0400
committerDavid S. Miller <davem@davemloft.net>2008-01-28 18:02:58 -0500
commit4300beb47dd96ccaf5fa1a7550f6f6f15d045b30 (patch)
treecf078e172198a5c0b9b07365c4d5e1653dbb9296 /drivers/net/wireless/rt2x00/rt2x00rfkill.c
parente4cd2ff89f91b0556a2e2d928219b2908cafd67f (diff)
rt2x00: Input-polldev requires input device
input-polldev requires a correctly allocated and initialized input device to be set for the input_polled_dev->input field. Failure to do that will prevent correct polling of the device. Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/wireless/rt2x00/rt2x00rfkill.c')
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00rfkill.c35
1 files changed, 31 insertions, 4 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2x00rfkill.c b/drivers/net/wireless/rt2x00/rt2x00rfkill.c
index a0f8b8e0a24b..db513f141bec 100644
--- a/drivers/net/wireless/rt2x00/rt2x00rfkill.c
+++ b/drivers/net/wireless/rt2x00/rt2x00rfkill.c
@@ -68,8 +68,10 @@ static void rt2x00rfkill_poll(struct input_polled_dev *poll_dev)
68 struct rt2x00_dev *rt2x00dev = poll_dev->private; 68 struct rt2x00_dev *rt2x00dev = poll_dev->private;
69 int state = rt2x00dev->ops->lib->rfkill_poll(rt2x00dev); 69 int state = rt2x00dev->ops->lib->rfkill_poll(rt2x00dev);
70 70
71 if (rt2x00dev->rfkill->state != state) 71 if (rt2x00dev->rfkill->state != state) {
72 input_report_key(poll_dev->input, KEY_WLAN, 1); 72 input_report_key(poll_dev->input, KEY_WLAN, 1);
73 input_report_key(poll_dev->input, KEY_WLAN, 0);
74 }
73} 75}
74 76
75int rt2x00rfkill_register(struct rt2x00_dev *rt2x00dev) 77int rt2x00rfkill_register(struct rt2x00_dev *rt2x00dev)
@@ -114,7 +116,7 @@ int rt2x00rfkill_allocate(struct rt2x00_dev *rt2x00dev)
114 rt2x00dev->rfkill = rfkill_allocate(device, RFKILL_TYPE_WLAN); 116 rt2x00dev->rfkill = rfkill_allocate(device, RFKILL_TYPE_WLAN);
115 if (!rt2x00dev->rfkill) { 117 if (!rt2x00dev->rfkill) {
116 ERROR(rt2x00dev, "Failed to allocate rfkill handler.\n"); 118 ERROR(rt2x00dev, "Failed to allocate rfkill handler.\n");
117 return -ENOMEM; 119 goto exit;
118 } 120 }
119 121
120 rt2x00dev->rfkill->name = rt2x00dev->ops->name; 122 rt2x00dev->rfkill->name = rt2x00dev->ops->name;
@@ -125,15 +127,39 @@ int rt2x00rfkill_allocate(struct rt2x00_dev *rt2x00dev)
125 rt2x00dev->poll_dev = input_allocate_polled_device(); 127 rt2x00dev->poll_dev = input_allocate_polled_device();
126 if (!rt2x00dev->poll_dev) { 128 if (!rt2x00dev->poll_dev) {
127 ERROR(rt2x00dev, "Failed to allocate polled device.\n"); 129 ERROR(rt2x00dev, "Failed to allocate polled device.\n");
128 rfkill_free(rt2x00dev->rfkill); 130 goto exit_free_rfkill;
129 return -ENOMEM;
130 } 131 }
131 132
132 rt2x00dev->poll_dev->private = rt2x00dev; 133 rt2x00dev->poll_dev->private = rt2x00dev;
133 rt2x00dev->poll_dev->poll = rt2x00rfkill_poll; 134 rt2x00dev->poll_dev->poll = rt2x00rfkill_poll;
134 rt2x00dev->poll_dev->poll_interval = RFKILL_POLL_INTERVAL; 135 rt2x00dev->poll_dev->poll_interval = RFKILL_POLL_INTERVAL;
135 136
137 rt2x00dev->poll_dev->input = input_allocate_device();
138 if (!rt2x00dev->poll_dev->input) {
139 ERROR(rt2x00dev, "Failed to allocate input device.\n");
140 goto exit_free_polldev;
141 }
142
143 rt2x00dev->poll_dev->input->name = rt2x00dev->ops->name;
144 rt2x00dev->poll_dev->input->phys = wiphy_name(rt2x00dev->hw->wiphy);
145 rt2x00dev->poll_dev->input->id.bustype = BUS_HOST;
146 rt2x00dev->poll_dev->input->id.vendor = 0x1814;
147 rt2x00dev->poll_dev->input->id.product = rt2x00dev->chip.rt;
148 rt2x00dev->poll_dev->input->id.version = rt2x00dev->chip.rev;
149 rt2x00dev->poll_dev->input->dev.parent = device;
150 rt2x00dev->poll_dev->input->evbit[0] = BIT(EV_KEY);
151 set_bit(KEY_WLAN, rt2x00dev->poll_dev->input->keybit);
152
136 return 0; 153 return 0;
154
155exit_free_polldev:
156 input_free_polled_device(rt2x00dev->poll_dev);
157
158exit_free_rfkill:
159 rfkill_free(rt2x00dev->rfkill);
160
161exit:
162 return -ENOMEM;
137} 163}
138 164
139void rt2x00rfkill_free(struct rt2x00_dev *rt2x00dev) 165void rt2x00rfkill_free(struct rt2x00_dev *rt2x00dev)
@@ -141,6 +167,7 @@ void rt2x00rfkill_free(struct rt2x00_dev *rt2x00dev)
141 if (!test_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags)) 167 if (!test_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags))
142 return; 168 return;
143 169
170 input_free_device(rt2x00dev->poll_dev->input);
144 input_free_polled_device(rt2x00dev->poll_dev); 171 input_free_polled_device(rt2x00dev->poll_dev);
145 rfkill_free(rt2x00dev->rfkill); 172 rfkill_free(rt2x00dev->rfkill);
146} 173}