Commit 4300beb4 authored by Ivo van Doorn's avatar Ivo van Doorn Committed by David S. Miller

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: default avatarIvo van Doorn <IvDoorn@gmail.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent e4cd2ff8
...@@ -68,8 +68,10 @@ static void rt2x00rfkill_poll(struct input_polled_dev *poll_dev) ...@@ -68,8 +68,10 @@ static void rt2x00rfkill_poll(struct input_polled_dev *poll_dev)
struct rt2x00_dev *rt2x00dev = poll_dev->private; struct rt2x00_dev *rt2x00dev = poll_dev->private;
int state = rt2x00dev->ops->lib->rfkill_poll(rt2x00dev); int state = rt2x00dev->ops->lib->rfkill_poll(rt2x00dev);
if (rt2x00dev->rfkill->state != state) if (rt2x00dev->rfkill->state != state) {
input_report_key(poll_dev->input, KEY_WLAN, 1); input_report_key(poll_dev->input, KEY_WLAN, 1);
input_report_key(poll_dev->input, KEY_WLAN, 0);
}
} }
int rt2x00rfkill_register(struct rt2x00_dev *rt2x00dev) int rt2x00rfkill_register(struct rt2x00_dev *rt2x00dev)
...@@ -114,7 +116,7 @@ int rt2x00rfkill_allocate(struct rt2x00_dev *rt2x00dev) ...@@ -114,7 +116,7 @@ int rt2x00rfkill_allocate(struct rt2x00_dev *rt2x00dev)
rt2x00dev->rfkill = rfkill_allocate(device, RFKILL_TYPE_WLAN); rt2x00dev->rfkill = rfkill_allocate(device, RFKILL_TYPE_WLAN);
if (!rt2x00dev->rfkill) { if (!rt2x00dev->rfkill) {
ERROR(rt2x00dev, "Failed to allocate rfkill handler.\n"); ERROR(rt2x00dev, "Failed to allocate rfkill handler.\n");
return -ENOMEM; goto exit;
} }
rt2x00dev->rfkill->name = rt2x00dev->ops->name; rt2x00dev->rfkill->name = rt2x00dev->ops->name;
...@@ -125,15 +127,39 @@ int rt2x00rfkill_allocate(struct rt2x00_dev *rt2x00dev) ...@@ -125,15 +127,39 @@ int rt2x00rfkill_allocate(struct rt2x00_dev *rt2x00dev)
rt2x00dev->poll_dev = input_allocate_polled_device(); rt2x00dev->poll_dev = input_allocate_polled_device();
if (!rt2x00dev->poll_dev) { if (!rt2x00dev->poll_dev) {
ERROR(rt2x00dev, "Failed to allocate polled device.\n"); ERROR(rt2x00dev, "Failed to allocate polled device.\n");
rfkill_free(rt2x00dev->rfkill); goto exit_free_rfkill;
return -ENOMEM;
} }
rt2x00dev->poll_dev->private = rt2x00dev; rt2x00dev->poll_dev->private = rt2x00dev;
rt2x00dev->poll_dev->poll = rt2x00rfkill_poll; rt2x00dev->poll_dev->poll = rt2x00rfkill_poll;
rt2x00dev->poll_dev->poll_interval = RFKILL_POLL_INTERVAL; rt2x00dev->poll_dev->poll_interval = RFKILL_POLL_INTERVAL;
rt2x00dev->poll_dev->input = input_allocate_device();
if (!rt2x00dev->poll_dev->input) {
ERROR(rt2x00dev, "Failed to allocate input device.\n");
goto exit_free_polldev;
}
rt2x00dev->poll_dev->input->name = rt2x00dev->ops->name;
rt2x00dev->poll_dev->input->phys = wiphy_name(rt2x00dev->hw->wiphy);
rt2x00dev->poll_dev->input->id.bustype = BUS_HOST;
rt2x00dev->poll_dev->input->id.vendor = 0x1814;
rt2x00dev->poll_dev->input->id.product = rt2x00dev->chip.rt;
rt2x00dev->poll_dev->input->id.version = rt2x00dev->chip.rev;
rt2x00dev->poll_dev->input->dev.parent = device;
rt2x00dev->poll_dev->input->evbit[0] = BIT(EV_KEY);
set_bit(KEY_WLAN, rt2x00dev->poll_dev->input->keybit);
return 0; return 0;
exit_free_polldev:
input_free_polled_device(rt2x00dev->poll_dev);
exit_free_rfkill:
rfkill_free(rt2x00dev->rfkill);
exit:
return -ENOMEM;
} }
void rt2x00rfkill_free(struct rt2x00_dev *rt2x00dev) void rt2x00rfkill_free(struct rt2x00_dev *rt2x00dev)
...@@ -141,6 +167,7 @@ void rt2x00rfkill_free(struct rt2x00_dev *rt2x00dev) ...@@ -141,6 +167,7 @@ void rt2x00rfkill_free(struct rt2x00_dev *rt2x00dev)
if (!test_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags)) if (!test_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags))
return; return;
input_free_device(rt2x00dev->poll_dev->input);
input_free_polled_device(rt2x00dev->poll_dev); input_free_polled_device(rt2x00dev->poll_dev);
rfkill_free(rt2x00dev->rfkill); rfkill_free(rt2x00dev->rfkill);
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment