aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2009-06-20 04:16:40 -0400
committerDavid S. Miller <davem@davemloft.net>2009-06-20 04:16:40 -0400
commitc3da63f35773b04e885c5659e560d5c521d2682e (patch)
tree5e876e7587f299cadce0b53bfaf912fb28d8283d
parent73e42897e8e5619eacb787d2ce69be12f47cfc21 (diff)
parenta97f4424fb4cddecf9b13c9b0e3f79924b624a7f (diff)
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-next-2.6
-rw-r--r--Documentation/rfkill.txt2
-rw-r--r--MAINTAINERS6
-rw-r--r--drivers/net/wireless/ath/ath5k/base.c11
-rw-r--r--drivers/net/wireless/ath/ath9k/main.c2
-rw-r--r--drivers/net/wireless/ath/ath9k/pci.c18
-rw-r--r--drivers/net/wireless/ath/ath9k/recv.c7
-rw-r--r--drivers/net/wireless/iwmc3200wifi/iwm.h4
-rw-r--r--drivers/net/wireless/iwmc3200wifi/main.c64
-rw-r--r--drivers/net/wireless/iwmc3200wifi/netdev.c49
-rw-r--r--drivers/net/wireless/iwmc3200wifi/sdio.c11
-rw-r--r--drivers/net/wireless/zd1211rw/zd_usb.c1
-rw-r--r--drivers/platform/x86/acer-wmi.c4
-rw-r--r--drivers/platform/x86/eeepc-laptop.c50
-rw-r--r--drivers/platform/x86/thinkpad_acpi.c14
-rw-r--r--include/linux/rfkill.h33
-rw-r--r--net/rfkill/core.c56
-rw-r--r--net/wireless/nl80211.c95
17 files changed, 338 insertions, 89 deletions
diff --git a/Documentation/rfkill.txt b/Documentation/rfkill.txt
index c8acd8659e91..b4860509c319 100644
--- a/Documentation/rfkill.txt
+++ b/Documentation/rfkill.txt
@@ -111,6 +111,8 @@ following attributes:
111 111
112 name: Name assigned by driver to this key (interface or driver name). 112 name: Name assigned by driver to this key (interface or driver name).
113 type: Driver type string ("wlan", "bluetooth", etc). 113 type: Driver type string ("wlan", "bluetooth", etc).
114 persistent: Whether the soft blocked state is initialised from
115 non-volatile storage at startup.
114 state: Current state of the transmitter 116 state: Current state of the transmitter
115 0: RFKILL_STATE_SOFT_BLOCKED 117 0: RFKILL_STATE_SOFT_BLOCKED
116 transmitter is turned off by software 118 transmitter is turned off by software
diff --git a/MAINTAINERS b/MAINTAINERS
index 7aa3081a8968..90a48e99e8b3 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -940,7 +940,7 @@ M: me@bobcopeland.com
940L: linux-wireless@vger.kernel.org 940L: linux-wireless@vger.kernel.org
941L: ath5k-devel@lists.ath5k.org 941L: ath5k-devel@lists.ath5k.org
942S: Maintained 942S: Maintained
943F: drivers/net/wireless/ath5k/ 943F: drivers/net/wireless/ath/ath5k/
944 944
945ATHEROS ATH9K WIRELESS DRIVER 945ATHEROS ATH9K WIRELESS DRIVER
946P: Luis R. Rodriguez 946P: Luis R. Rodriguez
@@ -956,7 +956,7 @@ M: senthilkumar@atheros.com
956L: linux-wireless@vger.kernel.org 956L: linux-wireless@vger.kernel.org
957L: ath9k-devel@lists.ath9k.org 957L: ath9k-devel@lists.ath9k.org
958S: Supported 958S: Supported
959F: drivers/net/wireless/ath9k/ 959F: drivers/net/wireless/ath/ath9k/
960 960
961ATHEROS AR9170 WIRELESS DRIVER 961ATHEROS AR9170 WIRELESS DRIVER
962P: Christian Lamparter 962P: Christian Lamparter
@@ -964,7 +964,7 @@ M: chunkeey@web.de
964L: linux-wireless@vger.kernel.org 964L: linux-wireless@vger.kernel.org
965W: http://wireless.kernel.org/en/users/Drivers/ar9170 965W: http://wireless.kernel.org/en/users/Drivers/ar9170
966S: Maintained 966S: Maintained
967F: drivers/net/wireless/ar9170/ 967F: drivers/net/wireless/ath/ar9170/
968 968
969ATI_REMOTE2 DRIVER 969ATI_REMOTE2 DRIVER
970P: Ville Syrjala 970P: Ville Syrjala
diff --git a/drivers/net/wireless/ath/ath5k/base.c b/drivers/net/wireless/ath/ath5k/base.c
index 55f7de09d134..ea045151f953 100644
--- a/drivers/net/wireless/ath/ath5k/base.c
+++ b/drivers/net/wireless/ath/ath5k/base.c
@@ -538,6 +538,7 @@ ath5k_pci_probe(struct pci_dev *pdev,
538 sc->iobase = mem; /* So we can unmap it on detach */ 538 sc->iobase = mem; /* So we can unmap it on detach */
539 sc->cachelsz = csz * sizeof(u32); /* convert to bytes */ 539 sc->cachelsz = csz * sizeof(u32); /* convert to bytes */
540 sc->opmode = NL80211_IFTYPE_STATION; 540 sc->opmode = NL80211_IFTYPE_STATION;
541 sc->bintval = 1000;
541 mutex_init(&sc->lock); 542 mutex_init(&sc->lock);
542 spin_lock_init(&sc->rxbuflock); 543 spin_lock_init(&sc->rxbuflock);
543 spin_lock_init(&sc->txbuflock); 544 spin_lock_init(&sc->txbuflock);
@@ -686,6 +687,13 @@ ath5k_pci_resume(struct pci_dev *pdev)
686 if (err) 687 if (err)
687 return err; 688 return err;
688 689
690 /*
691 * Suspend/Resume resets the PCI configuration space, so we have to
692 * re-disable the RETRY_TIMEOUT register (0x41) to keep
693 * PCI Tx retries from interfering with C3 CPU state
694 */
695 pci_write_config_byte(pdev, 0x41, 0);
696
689 err = request_irq(pdev->irq, ath5k_intr, IRQF_SHARED, "ath", sc); 697 err = request_irq(pdev->irq, ath5k_intr, IRQF_SHARED, "ath", sc);
690 if (err) { 698 if (err) {
691 ATH5K_ERR(sc, "request_irq failed\n"); 699 ATH5K_ERR(sc, "request_irq failed\n");
@@ -2748,9 +2756,6 @@ static int ath5k_add_interface(struct ieee80211_hw *hw,
2748 goto end; 2756 goto end;
2749 } 2757 }
2750 2758
2751 /* Set to a reasonable value. Note that this will
2752 * be set to mac80211's value at ath5k_config(). */
2753 sc->bintval = 1000;
2754 ath5k_hw_set_lladdr(sc->ah, conf->mac_addr); 2759 ath5k_hw_set_lladdr(sc->ah, conf->mac_addr);
2755 2760
2756 ret = 0; 2761 ret = 0;
diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
index 9f49a3251d4d..66a6c1f5022a 100644
--- a/drivers/net/wireless/ath/ath9k/main.c
+++ b/drivers/net/wireless/ath/ath9k/main.c
@@ -1196,8 +1196,8 @@ void ath_radio_disable(struct ath_softc *sc)
1196 1196
1197 ath9k_hw_phy_disable(ah); 1197 ath9k_hw_phy_disable(ah);
1198 ath9k_hw_configpcipowersave(ah, 1); 1198 ath9k_hw_configpcipowersave(ah, 1);
1199 ath9k_hw_setpower(ah, ATH9K_PM_FULL_SLEEP);
1200 ath9k_ps_restore(sc); 1199 ath9k_ps_restore(sc);
1200 ath9k_hw_setpower(ah, ATH9K_PM_FULL_SLEEP);
1201} 1201}
1202 1202
1203/*******************/ 1203/*******************/
diff --git a/drivers/net/wireless/ath/ath9k/pci.c b/drivers/net/wireless/ath/ath9k/pci.c
index ccdf20a2e9be..170c5b32e49b 100644
--- a/drivers/net/wireless/ath/ath9k/pci.c
+++ b/drivers/net/wireless/ath/ath9k/pci.c
@@ -87,6 +87,7 @@ static int ath_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
87 struct ath_softc *sc; 87 struct ath_softc *sc;
88 struct ieee80211_hw *hw; 88 struct ieee80211_hw *hw;
89 u8 csz; 89 u8 csz;
90 u32 val;
90 int ret = 0; 91 int ret = 0;
91 struct ath_hw *ah; 92 struct ath_hw *ah;
92 93
@@ -133,6 +134,14 @@ static int ath_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
133 134
134 pci_set_master(pdev); 135 pci_set_master(pdev);
135 136
137 /*
138 * Disable the RETRY_TIMEOUT register (0x41) to keep
139 * PCI Tx retries from interfering with C3 CPU state.
140 */
141 pci_read_config_dword(pdev, 0x40, &val);
142 if ((val & 0x0000ff00) != 0)
143 pci_write_config_dword(pdev, 0x40, val & 0xffff00ff);
144
136 ret = pci_request_region(pdev, 0, "ath9k"); 145 ret = pci_request_region(pdev, 0, "ath9k");
137 if (ret) { 146 if (ret) {
138 dev_err(&pdev->dev, "PCI memory region reserve error\n"); 147 dev_err(&pdev->dev, "PCI memory region reserve error\n");
@@ -239,12 +248,21 @@ static int ath_pci_resume(struct pci_dev *pdev)
239 struct ieee80211_hw *hw = pci_get_drvdata(pdev); 248 struct ieee80211_hw *hw = pci_get_drvdata(pdev);
240 struct ath_wiphy *aphy = hw->priv; 249 struct ath_wiphy *aphy = hw->priv;
241 struct ath_softc *sc = aphy->sc; 250 struct ath_softc *sc = aphy->sc;
251 u32 val;
242 int err; 252 int err;
243 253
244 err = pci_enable_device(pdev); 254 err = pci_enable_device(pdev);
245 if (err) 255 if (err)
246 return err; 256 return err;
247 pci_restore_state(pdev); 257 pci_restore_state(pdev);
258 /*
259 * Suspend/Resume resets the PCI configuration space, so we have to
260 * re-disable the RETRY_TIMEOUT register (0x41) to keep
261 * PCI Tx retries from interfering with C3 CPU state
262 */
263 pci_read_config_dword(pdev, 0x40, &val);
264 if ((val & 0x0000ff00) != 0)
265 pci_write_config_dword(pdev, 0x40, val & 0xffff00ff);
248 266
249 /* Enable LED */ 267 /* Enable LED */
250 ath9k_hw_cfg_output(sc->sc_ah, ATH_LED_PIN, 268 ath9k_hw_cfg_output(sc->sc_ah, ATH_LED_PIN,
diff --git a/drivers/net/wireless/ath/ath9k/recv.c b/drivers/net/wireless/ath/ath9k/recv.c
index f99f3a76df3f..cece1c4c6bda 100644
--- a/drivers/net/wireless/ath/ath9k/recv.c
+++ b/drivers/net/wireless/ath/ath9k/recv.c
@@ -539,11 +539,14 @@ static void ath_rx_ps_beacon(struct ath_softc *sc, struct sk_buff *skb)
539 if (ath_beacon_dtim_pending_cab(skb)) { 539 if (ath_beacon_dtim_pending_cab(skb)) {
540 /* 540 /*
541 * Remain awake waiting for buffered broadcast/multicast 541 * Remain awake waiting for buffered broadcast/multicast
542 * frames. 542 * frames. If the last broadcast/multicast frame is not
543 * received properly, the next beacon frame will work as
544 * a backup trigger for returning into NETWORK SLEEP state,
545 * so we are waiting for it as well.
543 */ 546 */
544 DPRINTF(sc, ATH_DBG_PS, "Received DTIM beacon indicating " 547 DPRINTF(sc, ATH_DBG_PS, "Received DTIM beacon indicating "
545 "buffered broadcast/multicast frame(s)\n"); 548 "buffered broadcast/multicast frame(s)\n");
546 sc->sc_flags |= SC_OP_WAIT_FOR_CAB; 549 sc->sc_flags |= SC_OP_WAIT_FOR_CAB | SC_OP_WAIT_FOR_BEACON;
547 return; 550 return;
548 } 551 }
549 552
diff --git a/drivers/net/wireless/iwmc3200wifi/iwm.h b/drivers/net/wireless/iwmc3200wifi/iwm.h
index 635c16ee6186..77c339f8516c 100644
--- a/drivers/net/wireless/iwmc3200wifi/iwm.h
+++ b/drivers/net/wireless/iwmc3200wifi/iwm.h
@@ -288,6 +288,7 @@ struct iwm_priv {
288 u8 *eeprom; 288 u8 *eeprom;
289 struct timer_list watchdog; 289 struct timer_list watchdog;
290 struct work_struct reset_worker; 290 struct work_struct reset_worker;
291 struct mutex mutex;
291 struct rfkill *rfkill; 292 struct rfkill *rfkill;
292 293
293 char private[0] __attribute__((__aligned__(NETDEV_ALIGN))); 294 char private[0] __attribute__((__aligned__(NETDEV_ALIGN)));
@@ -315,8 +316,11 @@ extern const struct iw_handler_def iwm_iw_handler_def;
315void *iwm_if_alloc(int sizeof_bus, struct device *dev, 316void *iwm_if_alloc(int sizeof_bus, struct device *dev,
316 struct iwm_if_ops *if_ops); 317 struct iwm_if_ops *if_ops);
317void iwm_if_free(struct iwm_priv *iwm); 318void iwm_if_free(struct iwm_priv *iwm);
319int iwm_if_add(struct iwm_priv *iwm);
320void iwm_if_remove(struct iwm_priv *iwm);
318int iwm_mode_to_nl80211_iftype(int mode); 321int iwm_mode_to_nl80211_iftype(int mode);
319int iwm_priv_init(struct iwm_priv *iwm); 322int iwm_priv_init(struct iwm_priv *iwm);
323void iwm_priv_deinit(struct iwm_priv *iwm);
320void iwm_reset(struct iwm_priv *iwm); 324void iwm_reset(struct iwm_priv *iwm);
321void iwm_tx_credit_init_pools(struct iwm_priv *iwm, 325void iwm_tx_credit_init_pools(struct iwm_priv *iwm,
322 struct iwm_umac_notif_alive *alive); 326 struct iwm_umac_notif_alive *alive);
diff --git a/drivers/net/wireless/iwmc3200wifi/main.c b/drivers/net/wireless/iwmc3200wifi/main.c
index 6a2640f16b6d..8be206d58222 100644
--- a/drivers/net/wireless/iwmc3200wifi/main.c
+++ b/drivers/net/wireless/iwmc3200wifi/main.c
@@ -112,6 +112,9 @@ static void iwm_statistics_request(struct work_struct *work)
112 iwm_send_umac_stats_req(iwm, 0); 112 iwm_send_umac_stats_req(iwm, 0);
113} 113}
114 114
115int __iwm_up(struct iwm_priv *iwm);
116int __iwm_down(struct iwm_priv *iwm);
117
115static void iwm_reset_worker(struct work_struct *work) 118static void iwm_reset_worker(struct work_struct *work)
116{ 119{
117 struct iwm_priv *iwm; 120 struct iwm_priv *iwm;
@@ -120,6 +123,19 @@ static void iwm_reset_worker(struct work_struct *work)
120 123
121 iwm = container_of(work, struct iwm_priv, reset_worker); 124 iwm = container_of(work, struct iwm_priv, reset_worker);
122 125
126 /*
127 * XXX: The iwm->mutex is introduced purely for this reset work,
128 * because the other users for iwm_up and iwm_down are only netdev
129 * ndo_open and ndo_stop which are already protected by rtnl.
130 * Please remove iwm->mutex together if iwm_reset_worker() is not
131 * required in the future.
132 */
133 if (!mutex_trylock(&iwm->mutex)) {
134 IWM_WARN(iwm, "We are in the middle of interface bringing "
135 "UP/DOWN. Skip driver resetting.\n");
136 return;
137 }
138
123 if (iwm->umac_profile_active) { 139 if (iwm->umac_profile_active) {
124 profile = kmalloc(sizeof(struct iwm_umac_profile), GFP_KERNEL); 140 profile = kmalloc(sizeof(struct iwm_umac_profile), GFP_KERNEL);
125 if (profile) 141 if (profile)
@@ -128,10 +144,10 @@ static void iwm_reset_worker(struct work_struct *work)
128 IWM_ERR(iwm, "Couldn't alloc memory for profile\n"); 144 IWM_ERR(iwm, "Couldn't alloc memory for profile\n");
129 } 145 }
130 146
131 iwm_down(iwm); 147 __iwm_down(iwm);
132 148
133 while (retry++ < 3) { 149 while (retry++ < 3) {
134 ret = iwm_up(iwm); 150 ret = __iwm_up(iwm);
135 if (!ret) 151 if (!ret)
136 break; 152 break;
137 153
@@ -142,7 +158,7 @@ static void iwm_reset_worker(struct work_struct *work)
142 IWM_WARN(iwm, "iwm_up() failed: %d\n", ret); 158 IWM_WARN(iwm, "iwm_up() failed: %d\n", ret);
143 159
144 kfree(profile); 160 kfree(profile);
145 return; 161 goto out;
146 } 162 }
147 163
148 if (profile) { 164 if (profile) {
@@ -151,6 +167,9 @@ static void iwm_reset_worker(struct work_struct *work)
151 iwm_send_mlme_profile(iwm); 167 iwm_send_mlme_profile(iwm);
152 kfree(profile); 168 kfree(profile);
153 } 169 }
170
171 out:
172 mutex_unlock(&iwm->mutex);
154} 173}
155 174
156static void iwm_watchdog(unsigned long data) 175static void iwm_watchdog(unsigned long data)
@@ -215,10 +234,21 @@ int iwm_priv_init(struct iwm_priv *iwm)
215 init_timer(&iwm->watchdog); 234 init_timer(&iwm->watchdog);
216 iwm->watchdog.function = iwm_watchdog; 235 iwm->watchdog.function = iwm_watchdog;
217 iwm->watchdog.data = (unsigned long)iwm; 236 iwm->watchdog.data = (unsigned long)iwm;
237 mutex_init(&iwm->mutex);
218 238
219 return 0; 239 return 0;
220} 240}
221 241
242void iwm_priv_deinit(struct iwm_priv *iwm)
243{
244 int i;
245
246 for (i = 0; i < IWM_TX_QUEUES; i++)
247 destroy_workqueue(iwm->txq[i].wq);
248
249 destroy_workqueue(iwm->rx_wq);
250}
251
222/* 252/*
223 * We reset all the structures, and we reset the UMAC. 253 * We reset all the structures, and we reset the UMAC.
224 * After calling this routine, you're expected to reload 254 * After calling this routine, you're expected to reload
@@ -466,7 +496,7 @@ void iwm_link_off(struct iwm_priv *iwm)
466 496
467 iwm_rx_free(iwm); 497 iwm_rx_free(iwm);
468 498
469 cancel_delayed_work(&iwm->stats_request); 499 cancel_delayed_work_sync(&iwm->stats_request);
470 memset(wstats, 0, sizeof(struct iw_statistics)); 500 memset(wstats, 0, sizeof(struct iw_statistics));
471 wstats->qual.updated = IW_QUAL_ALL_INVALID; 501 wstats->qual.updated = IW_QUAL_ALL_INVALID;
472 502
@@ -511,7 +541,7 @@ static int iwm_channels_init(struct iwm_priv *iwm)
511 return 0; 541 return 0;
512} 542}
513 543
514int iwm_up(struct iwm_priv *iwm) 544int __iwm_up(struct iwm_priv *iwm)
515{ 545{
516 int ret; 546 int ret;
517 struct iwm_notif *notif_reboot, *notif_ack = NULL; 547 struct iwm_notif *notif_reboot, *notif_ack = NULL;
@@ -647,7 +677,18 @@ int iwm_up(struct iwm_priv *iwm)
647 return -EIO; 677 return -EIO;
648} 678}
649 679
650int iwm_down(struct iwm_priv *iwm) 680int iwm_up(struct iwm_priv *iwm)
681{
682 int ret;
683
684 mutex_lock(&iwm->mutex);
685 ret = __iwm_up(iwm);
686 mutex_unlock(&iwm->mutex);
687
688 return ret;
689}
690
691int __iwm_down(struct iwm_priv *iwm)
651{ 692{
652 int ret; 693 int ret;
653 694
@@ -678,3 +719,14 @@ int iwm_down(struct iwm_priv *iwm)
678 719
679 return 0; 720 return 0;
680} 721}
722
723int iwm_down(struct iwm_priv *iwm)
724{
725 int ret;
726
727 mutex_lock(&iwm->mutex);
728 ret = __iwm_down(iwm);
729 mutex_unlock(&iwm->mutex);
730
731 return ret;
732}
diff --git a/drivers/net/wireless/iwmc3200wifi/netdev.c b/drivers/net/wireless/iwmc3200wifi/netdev.c
index 68e2c3b6c7a1..aaa20c6885c8 100644
--- a/drivers/net/wireless/iwmc3200wifi/netdev.c
+++ b/drivers/net/wireless/iwmc3200wifi/netdev.c
@@ -114,32 +114,31 @@ void *iwm_if_alloc(int sizeof_bus, struct device *dev,
114 iwm = wdev_to_iwm(wdev); 114 iwm = wdev_to_iwm(wdev);
115 iwm->bus_ops = if_ops; 115 iwm->bus_ops = if_ops;
116 iwm->wdev = wdev; 116 iwm->wdev = wdev;
117 iwm_priv_init(iwm); 117
118 ret = iwm_priv_init(iwm);
119 if (ret) {
120 dev_err(dev, "failed to init iwm_priv\n");
121 goto out_wdev;
122 }
123
118 wdev->iftype = iwm_mode_to_nl80211_iftype(iwm->conf.mode); 124 wdev->iftype = iwm_mode_to_nl80211_iftype(iwm->conf.mode);
119 125
120 ndev = alloc_netdev_mq(0, "wlan%d", ether_setup, 126 ndev = alloc_netdev_mq(0, "wlan%d", ether_setup, IWM_TX_QUEUES);
121 IWM_TX_QUEUES);
122 if (!ndev) { 127 if (!ndev) {
123 dev_err(dev, "no memory for network device instance\n"); 128 dev_err(dev, "no memory for network device instance\n");
124 goto out_wdev; 129 goto out_priv;
125 } 130 }
126 131
127 ndev->netdev_ops = &iwm_netdev_ops; 132 ndev->netdev_ops = &iwm_netdev_ops;
128 ndev->wireless_handlers = &iwm_iw_handler_def; 133 ndev->wireless_handlers = &iwm_iw_handler_def;
129 ndev->ieee80211_ptr = wdev; 134 ndev->ieee80211_ptr = wdev;
130 SET_NETDEV_DEV(ndev, wiphy_dev(wdev->wiphy)); 135 SET_NETDEV_DEV(ndev, wiphy_dev(wdev->wiphy));
131 ret = register_netdev(ndev);
132 if (ret < 0) {
133 dev_err(dev, "Failed to register netdev: %d\n", ret);
134 goto out_ndev;
135 }
136
137 wdev->netdev = ndev; 136 wdev->netdev = ndev;
138 137
139 return iwm; 138 return iwm;
140 139
141 out_ndev: 140 out_priv:
142 free_netdev(ndev); 141 iwm_priv_deinit(iwm);
143 142
144 out_wdev: 143 out_wdev:
145 iwm_wdev_free(iwm); 144 iwm_wdev_free(iwm);
@@ -148,15 +147,29 @@ void *iwm_if_alloc(int sizeof_bus, struct device *dev,
148 147
149void iwm_if_free(struct iwm_priv *iwm) 148void iwm_if_free(struct iwm_priv *iwm)
150{ 149{
151 int i;
152
153 if (!iwm_to_ndev(iwm)) 150 if (!iwm_to_ndev(iwm))
154 return; 151 return;
155 152
156 unregister_netdev(iwm_to_ndev(iwm));
157 free_netdev(iwm_to_ndev(iwm)); 153 free_netdev(iwm_to_ndev(iwm));
158 iwm_wdev_free(iwm); 154 iwm_wdev_free(iwm);
159 destroy_workqueue(iwm->rx_wq); 155 iwm_priv_deinit(iwm);
160 for (i = 0; i < IWM_TX_QUEUES; i++) 156}
161 destroy_workqueue(iwm->txq[i].wq); 157
158int iwm_if_add(struct iwm_priv *iwm)
159{
160 struct net_device *ndev = iwm_to_ndev(iwm);
161 int ret;
162
163 ret = register_netdev(ndev);
164 if (ret < 0) {
165 dev_err(&ndev->dev, "Failed to register netdev: %d\n", ret);
166 return ret;
167 }
168
169 return 0;
170}
171
172void iwm_if_remove(struct iwm_priv *iwm)
173{
174 unregister_netdev(iwm_to_ndev(iwm));
162} 175}
diff --git a/drivers/net/wireless/iwmc3200wifi/sdio.c b/drivers/net/wireless/iwmc3200wifi/sdio.c
index b54da677b371..916681837fd2 100644
--- a/drivers/net/wireless/iwmc3200wifi/sdio.c
+++ b/drivers/net/wireless/iwmc3200wifi/sdio.c
@@ -454,10 +454,18 @@ static int iwm_sdio_probe(struct sdio_func *func,
454 454
455 INIT_WORK(&hw->isr_worker, iwm_sdio_isr_worker); 455 INIT_WORK(&hw->isr_worker, iwm_sdio_isr_worker);
456 456
457 ret = iwm_if_add(iwm);
458 if (ret) {
459 dev_err(dev, "add SDIO interface failed\n");
460 goto destroy_wq;
461 }
462
457 dev_info(dev, "IWM SDIO probe\n"); 463 dev_info(dev, "IWM SDIO probe\n");
458 464
459 return 0; 465 return 0;
460 466
467 destroy_wq:
468 destroy_workqueue(hw->isr_wq);
461 debugfs_exit: 469 debugfs_exit:
462 iwm_debugfs_exit(iwm); 470 iwm_debugfs_exit(iwm);
463 if_free: 471 if_free:
@@ -471,9 +479,10 @@ static void iwm_sdio_remove(struct sdio_func *func)
471 struct iwm_priv *iwm = hw_to_iwm(hw); 479 struct iwm_priv *iwm = hw_to_iwm(hw);
472 struct device *dev = &func->dev; 480 struct device *dev = &func->dev;
473 481
482 iwm_if_remove(iwm);
483 destroy_workqueue(hw->isr_wq);
474 iwm_debugfs_exit(iwm); 484 iwm_debugfs_exit(iwm);
475 iwm_if_free(iwm); 485 iwm_if_free(iwm);
476 destroy_workqueue(hw->isr_wq);
477 486
478 sdio_set_drvdata(func, NULL); 487 sdio_set_drvdata(func, NULL);
479 488
diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c
index f0e5e943f6e3..14a19baff214 100644
--- a/drivers/net/wireless/zd1211rw/zd_usb.c
+++ b/drivers/net/wireless/zd1211rw/zd_usb.c
@@ -67,6 +67,7 @@ static struct usb_device_id usb_ids[] = {
67 { USB_DEVICE(0x079b, 0x0062), .driver_info = DEVICE_ZD1211B }, 67 { USB_DEVICE(0x079b, 0x0062), .driver_info = DEVICE_ZD1211B },
68 { USB_DEVICE(0x1582, 0x6003), .driver_info = DEVICE_ZD1211B }, 68 { USB_DEVICE(0x1582, 0x6003), .driver_info = DEVICE_ZD1211B },
69 { USB_DEVICE(0x050d, 0x705c), .driver_info = DEVICE_ZD1211B }, 69 { USB_DEVICE(0x050d, 0x705c), .driver_info = DEVICE_ZD1211B },
70 { USB_DEVICE(0x083a, 0xe503), .driver_info = DEVICE_ZD1211B },
70 { USB_DEVICE(0x083a, 0xe506), .driver_info = DEVICE_ZD1211B }, 71 { USB_DEVICE(0x083a, 0xe506), .driver_info = DEVICE_ZD1211B },
71 { USB_DEVICE(0x083a, 0x4505), .driver_info = DEVICE_ZD1211B }, 72 { USB_DEVICE(0x083a, 0x4505), .driver_info = DEVICE_ZD1211B },
72 { USB_DEVICE(0x0471, 0x1236), .driver_info = DEVICE_ZD1211B }, 73 { USB_DEVICE(0x0471, 0x1236), .driver_info = DEVICE_ZD1211B },
diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c
index 09a503e5da6a..be2fd6f91639 100644
--- a/drivers/platform/x86/acer-wmi.c
+++ b/drivers/platform/x86/acer-wmi.c
@@ -958,12 +958,12 @@ static void acer_rfkill_update(struct work_struct *ignored)
958 958
959 status = get_u32(&state, ACER_CAP_WIRELESS); 959 status = get_u32(&state, ACER_CAP_WIRELESS);
960 if (ACPI_SUCCESS(status)) 960 if (ACPI_SUCCESS(status))
961 rfkill_set_sw_state(wireless_rfkill, !!state); 961 rfkill_set_sw_state(wireless_rfkill, !state);
962 962
963 if (has_cap(ACER_CAP_BLUETOOTH)) { 963 if (has_cap(ACER_CAP_BLUETOOTH)) {
964 status = get_u32(&state, ACER_CAP_BLUETOOTH); 964 status = get_u32(&state, ACER_CAP_BLUETOOTH);
965 if (ACPI_SUCCESS(status)) 965 if (ACPI_SUCCESS(status))
966 rfkill_set_sw_state(bluetooth_rfkill, !!state); 966 rfkill_set_sw_state(bluetooth_rfkill, !state);
967 } 967 }
968 968
969 schedule_delayed_work(&acer_rfkill_work, round_jiffies_relative(HZ)); 969 schedule_delayed_work(&acer_rfkill_work, round_jiffies_relative(HZ));
diff --git a/drivers/platform/x86/eeepc-laptop.c b/drivers/platform/x86/eeepc-laptop.c
index 03bf522bd7ab..8153b3e59189 100644
--- a/drivers/platform/x86/eeepc-laptop.c
+++ b/drivers/platform/x86/eeepc-laptop.c
@@ -180,6 +180,7 @@ static struct key_entry eeepc_keymap[] = {
180 */ 180 */
181static int eeepc_hotk_add(struct acpi_device *device); 181static int eeepc_hotk_add(struct acpi_device *device);
182static int eeepc_hotk_remove(struct acpi_device *device, int type); 182static int eeepc_hotk_remove(struct acpi_device *device, int type);
183static int eeepc_hotk_resume(struct acpi_device *device);
183 184
184static const struct acpi_device_id eeepc_device_ids[] = { 185static const struct acpi_device_id eeepc_device_ids[] = {
185 {EEEPC_HOTK_HID, 0}, 186 {EEEPC_HOTK_HID, 0},
@@ -194,6 +195,7 @@ static struct acpi_driver eeepc_hotk_driver = {
194 .ops = { 195 .ops = {
195 .add = eeepc_hotk_add, 196 .add = eeepc_hotk_add,
196 .remove = eeepc_hotk_remove, 197 .remove = eeepc_hotk_remove,
198 .resume = eeepc_hotk_resume,
197 }, 199 },
198}; 200};
199 201
@@ -512,15 +514,12 @@ static int notify_brn(void)
512 return -1; 514 return -1;
513} 515}
514 516
515static void eeepc_rfkill_notify(acpi_handle handle, u32 event, void *data) 517static void eeepc_rfkill_hotplug(void)
516{ 518{
517 struct pci_dev *dev; 519 struct pci_dev *dev;
518 struct pci_bus *bus = pci_find_bus(0, 1); 520 struct pci_bus *bus = pci_find_bus(0, 1);
519 bool blocked; 521 bool blocked;
520 522
521 if (event != ACPI_NOTIFY_BUS_CHECK)
522 return;
523
524 if (!bus) { 523 if (!bus) {
525 printk(EEEPC_WARNING "Unable to find PCI bus 1?\n"); 524 printk(EEEPC_WARNING "Unable to find PCI bus 1?\n");
526 return; 525 return;
@@ -551,6 +550,14 @@ static void eeepc_rfkill_notify(acpi_handle handle, u32 event, void *data)
551 rfkill_set_sw_state(ehotk->eeepc_wlan_rfkill, blocked); 550 rfkill_set_sw_state(ehotk->eeepc_wlan_rfkill, blocked);
552} 551}
553 552
553static void eeepc_rfkill_notify(acpi_handle handle, u32 event, void *data)
554{
555 if (event != ACPI_NOTIFY_BUS_CHECK)
556 return;
557
558 eeepc_rfkill_hotplug();
559}
560
554static void eeepc_hotk_notify(acpi_handle handle, u32 event, void *data) 561static void eeepc_hotk_notify(acpi_handle handle, u32 event, void *data)
555{ 562{
556 static struct key_entry *key; 563 static struct key_entry *key;
@@ -675,8 +682,8 @@ static int eeepc_hotk_add(struct acpi_device *device)
675 if (!ehotk->eeepc_wlan_rfkill) 682 if (!ehotk->eeepc_wlan_rfkill)
676 goto wlan_fail; 683 goto wlan_fail;
677 684
678 rfkill_set_sw_state(ehotk->eeepc_wlan_rfkill, 685 rfkill_init_sw_state(ehotk->eeepc_wlan_rfkill,
679 get_acpi(CM_ASL_WLAN) != 1); 686 get_acpi(CM_ASL_WLAN) != 1);
680 result = rfkill_register(ehotk->eeepc_wlan_rfkill); 687 result = rfkill_register(ehotk->eeepc_wlan_rfkill);
681 if (result) 688 if (result)
682 goto wlan_fail; 689 goto wlan_fail;
@@ -693,8 +700,8 @@ static int eeepc_hotk_add(struct acpi_device *device)
693 if (!ehotk->eeepc_bluetooth_rfkill) 700 if (!ehotk->eeepc_bluetooth_rfkill)
694 goto bluetooth_fail; 701 goto bluetooth_fail;
695 702
696 rfkill_set_sw_state(ehotk->eeepc_bluetooth_rfkill, 703 rfkill_init_sw_state(ehotk->eeepc_bluetooth_rfkill,
697 get_acpi(CM_ASL_BLUETOOTH) != 1); 704 get_acpi(CM_ASL_BLUETOOTH) != 1);
698 result = rfkill_register(ehotk->eeepc_bluetooth_rfkill); 705 result = rfkill_register(ehotk->eeepc_bluetooth_rfkill);
699 if (result) 706 if (result)
700 goto bluetooth_fail; 707 goto bluetooth_fail;
@@ -734,6 +741,33 @@ static int eeepc_hotk_remove(struct acpi_device *device, int type)
734 return 0; 741 return 0;
735} 742}
736 743
744static int eeepc_hotk_resume(struct acpi_device *device)
745{
746 if (ehotk->eeepc_wlan_rfkill) {
747 bool wlan;
748
749 /* Workaround - it seems that _PTS disables the wireless
750 without notification or changing the value read by WLAN.
751 Normally this is fine because the correct value is restored
752 from the non-volatile storage on resume, but we need to do
753 it ourself if case suspend is aborted, or we lose wireless.
754 */
755 wlan = get_acpi(CM_ASL_WLAN);
756 set_acpi(CM_ASL_WLAN, wlan);
757
758 rfkill_set_sw_state(ehotk->eeepc_wlan_rfkill,
759 wlan != 1);
760
761 eeepc_rfkill_hotplug();
762 }
763
764 if (ehotk->eeepc_bluetooth_rfkill)
765 rfkill_set_sw_state(ehotk->eeepc_bluetooth_rfkill,
766 get_acpi(CM_ASL_BLUETOOTH) != 1);
767
768 return 0;
769}
770
737/* 771/*
738 * Hwmon 772 * Hwmon
739 */ 773 */
diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
index 86e958539f46..40d64c03278c 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -1163,8 +1163,8 @@ static int __init tpacpi_new_rfkill(const enum tpacpi_rfk_id id,
1163{ 1163{
1164 struct tpacpi_rfk *atp_rfk; 1164 struct tpacpi_rfk *atp_rfk;
1165 int res; 1165 int res;
1166 bool initial_sw_state = false; 1166 bool sw_state = false;
1167 int initial_sw_status; 1167 int sw_status;
1168 1168
1169 BUG_ON(id >= TPACPI_RFK_SW_MAX || tpacpi_rfkill_switches[id]); 1169 BUG_ON(id >= TPACPI_RFK_SW_MAX || tpacpi_rfkill_switches[id]);
1170 1170
@@ -1185,17 +1185,17 @@ static int __init tpacpi_new_rfkill(const enum tpacpi_rfk_id id,
1185 atp_rfk->id = id; 1185 atp_rfk->id = id;
1186 atp_rfk->ops = tp_rfkops; 1186 atp_rfk->ops = tp_rfkops;
1187 1187
1188 initial_sw_status = (tp_rfkops->get_status)(); 1188 sw_status = (tp_rfkops->get_status)();
1189 if (initial_sw_status < 0) { 1189 if (sw_status < 0) {
1190 printk(TPACPI_ERR 1190 printk(TPACPI_ERR
1191 "failed to read initial state for %s, error %d\n", 1191 "failed to read initial state for %s, error %d\n",
1192 name, initial_sw_status); 1192 name, sw_status);
1193 } else { 1193 } else {
1194 initial_sw_state = (initial_sw_status == TPACPI_RFK_RADIO_OFF); 1194 sw_state = (sw_status == TPACPI_RFK_RADIO_OFF);
1195 if (set_default) { 1195 if (set_default) {
1196 /* try to keep the initial state, since we ask the 1196 /* try to keep the initial state, since we ask the
1197 * firmware to preserve it across S5 in NVRAM */ 1197 * firmware to preserve it across S5 in NVRAM */
1198 rfkill_set_sw_state(atp_rfk->rfkill, initial_sw_state); 1198 rfkill_init_sw_state(atp_rfk->rfkill, sw_state);
1199 } 1199 }
1200 } 1200 }
1201 rfkill_set_hw_state(atp_rfk->rfkill, tpacpi_rfk_check_hwblock_state()); 1201 rfkill_set_hw_state(atp_rfk->rfkill, tpacpi_rfk_check_hwblock_state());
diff --git a/include/linux/rfkill.h b/include/linux/rfkill.h
index 16e39c7a67fc..e73e2429a1b1 100644
--- a/include/linux/rfkill.h
+++ b/include/linux/rfkill.h
@@ -160,8 +160,9 @@ struct rfkill * __must_check rfkill_alloc(const char *name,
160 * the rfkill structure. Before calling this function the driver needs 160 * the rfkill structure. Before calling this function the driver needs
161 * to be ready to service method calls from rfkill. 161 * to be ready to service method calls from rfkill.
162 * 162 *
163 * If the software blocked state is not set before registration, 163 * If rfkill_init_sw_state() is not called before registration,
164 * set_block will be called to initialize it to a default value. 164 * set_block() will be called to initialize the software blocked state
165 * to a default value.
165 * 166 *
166 * If the hardware blocked state is not set before registration, 167 * If the hardware blocked state is not set before registration,
167 * it is assumed to be unblocked. 168 * it is assumed to be unblocked.
@@ -234,9 +235,11 @@ bool __must_check rfkill_set_hw_state(struct rfkill *rfkill, bool blocked);
234 * rfkill drivers that get events when the soft-blocked state changes 235 * rfkill drivers that get events when the soft-blocked state changes
235 * (yes, some platforms directly act on input but allow changing again) 236 * (yes, some platforms directly act on input but allow changing again)
236 * use this function to notify the rfkill core (and through that also 237 * use this function to notify the rfkill core (and through that also
237 * userspace) of the current state. It is not necessary to notify on 238 * userspace) of the current state.
238 * resume; since hibernation can always change the soft-blocked state, 239 *
239 * the rfkill core will unconditionally restore the previous state. 240 * Drivers should also call this function after resume if the state has
241 * been changed by the user. This only makes sense for "persistent"
242 * devices (see rfkill_init_sw_state()).
240 * 243 *
241 * This function can be called in any context, even from within rfkill 244 * This function can be called in any context, even from within rfkill
242 * callbacks. 245 * callbacks.
@@ -247,6 +250,22 @@ bool __must_check rfkill_set_hw_state(struct rfkill *rfkill, bool blocked);
247bool rfkill_set_sw_state(struct rfkill *rfkill, bool blocked); 250bool rfkill_set_sw_state(struct rfkill *rfkill, bool blocked);
248 251
249/** 252/**
253 * rfkill_init_sw_state - Initialize persistent software block state
254 * @rfkill: pointer to the rfkill class to modify.
255 * @state: the current software block state to set
256 *
257 * rfkill drivers that preserve their software block state over power off
258 * use this function to notify the rfkill core (and through that also
259 * userspace) of their initial state. It should only be used before
260 * registration.
261 *
262 * In addition, it marks the device as "persistent", an attribute which
263 * can be read by userspace. Persistent devices are expected to preserve
264 * their own state when suspended.
265 */
266void rfkill_init_sw_state(struct rfkill *rfkill, bool blocked);
267
268/**
250 * rfkill_set_states - Set the internal rfkill block states 269 * rfkill_set_states - Set the internal rfkill block states
251 * @rfkill: pointer to the rfkill class to modify. 270 * @rfkill: pointer to the rfkill class to modify.
252 * @sw: the current software block state to set 271 * @sw: the current software block state to set
@@ -307,6 +326,10 @@ static inline bool rfkill_set_sw_state(struct rfkill *rfkill, bool blocked)
307 return blocked; 326 return blocked;
308} 327}
309 328
329static inline void rfkill_init_sw_state(struct rfkill *rfkill, bool blocked)
330{
331}
332
310static inline void rfkill_set_states(struct rfkill *rfkill, bool sw, bool hw) 333static inline void rfkill_set_states(struct rfkill *rfkill, bool sw, bool hw)
311{ 334{
312} 335}
diff --git a/net/rfkill/core.c b/net/rfkill/core.c
index 4e68ab439d5d..79693fe2001e 100644
--- a/net/rfkill/core.c
+++ b/net/rfkill/core.c
@@ -56,7 +56,6 @@ struct rfkill {
56 u32 idx; 56 u32 idx;
57 57
58 bool registered; 58 bool registered;
59 bool suspended;
60 bool persistent; 59 bool persistent;
61 60
62 const struct rfkill_ops *ops; 61 const struct rfkill_ops *ops;
@@ -224,7 +223,7 @@ static void rfkill_send_events(struct rfkill *rfkill, enum rfkill_operation op)
224 223
225static void rfkill_event(struct rfkill *rfkill) 224static void rfkill_event(struct rfkill *rfkill)
226{ 225{
227 if (!rfkill->registered || rfkill->suspended) 226 if (!rfkill->registered)
228 return; 227 return;
229 228
230 kobject_uevent(&rfkill->dev.kobj, KOBJ_CHANGE); 229 kobject_uevent(&rfkill->dev.kobj, KOBJ_CHANGE);
@@ -270,6 +269,9 @@ static void rfkill_set_block(struct rfkill *rfkill, bool blocked)
270 unsigned long flags; 269 unsigned long flags;
271 int err; 270 int err;
272 271
272 if (unlikely(rfkill->dev.power.power_state.event & PM_EVENT_SLEEP))
273 return;
274
273 /* 275 /*
274 * Some platforms (...!) generate input events which affect the 276 * Some platforms (...!) generate input events which affect the
275 * _hard_ kill state -- whenever something tries to change the 277 * _hard_ kill state -- whenever something tries to change the
@@ -292,9 +294,6 @@ static void rfkill_set_block(struct rfkill *rfkill, bool blocked)
292 rfkill->state |= RFKILL_BLOCK_SW_SETCALL; 294 rfkill->state |= RFKILL_BLOCK_SW_SETCALL;
293 spin_unlock_irqrestore(&rfkill->lock, flags); 295 spin_unlock_irqrestore(&rfkill->lock, flags);
294 296
295 if (unlikely(rfkill->dev.power.power_state.event & PM_EVENT_SLEEP))
296 return;
297
298 err = rfkill->ops->set_block(rfkill->data, blocked); 297 err = rfkill->ops->set_block(rfkill->data, blocked);
299 298
300 spin_lock_irqsave(&rfkill->lock, flags); 299 spin_lock_irqsave(&rfkill->lock, flags);
@@ -508,19 +507,32 @@ bool rfkill_set_sw_state(struct rfkill *rfkill, bool blocked)
508 blocked = blocked || hwblock; 507 blocked = blocked || hwblock;
509 spin_unlock_irqrestore(&rfkill->lock, flags); 508 spin_unlock_irqrestore(&rfkill->lock, flags);
510 509
511 if (!rfkill->registered) { 510 if (!rfkill->registered)
512 rfkill->persistent = true; 511 return blocked;
513 } else {
514 if (prev != blocked && !hwblock)
515 schedule_work(&rfkill->uevent_work);
516 512
517 rfkill_led_trigger_event(rfkill); 513 if (prev != blocked && !hwblock)
518 } 514 schedule_work(&rfkill->uevent_work);
515
516 rfkill_led_trigger_event(rfkill);
519 517
520 return blocked; 518 return blocked;
521} 519}
522EXPORT_SYMBOL(rfkill_set_sw_state); 520EXPORT_SYMBOL(rfkill_set_sw_state);
523 521
522void rfkill_init_sw_state(struct rfkill *rfkill, bool blocked)
523{
524 unsigned long flags;
525
526 BUG_ON(!rfkill);
527 BUG_ON(rfkill->registered);
528
529 spin_lock_irqsave(&rfkill->lock, flags);
530 __rfkill_set_sw_state(rfkill, blocked);
531 rfkill->persistent = true;
532 spin_unlock_irqrestore(&rfkill->lock, flags);
533}
534EXPORT_SYMBOL(rfkill_init_sw_state);
535
524void rfkill_set_states(struct rfkill *rfkill, bool sw, bool hw) 536void rfkill_set_states(struct rfkill *rfkill, bool sw, bool hw)
525{ 537{
526 unsigned long flags; 538 unsigned long flags;
@@ -598,6 +610,15 @@ static ssize_t rfkill_idx_show(struct device *dev,
598 return sprintf(buf, "%d\n", rfkill->idx); 610 return sprintf(buf, "%d\n", rfkill->idx);
599} 611}
600 612
613static ssize_t rfkill_persistent_show(struct device *dev,
614 struct device_attribute *attr,
615 char *buf)
616{
617 struct rfkill *rfkill = to_rfkill(dev);
618
619 return sprintf(buf, "%d\n", rfkill->persistent);
620}
621
601static u8 user_state_from_blocked(unsigned long state) 622static u8 user_state_from_blocked(unsigned long state)
602{ 623{
603 if (state & RFKILL_BLOCK_HW) 624 if (state & RFKILL_BLOCK_HW)
@@ -656,6 +677,7 @@ static struct device_attribute rfkill_dev_attrs[] = {
656 __ATTR(name, S_IRUGO, rfkill_name_show, NULL), 677 __ATTR(name, S_IRUGO, rfkill_name_show, NULL),
657 __ATTR(type, S_IRUGO, rfkill_type_show, NULL), 678 __ATTR(type, S_IRUGO, rfkill_type_show, NULL),
658 __ATTR(index, S_IRUGO, rfkill_idx_show, NULL), 679 __ATTR(index, S_IRUGO, rfkill_idx_show, NULL),
680 __ATTR(persistent, S_IRUGO, rfkill_persistent_show, NULL),
659 __ATTR(state, S_IRUGO|S_IWUSR, rfkill_state_show, rfkill_state_store), 681 __ATTR(state, S_IRUGO|S_IWUSR, rfkill_state_show, rfkill_state_store),
660 __ATTR(claim, S_IRUGO|S_IWUSR, rfkill_claim_show, rfkill_claim_store), 682 __ATTR(claim, S_IRUGO|S_IWUSR, rfkill_claim_show, rfkill_claim_store),
661 __ATTR_NULL 683 __ATTR_NULL
@@ -718,8 +740,6 @@ static int rfkill_suspend(struct device *dev, pm_message_t state)
718 740
719 rfkill_pause_polling(rfkill); 741 rfkill_pause_polling(rfkill);
720 742
721 rfkill->suspended = true;
722
723 return 0; 743 return 0;
724} 744}
725 745
@@ -728,10 +748,10 @@ static int rfkill_resume(struct device *dev)
728 struct rfkill *rfkill = to_rfkill(dev); 748 struct rfkill *rfkill = to_rfkill(dev);
729 bool cur; 749 bool cur;
730 750
731 cur = !!(rfkill->state & RFKILL_BLOCK_SW); 751 if (!rfkill->persistent) {
732 rfkill_set_block(rfkill, cur); 752 cur = !!(rfkill->state & RFKILL_BLOCK_SW);
733 753 rfkill_set_block(rfkill, cur);
734 rfkill->suspended = false; 754 }
735 755
736 rfkill_resume_polling(rfkill); 756 rfkill_resume_polling(rfkill);
737 757
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 24168560ebae..241bddd0b4f1 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -1687,13 +1687,52 @@ static int nl80211_set_station(struct sk_buff *skb, struct genl_info *info)
1687 if (err) 1687 if (err)
1688 goto out_rtnl; 1688 goto out_rtnl;
1689 1689
1690 if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_AP && 1690 err = get_vlan(info->attrs[NL80211_ATTR_STA_VLAN], drv, &params.vlan);
1691 dev->ieee80211_ptr->iftype != NL80211_IFTYPE_AP_VLAN) { 1691 if (err)
1692 err = -EINVAL;
1693 goto out; 1692 goto out;
1693
1694 /* validate settings */
1695 err = 0;
1696
1697 switch (dev->ieee80211_ptr->iftype) {
1698 case NL80211_IFTYPE_AP:
1699 case NL80211_IFTYPE_AP_VLAN:
1700 /* disallow mesh-specific things */
1701 if (params.plink_action)
1702 err = -EINVAL;
1703 break;
1704 case NL80211_IFTYPE_STATION:
1705 /* disallow everything but AUTHORIZED flag */
1706 if (params.plink_action)
1707 err = -EINVAL;
1708 if (params.vlan)
1709 err = -EINVAL;
1710 if (params.supported_rates)
1711 err = -EINVAL;
1712 if (params.ht_capa)
1713 err = -EINVAL;
1714 if (params.listen_interval >= 0)
1715 err = -EINVAL;
1716 if (params.sta_flags_mask & ~BIT(NL80211_STA_FLAG_AUTHORIZED))
1717 err = -EINVAL;
1718 break;
1719 case NL80211_IFTYPE_MESH_POINT:
1720 /* disallow things mesh doesn't support */
1721 if (params.vlan)
1722 err = -EINVAL;
1723 if (params.ht_capa)
1724 err = -EINVAL;
1725 if (params.listen_interval >= 0)
1726 err = -EINVAL;
1727 if (params.supported_rates)
1728 err = -EINVAL;
1729 if (params.sta_flags_mask)
1730 err = -EINVAL;
1731 break;
1732 default:
1733 err = -EINVAL;
1694 } 1734 }
1695 1735
1696 err = get_vlan(info->attrs[NL80211_ATTR_STA_VLAN], drv, &params.vlan);
1697 if (err) 1736 if (err)
1698 goto out; 1737 goto out;
1699 1738
@@ -1728,9 +1767,6 @@ static int nl80211_new_station(struct sk_buff *skb, struct genl_info *info)
1728 if (!info->attrs[NL80211_ATTR_MAC]) 1767 if (!info->attrs[NL80211_ATTR_MAC])
1729 return -EINVAL; 1768 return -EINVAL;
1730 1769
1731 if (!info->attrs[NL80211_ATTR_STA_AID])
1732 return -EINVAL;
1733
1734 if (!info->attrs[NL80211_ATTR_STA_LISTEN_INTERVAL]) 1770 if (!info->attrs[NL80211_ATTR_STA_LISTEN_INTERVAL])
1735 return -EINVAL; 1771 return -EINVAL;
1736 1772
@@ -1745,9 +1781,11 @@ static int nl80211_new_station(struct sk_buff *skb, struct genl_info *info)
1745 params.listen_interval = 1781 params.listen_interval =
1746 nla_get_u16(info->attrs[NL80211_ATTR_STA_LISTEN_INTERVAL]); 1782 nla_get_u16(info->attrs[NL80211_ATTR_STA_LISTEN_INTERVAL]);
1747 1783
1748 params.aid = nla_get_u16(info->attrs[NL80211_ATTR_STA_AID]); 1784 if (info->attrs[NL80211_ATTR_STA_AID]) {
1749 if (!params.aid || params.aid > IEEE80211_MAX_AID) 1785 params.aid = nla_get_u16(info->attrs[NL80211_ATTR_STA_AID]);
1750 return -EINVAL; 1786 if (!params.aid || params.aid > IEEE80211_MAX_AID)
1787 return -EINVAL;
1788 }
1751 1789
1752 if (info->attrs[NL80211_ATTR_HT_CAPABILITY]) 1790 if (info->attrs[NL80211_ATTR_HT_CAPABILITY])
1753 params.ht_capa = 1791 params.ht_capa =
@@ -1762,13 +1800,39 @@ static int nl80211_new_station(struct sk_buff *skb, struct genl_info *info)
1762 if (err) 1800 if (err)
1763 goto out_rtnl; 1801 goto out_rtnl;
1764 1802
1765 if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_AP && 1803 err = get_vlan(info->attrs[NL80211_ATTR_STA_VLAN], drv, &params.vlan);
1766 dev->ieee80211_ptr->iftype != NL80211_IFTYPE_AP_VLAN) { 1804 if (err)
1767 err = -EINVAL;
1768 goto out; 1805 goto out;
1806
1807 /* validate settings */
1808 err = 0;
1809
1810 switch (dev->ieee80211_ptr->iftype) {
1811 case NL80211_IFTYPE_AP:
1812 case NL80211_IFTYPE_AP_VLAN:
1813 /* all ok but must have AID */
1814 if (!params.aid)
1815 err = -EINVAL;
1816 break;
1817 case NL80211_IFTYPE_MESH_POINT:
1818 /* disallow things mesh doesn't support */
1819 if (params.vlan)
1820 err = -EINVAL;
1821 if (params.aid)
1822 err = -EINVAL;
1823 if (params.ht_capa)
1824 err = -EINVAL;
1825 if (params.listen_interval >= 0)
1826 err = -EINVAL;
1827 if (params.supported_rates)
1828 err = -EINVAL;
1829 if (params.sta_flags_mask)
1830 err = -EINVAL;
1831 break;
1832 default:
1833 err = -EINVAL;
1769 } 1834 }
1770 1835
1771 err = get_vlan(info->attrs[NL80211_ATTR_STA_VLAN], drv, &params.vlan);
1772 if (err) 1836 if (err)
1773 goto out; 1837 goto out;
1774 1838
@@ -1812,7 +1876,8 @@ static int nl80211_del_station(struct sk_buff *skb, struct genl_info *info)
1812 goto out_rtnl; 1876 goto out_rtnl;
1813 1877
1814 if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_AP && 1878 if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_AP &&
1815 dev->ieee80211_ptr->iftype != NL80211_IFTYPE_AP_VLAN) { 1879 dev->ieee80211_ptr->iftype != NL80211_IFTYPE_AP_VLAN &&
1880 dev->ieee80211_ptr->iftype != NL80211_IFTYPE_MESH_POINT) {
1816 err = -EINVAL; 1881 err = -EINVAL;
1817 goto out; 1882 goto out;
1818 } 1883 }