aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2008-03-17 15:06:33 -0400
committerDavid S. Miller <davem@davemloft.net>2008-03-17 15:06:33 -0400
commitfc4d30a6fc88121081916faef930d8c3e4ed6036 (patch)
tree72681dc20cacee979092555c109399852512af0b /drivers/net
parent9150c979cee012eeee853d4041e133d2801c699e (diff)
parent1682fe6de206bd1e937529cbb393915e5ea40b2c (diff)
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-2.6
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/ps3_gelic_wireless.c29
-rw-r--r--drivers/net/wireless/ath5k/hw.c2
-rw-r--r--drivers/net/wireless/b43/phy.c2
-rw-r--r--drivers/net/wireless/p54usb.c1
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00.h3
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00dev.c35
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00lib.h20
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00rfkill.c116
8 files changed, 127 insertions, 81 deletions
diff --git a/drivers/net/ps3_gelic_wireless.c b/drivers/net/ps3_gelic_wireless.c
index daf5abab9534..ddbc6e475e28 100644
--- a/drivers/net/ps3_gelic_wireless.c
+++ b/drivers/net/ps3_gelic_wireless.c
@@ -1644,13 +1644,24 @@ static void gelic_wl_scan_complete_event(struct gelic_wl_info *wl)
1644 } 1644 }
1645 1645
1646 /* put them in the newtork_list */ 1646 /* put them in the newtork_list */
1647 scan_info = wl->buf; 1647 for (i = 0, scan_info_size = 0, scan_info = wl->buf;
1648 scan_info_size = 0; 1648 scan_info_size < data_len;
1649 i = 0; 1649 i++, scan_info_size += be16_to_cpu(scan_info->size),
1650 while (scan_info_size < data_len) { 1650 scan_info = (void *)scan_info + be16_to_cpu(scan_info->size)) {
1651 pr_debug("%s:size=%d bssid=%s scan_info=%p\n", __func__, 1651 pr_debug("%s:size=%d bssid=%s scan_info=%p\n", __func__,
1652 be16_to_cpu(scan_info->size), 1652 be16_to_cpu(scan_info->size),
1653 print_mac(mac, &scan_info->bssid[2]), scan_info); 1653 print_mac(mac, &scan_info->bssid[2]), scan_info);
1654
1655 /*
1656 * The wireless firmware may return invalid channel 0 and/or
1657 * invalid rate if the AP emits zero length SSID ie. As this
1658 * scan information is useless, ignore it
1659 */
1660 if (!be16_to_cpu(scan_info->channel) || !scan_info->rate[0]) {
1661 pr_debug("%s: invalid scan info\n", __func__);
1662 continue;
1663 }
1664
1654 found = 0; 1665 found = 0;
1655 oldest = NULL; 1666 oldest = NULL;
1656 list_for_each_entry(target, &wl->network_list, list) { 1667 list_for_each_entry(target, &wl->network_list, list) {
@@ -1687,10 +1698,6 @@ static void gelic_wl_scan_complete_event(struct gelic_wl_info *wl)
1687 GFP_KERNEL); 1698 GFP_KERNEL);
1688 if (!target->hwinfo) { 1699 if (!target->hwinfo) {
1689 pr_info("%s: kzalloc failed\n", __func__); 1700 pr_info("%s: kzalloc failed\n", __func__);
1690 i++;
1691 scan_info_size += be16_to_cpu(scan_info->size);
1692 scan_info = (void *)scan_info +
1693 be16_to_cpu(scan_info->size);
1694 continue; 1701 continue;
1695 } 1702 }
1696 /* copy hw scan info */ 1703 /* copy hw scan info */
@@ -1709,10 +1716,6 @@ static void gelic_wl_scan_complete_event(struct gelic_wl_info *wl)
1709 if (scan_info->ext_rate[r]) 1716 if (scan_info->ext_rate[r])
1710 target->rate_ext_len++; 1717 target->rate_ext_len++;
1711 list_move_tail(&target->list, &wl->network_list); 1718 list_move_tail(&target->list, &wl->network_list);
1712 /* bump pointer */
1713 i++;
1714 scan_info_size += be16_to_cpu(scan_info->size);
1715 scan_info = (void *)scan_info + be16_to_cpu(scan_info->size);
1716 } 1719 }
1717 memset(&data, 0, sizeof(data)); 1720 memset(&data, 0, sizeof(data));
1718 wireless_send_event(port_to_netdev(wl_port(wl)), SIOCGIWSCAN, &data, 1721 wireless_send_event(port_to_netdev(wl_port(wl)), SIOCGIWSCAN, &data,
@@ -2389,6 +2392,8 @@ static struct net_device *gelic_wl_alloc(struct gelic_card *card)
2389 if (!netdev) 2392 if (!netdev)
2390 return NULL; 2393 return NULL;
2391 2394
2395 strcpy(netdev->name, "wlan%d");
2396
2392 port = netdev_priv(netdev); 2397 port = netdev_priv(netdev);
2393 port->netdev = netdev; 2398 port->netdev = netdev;
2394 port->card = card; 2399 port->card = card;
diff --git a/drivers/net/wireless/ath5k/hw.c b/drivers/net/wireless/ath5k/hw.c
index c2de2d958e8e..01757436353d 100644
--- a/drivers/net/wireless/ath5k/hw.c
+++ b/drivers/net/wireless/ath5k/hw.c
@@ -427,6 +427,8 @@ void ath5k_hw_detach(struct ath5k_hw *ah)
427{ 427{
428 ATH5K_TRACE(ah->ah_sc); 428 ATH5K_TRACE(ah->ah_sc);
429 429
430 __set_bit(ATH_STAT_INVALID, ah->ah_sc->status);
431
430 if (ah->ah_rf_banks != NULL) 432 if (ah->ah_rf_banks != NULL)
431 kfree(ah->ah_rf_banks); 433 kfree(ah->ah_rf_banks);
432 434
diff --git a/drivers/net/wireless/b43/phy.c b/drivers/net/wireless/b43/phy.c
index 71507b260b6d..575c5436ebdf 100644
--- a/drivers/net/wireless/b43/phy.c
+++ b/drivers/net/wireless/b43/phy.c
@@ -860,7 +860,7 @@ static void b43_phy_ww(struct b43_wldev *dev)
860 b43_phy_write(dev, B43_PHY_OFDM(0xBB), 860 b43_phy_write(dev, B43_PHY_OFDM(0xBB),
861 (b43_phy_read(dev, B43_PHY_OFDM(0xBB)) & 0xF000) | 0x0053); 861 (b43_phy_read(dev, B43_PHY_OFDM(0xBB)) & 0xF000) | 0x0053);
862 b43_phy_write(dev, B43_PHY_OFDM61, 862 b43_phy_write(dev, B43_PHY_OFDM61,
863 (b43_phy_read(dev, B43_PHY_OFDM61 & 0xFE1F)) | 0x0120); 863 (b43_phy_read(dev, B43_PHY_OFDM61) & 0xFE1F) | 0x0120);
864 b43_phy_write(dev, B43_PHY_OFDM(0x13), 864 b43_phy_write(dev, B43_PHY_OFDM(0x13),
865 (b43_phy_read(dev, B43_PHY_OFDM(0x13)) & 0x0FFF) | 0x3000); 865 (b43_phy_read(dev, B43_PHY_OFDM(0x13)) & 0x0FFF) | 0x3000);
866 b43_phy_write(dev, B43_PHY_OFDM(0x14), 866 b43_phy_write(dev, B43_PHY_OFDM(0x14),
diff --git a/drivers/net/wireless/p54usb.c b/drivers/net/wireless/p54usb.c
index e7d4aee8799e..98ddbb3b3273 100644
--- a/drivers/net/wireless/p54usb.c
+++ b/drivers/net/wireless/p54usb.c
@@ -63,6 +63,7 @@ static struct usb_device_id p54u_table[] __devinitdata = {
63 {USB_DEVICE(0x0cde, 0x0008)}, /* Sagem XG703A */ 63 {USB_DEVICE(0x0cde, 0x0008)}, /* Sagem XG703A */
64 {USB_DEVICE(0x0d8e, 0x3762)}, /* DLink DWL-G120 Cohiba */ 64 {USB_DEVICE(0x0d8e, 0x3762)}, /* DLink DWL-G120 Cohiba */
65 {USB_DEVICE(0x09aa, 0x1000)}, /* Spinnaker Proto board */ 65 {USB_DEVICE(0x09aa, 0x1000)}, /* Spinnaker Proto board */
66 {USB_DEVICE(0x124a, 0x4025)}, /* IOGear GWU513 (GW3887IK chip) */
66 {USB_DEVICE(0x13b1, 0x000a)}, /* Linksys WUSB54G ver 2 */ 67 {USB_DEVICE(0x13b1, 0x000a)}, /* Linksys WUSB54G ver 2 */
67 {USB_DEVICE(0x13B1, 0x000C)}, /* Linksys WUSB54AG */ 68 {USB_DEVICE(0x13B1, 0x000C)}, /* Linksys WUSB54AG */
68 {USB_DEVICE(0x1435, 0x0427)}, /* Inventel UR054G */ 69 {USB_DEVICE(0x1435, 0x0427)}, /* Inventel UR054G */
diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
index 05927b908f80..6c725422af5a 100644
--- a/drivers/net/wireless/rt2x00/rt2x00.h
+++ b/drivers/net/wireless/rt2x00/rt2x00.h
@@ -620,6 +620,9 @@ struct rt2x00_dev {
620 * This will only be compiled in when required. 620 * This will only be compiled in when required.
621 */ 621 */
622#ifdef CONFIG_RT2X00_LIB_RFKILL 622#ifdef CONFIG_RT2X00_LIB_RFKILL
623unsigned long rfkill_state;
624#define RFKILL_STATE_ALLOCATED 1
625#define RFKILL_STATE_REGISTERED 2
623 struct rfkill *rfkill; 626 struct rfkill *rfkill;
624 struct input_polled_dev *poll_dev; 627 struct input_polled_dev *poll_dev;
625#endif /* CONFIG_RT2X00_LIB_RFKILL */ 628#endif /* CONFIG_RT2X00_LIB_RFKILL */
diff --git a/drivers/net/wireless/rt2x00/rt2x00dev.c b/drivers/net/wireless/rt2x00/rt2x00dev.c
index 0d51f478bcdf..bc846ba12f63 100644
--- a/drivers/net/wireless/rt2x00/rt2x00dev.c
+++ b/drivers/net/wireless/rt2x00/rt2x00dev.c
@@ -1098,7 +1098,7 @@ static void rt2x00lib_uninitialize(struct rt2x00_dev *rt2x00dev)
1098 return; 1098 return;
1099 1099
1100 /* 1100 /*
1101 * Unregister rfkill. 1101 * Unregister extra components.
1102 */ 1102 */
1103 rt2x00rfkill_unregister(rt2x00dev); 1103 rt2x00rfkill_unregister(rt2x00dev);
1104 1104
@@ -1139,11 +1139,9 @@ static int rt2x00lib_initialize(struct rt2x00_dev *rt2x00dev)
1139 __set_bit(DEVICE_INITIALIZED, &rt2x00dev->flags); 1139 __set_bit(DEVICE_INITIALIZED, &rt2x00dev->flags);
1140 1140
1141 /* 1141 /*
1142 * Register the rfkill handler. 1142 * Register the extra components.
1143 */ 1143 */
1144 status = rt2x00rfkill_register(rt2x00dev); 1144 rt2x00rfkill_register(rt2x00dev);
1145 if (status)
1146 goto exit_unitialize;
1147 1145
1148 return 0; 1146 return 0;
1149 1147
@@ -1313,15 +1311,9 @@ int rt2x00lib_probe_dev(struct rt2x00_dev *rt2x00dev)
1313 } 1311 }
1314 1312
1315 /* 1313 /*
1316 * Allocatie rfkill. 1314 * Register extra components.
1317 */
1318 retval = rt2x00rfkill_allocate(rt2x00dev);
1319 if (retval)
1320 goto exit;
1321
1322 /*
1323 * Open the debugfs entry.
1324 */ 1315 */
1316 rt2x00rfkill_allocate(rt2x00dev);
1325 rt2x00debug_register(rt2x00dev); 1317 rt2x00debug_register(rt2x00dev);
1326 1318
1327 __set_bit(DEVICE_PRESENT, &rt2x00dev->flags); 1319 __set_bit(DEVICE_PRESENT, &rt2x00dev->flags);
@@ -1350,13 +1342,9 @@ void rt2x00lib_remove_dev(struct rt2x00_dev *rt2x00dev)
1350 rt2x00lib_uninitialize(rt2x00dev); 1342 rt2x00lib_uninitialize(rt2x00dev);
1351 1343
1352 /* 1344 /*
1353 * Close debugfs entry. 1345 * Free extra components
1354 */ 1346 */
1355 rt2x00debug_deregister(rt2x00dev); 1347 rt2x00debug_deregister(rt2x00dev);
1356
1357 /*
1358 * Free rfkill
1359 */
1360 rt2x00rfkill_free(rt2x00dev); 1348 rt2x00rfkill_free(rt2x00dev);
1361 1349
1362 /* 1350 /*
@@ -1395,11 +1383,15 @@ int rt2x00lib_suspend(struct rt2x00_dev *rt2x00dev, pm_message_t state)
1395 __set_bit(DEVICE_STARTED_SUSPEND, &rt2x00dev->flags); 1383 __set_bit(DEVICE_STARTED_SUSPEND, &rt2x00dev->flags);
1396 1384
1397 /* 1385 /*
1398 * Disable radio and unitialize all items 1386 * Disable radio.
1399 * that must be recreated on resume.
1400 */ 1387 */
1401 rt2x00lib_stop(rt2x00dev); 1388 rt2x00lib_stop(rt2x00dev);
1402 rt2x00lib_uninitialize(rt2x00dev); 1389 rt2x00lib_uninitialize(rt2x00dev);
1390
1391 /*
1392 * Suspend/disable extra components.
1393 */
1394 rt2x00rfkill_suspend(rt2x00dev);
1403 rt2x00debug_deregister(rt2x00dev); 1395 rt2x00debug_deregister(rt2x00dev);
1404 1396
1405exit: 1397exit:
@@ -1422,9 +1414,10 @@ int rt2x00lib_resume(struct rt2x00_dev *rt2x00dev)
1422 NOTICE(rt2x00dev, "Waking up.\n"); 1414 NOTICE(rt2x00dev, "Waking up.\n");
1423 1415
1424 /* 1416 /*
1425 * Open the debugfs entry. 1417 * Restore/enable extra components.
1426 */ 1418 */
1427 rt2x00debug_register(rt2x00dev); 1419 rt2x00debug_register(rt2x00dev);
1420 rt2x00rfkill_resume(rt2x00dev);
1428 1421
1429 /* 1422 /*
1430 * Only continue if mac80211 had open interfaces. 1423 * Only continue if mac80211 had open interfaces.
diff --git a/drivers/net/wireless/rt2x00/rt2x00lib.h b/drivers/net/wireless/rt2x00/rt2x00lib.h
index 1adbd28e0973..ce58c654ade1 100644
--- a/drivers/net/wireless/rt2x00/rt2x00lib.h
+++ b/drivers/net/wireless/rt2x00/rt2x00lib.h
@@ -100,28 +100,36 @@ static inline void rt2x00debug_dump_frame(struct rt2x00_dev *rt2x00dev,
100 * RFkill handlers. 100 * RFkill handlers.
101 */ 101 */
102#ifdef CONFIG_RT2X00_LIB_RFKILL 102#ifdef CONFIG_RT2X00_LIB_RFKILL
103int rt2x00rfkill_register(struct rt2x00_dev *rt2x00dev); 103void rt2x00rfkill_register(struct rt2x00_dev *rt2x00dev);
104void rt2x00rfkill_unregister(struct rt2x00_dev *rt2x00dev); 104void rt2x00rfkill_unregister(struct rt2x00_dev *rt2x00dev);
105int rt2x00rfkill_allocate(struct rt2x00_dev *rt2x00dev); 105void rt2x00rfkill_allocate(struct rt2x00_dev *rt2x00dev);
106void rt2x00rfkill_free(struct rt2x00_dev *rt2x00dev); 106void rt2x00rfkill_free(struct rt2x00_dev *rt2x00dev);
107void rt2x00rfkill_suspend(struct rt2x00_dev *rt2x00dev);
108void rt2x00rfkill_resume(struct rt2x00_dev *rt2x00dev);
107#else 109#else
108static inline int rt2x00rfkill_register(struct rt2x00_dev *rt2x00dev) 110static inline void rt2x00rfkill_register(struct rt2x00_dev *rt2x00dev)
109{ 111{
110 return 0;
111} 112}
112 113
113static inline void rt2x00rfkill_unregister(struct rt2x00_dev *rt2x00dev) 114static inline void rt2x00rfkill_unregister(struct rt2x00_dev *rt2x00dev)
114{ 115{
115} 116}
116 117
117static inline int rt2x00rfkill_allocate(struct rt2x00_dev *rt2x00dev) 118static inline void rt2x00rfkill_allocate(struct rt2x00_dev *rt2x00dev)
118{ 119{
119 return 0;
120} 120}
121 121
122static inline void rt2x00rfkill_free(struct rt2x00_dev *rt2x00dev) 122static inline void rt2x00rfkill_free(struct rt2x00_dev *rt2x00dev)
123{ 123{
124} 124}
125
126static inline void rt2x00rfkill_suspend(struct rt2x00_dev *rt2x00dev)
127{
128}
129
130static inline void rt2x00rfkill_resume(struct rt2x00_dev *rt2x00dev)
131{
132}
125#endif /* CONFIG_RT2X00_LIB_RFKILL */ 133#endif /* CONFIG_RT2X00_LIB_RFKILL */
126 134
127#endif /* RT2X00LIB_H */ 135#endif /* RT2X00LIB_H */
diff --git a/drivers/net/wireless/rt2x00/rt2x00rfkill.c b/drivers/net/wireless/rt2x00/rt2x00rfkill.c
index 34a96d44e306..f95577596206 100644
--- a/drivers/net/wireless/rt2x00/rt2x00rfkill.c
+++ b/drivers/net/wireless/rt2x00/rt2x00rfkill.c
@@ -69,56 +69,81 @@ static void rt2x00rfkill_poll(struct input_polled_dev *poll_dev)
69 } 69 }
70} 70}
71 71
72int rt2x00rfkill_register(struct rt2x00_dev *rt2x00dev) 72void rt2x00rfkill_register(struct rt2x00_dev *rt2x00dev)
73{ 73{
74 int retval; 74 if (!test_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags) ||
75 75 !test_bit(RFKILL_STATE_ALLOCATED, &rt2x00dev->rfkill_state))
76 if (!test_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags)) 76 return;
77 return 0;
78 77
79 retval = rfkill_register(rt2x00dev->rfkill); 78 if (rfkill_register(rt2x00dev->rfkill)) {
80 if (retval) {
81 ERROR(rt2x00dev, "Failed to register rfkill handler.\n"); 79 ERROR(rt2x00dev, "Failed to register rfkill handler.\n");
82 return retval; 80 return;
83 } 81 }
84 82
85 retval = input_register_polled_device(rt2x00dev->poll_dev); 83 if (input_register_polled_device(rt2x00dev->poll_dev)) {
86 if (retval) {
87 ERROR(rt2x00dev, "Failed to register polled device.\n"); 84 ERROR(rt2x00dev, "Failed to register polled device.\n");
88 rfkill_unregister(rt2x00dev->rfkill); 85 rfkill_unregister(rt2x00dev->rfkill);
89 return retval; 86 return;
90 } 87 }
91 88
89 __set_bit(RFKILL_STATE_REGISTERED, &rt2x00dev->rfkill_state);
90
92 /* 91 /*
93 * Force initial poll which will detect the initial device state, 92 * Force initial poll which will detect the initial device state,
94 * and correctly sends the signal to the rfkill layer about this 93 * and correctly sends the signal to the rfkill layer about this
95 * state. 94 * state.
96 */ 95 */
97 rt2x00rfkill_poll(rt2x00dev->poll_dev); 96 rt2x00rfkill_poll(rt2x00dev->poll_dev);
98
99 return 0;
100} 97}
101 98
102void rt2x00rfkill_unregister(struct rt2x00_dev *rt2x00dev) 99void rt2x00rfkill_unregister(struct rt2x00_dev *rt2x00dev)
103{ 100{
104 if (!test_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags)) 101 if (!test_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags) ||
102 !test_bit(RFKILL_STATE_REGISTERED, &rt2x00dev->rfkill_state))
105 return; 103 return;
106 104
107 input_unregister_polled_device(rt2x00dev->poll_dev); 105 input_unregister_polled_device(rt2x00dev->poll_dev);
108 rfkill_unregister(rt2x00dev->rfkill); 106 rfkill_unregister(rt2x00dev->rfkill);
107
108 __clear_bit(RFKILL_STATE_REGISTERED, &rt2x00dev->rfkill_state);
109} 109}
110 110
111int rt2x00rfkill_allocate(struct rt2x00_dev *rt2x00dev) 111static struct input_polled_dev *
112rt2x00rfkill_allocate_polldev(struct rt2x00_dev *rt2x00dev)
112{ 113{
113 struct device *device = wiphy_dev(rt2x00dev->hw->wiphy); 114 struct input_polled_dev *poll_dev;
115
116 poll_dev = input_allocate_polled_device();
117 if (!poll_dev)
118 return NULL;
119
120 poll_dev->private = rt2x00dev;
121 poll_dev->poll = rt2x00rfkill_poll;
122 poll_dev->poll_interval = RFKILL_POLL_INTERVAL;
123
124 poll_dev->input->name = rt2x00dev->ops->name;
125 poll_dev->input->phys = wiphy_name(rt2x00dev->hw->wiphy);
126 poll_dev->input->id.bustype = BUS_HOST;
127 poll_dev->input->id.vendor = 0x1814;
128 poll_dev->input->id.product = rt2x00dev->chip.rt;
129 poll_dev->input->id.version = rt2x00dev->chip.rev;
130 poll_dev->input->dev.parent = wiphy_dev(rt2x00dev->hw->wiphy);
131 poll_dev->input->evbit[0] = BIT(EV_KEY);
132 set_bit(KEY_WLAN, poll_dev->input->keybit);
133
134 return poll_dev;
135}
114 136
137void rt2x00rfkill_allocate(struct rt2x00_dev *rt2x00dev)
138{
115 if (!test_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags)) 139 if (!test_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags))
116 return 0; 140 return;
117 141
118 rt2x00dev->rfkill = rfkill_allocate(device, RFKILL_TYPE_WLAN); 142 rt2x00dev->rfkill =
143 rfkill_allocate(wiphy_dev(rt2x00dev->hw->wiphy), RFKILL_TYPE_WLAN);
119 if (!rt2x00dev->rfkill) { 144 if (!rt2x00dev->rfkill) {
120 ERROR(rt2x00dev, "Failed to allocate rfkill handler.\n"); 145 ERROR(rt2x00dev, "Failed to allocate rfkill handler.\n");
121 goto exit; 146 return;
122 } 147 }
123 148
124 rt2x00dev->rfkill->name = rt2x00dev->ops->name; 149 rt2x00dev->rfkill->name = rt2x00dev->ops->name;
@@ -126,40 +151,49 @@ int rt2x00rfkill_allocate(struct rt2x00_dev *rt2x00dev)
126 rt2x00dev->rfkill->state = -1; 151 rt2x00dev->rfkill->state = -1;
127 rt2x00dev->rfkill->toggle_radio = rt2x00rfkill_toggle_radio; 152 rt2x00dev->rfkill->toggle_radio = rt2x00rfkill_toggle_radio;
128 153
129 rt2x00dev->poll_dev = input_allocate_polled_device(); 154 rt2x00dev->poll_dev = rt2x00rfkill_allocate_polldev(rt2x00dev);
130 if (!rt2x00dev->poll_dev) { 155 if (!rt2x00dev->poll_dev) {
131 ERROR(rt2x00dev, "Failed to allocate polled device.\n"); 156 ERROR(rt2x00dev, "Failed to allocate polled device.\n");
132 goto exit_free_rfkill; 157 rfkill_free(rt2x00dev->rfkill);
158 rt2x00dev->rfkill = NULL;
159 return;
133 } 160 }
134 161
135 rt2x00dev->poll_dev->private = rt2x00dev; 162 return;
136 rt2x00dev->poll_dev->poll = rt2x00rfkill_poll; 163}
137 rt2x00dev->poll_dev->poll_interval = RFKILL_POLL_INTERVAL;
138 164
139 rt2x00dev->poll_dev->input->name = rt2x00dev->ops->name; 165void rt2x00rfkill_free(struct rt2x00_dev *rt2x00dev)
140 rt2x00dev->poll_dev->input->phys = wiphy_name(rt2x00dev->hw->wiphy); 166{
141 rt2x00dev->poll_dev->input->id.bustype = BUS_HOST; 167 if (!test_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags) ||
142 rt2x00dev->poll_dev->input->id.vendor = 0x1814; 168 !test_bit(RFKILL_STATE_ALLOCATED, &rt2x00dev->rfkill_state))
143 rt2x00dev->poll_dev->input->id.product = rt2x00dev->chip.rt; 169 return;
144 rt2x00dev->poll_dev->input->id.version = rt2x00dev->chip.rev;
145 rt2x00dev->poll_dev->input->dev.parent = device;
146 rt2x00dev->poll_dev->input->evbit[0] = BIT(EV_KEY);
147 set_bit(KEY_WLAN, rt2x00dev->poll_dev->input->keybit);
148 170
149 return 0; 171 input_free_polled_device(rt2x00dev->poll_dev);
172 rt2x00dev->poll_dev = NULL;
150 173
151exit_free_rfkill:
152 rfkill_free(rt2x00dev->rfkill); 174 rfkill_free(rt2x00dev->rfkill);
153 175 rt2x00dev->rfkill = NULL;
154exit:
155 return -ENOMEM;
156} 176}
157 177
158void rt2x00rfkill_free(struct rt2x00_dev *rt2x00dev) 178void rt2x00rfkill_suspend(struct rt2x00_dev *rt2x00dev)
159{ 179{
160 if (!test_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags)) 180 if (!test_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags) ||
181 !test_bit(RFKILL_STATE_ALLOCATED, &rt2x00dev->rfkill_state))
161 return; 182 return;
162 183
163 input_free_polled_device(rt2x00dev->poll_dev); 184 input_free_polled_device(rt2x00dev->poll_dev);
164 rfkill_free(rt2x00dev->rfkill); 185 rt2x00dev->poll_dev = NULL;
186}
187
188void rt2x00rfkill_resume(struct rt2x00_dev *rt2x00dev)
189{
190 if (!test_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags) ||
191 !test_bit(RFKILL_STATE_ALLOCATED, &rt2x00dev->rfkill_state))
192 return;
193
194 rt2x00dev->poll_dev = rt2x00rfkill_allocate_polldev(rt2x00dev);
195 if (!rt2x00dev->poll_dev) {
196 ERROR(rt2x00dev, "Failed to allocate polled device.\n");
197 return;
198 }
165} 199}