diff options
author | Johannes Berg <johannes@sipsolutions.net> | 2009-06-13 05:20:26 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2009-06-15 15:05:57 -0400 |
commit | 3b319aae4244f9b4758212605f67cf63207a4fa1 (patch) | |
tree | 52a06f91c8a4d8784904bb46cbc2a0581ece7069 | |
parent | 159cd468bc885f7a2fbc75bbfe782782e52ef9c9 (diff) |
ath9k: port to cfg80211 rfkill
This ports the ath9k rfkill code to the new API offered by
cfg80211 and thus removes a lot of useless stuff.
("With this series a kernel panic, which is a regression, during module
unload disappears." -- Vasanthakumar Thiagarajan <vasanth@atheros.com>
Other patches in the series:
ath9k: Add helper to get ath9k specific current channel
ath9k: Make sure we have current channel in ah_curchan before rf
disable/enable
-- JWL)
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Cc: Luis Rodriguez <mcgrof@gmail.com>
Tested-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r-- | drivers/net/wireless/ath/ath9k/Kconfig | 1 | ||||
-rw-r--r-- | drivers/net/wireless/ath/ath9k/ath9k.h | 9 | ||||
-rw-r--r-- | drivers/net/wireless/ath/ath9k/hw.c | 29 | ||||
-rw-r--r-- | drivers/net/wireless/ath/ath9k/hw.h | 3 | ||||
-rw-r--r-- | drivers/net/wireless/ath/ath9k/main.c | 94 |
5 files changed, 26 insertions, 110 deletions
diff --git a/drivers/net/wireless/ath/ath9k/Kconfig b/drivers/net/wireless/ath/ath9k/Kconfig index 0ed1ac312aa6..2d79610bce12 100644 --- a/drivers/net/wireless/ath/ath9k/Kconfig +++ b/drivers/net/wireless/ath/ath9k/Kconfig | |||
@@ -1,7 +1,6 @@ | |||
1 | config ATH9K | 1 | config ATH9K |
2 | tristate "Atheros 802.11n wireless cards support" | 2 | tristate "Atheros 802.11n wireless cards support" |
3 | depends on PCI && MAC80211 && WLAN_80211 | 3 | depends on PCI && MAC80211 && WLAN_80211 |
4 | depends on RFKILL || RFKILL=n | ||
5 | select ATH_COMMON | 4 | select ATH_COMMON |
6 | select MAC80211_LEDS | 5 | select MAC80211_LEDS |
7 | select LEDS_CLASS | 6 | select LEDS_CLASS |
diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h b/drivers/net/wireless/ath/ath9k/ath9k.h index 515880aa2116..a6e65ff4bb2d 100644 --- a/drivers/net/wireless/ath/ath9k/ath9k.h +++ b/drivers/net/wireless/ath/ath9k/ath9k.h | |||
@@ -21,7 +21,6 @@ | |||
21 | #include <linux/device.h> | 21 | #include <linux/device.h> |
22 | #include <net/mac80211.h> | 22 | #include <net/mac80211.h> |
23 | #include <linux/leds.h> | 23 | #include <linux/leds.h> |
24 | #include <linux/rfkill.h> | ||
25 | 24 | ||
26 | #include "hw.h" | 25 | #include "hw.h" |
27 | #include "rc.h" | 26 | #include "rc.h" |
@@ -460,12 +459,6 @@ struct ath_led { | |||
460 | bool registered; | 459 | bool registered; |
461 | }; | 460 | }; |
462 | 461 | ||
463 | struct ath_rfkill { | ||
464 | struct rfkill *rfkill; | ||
465 | struct rfkill_ops ops; | ||
466 | char rfkill_name[32]; | ||
467 | }; | ||
468 | |||
469 | /********************/ | 462 | /********************/ |
470 | /* Main driver core */ | 463 | /* Main driver core */ |
471 | /********************/ | 464 | /********************/ |
@@ -505,7 +498,6 @@ struct ath_rfkill { | |||
505 | #define SC_OP_PROTECT_ENABLE BIT(6) | 498 | #define SC_OP_PROTECT_ENABLE BIT(6) |
506 | #define SC_OP_RXFLUSH BIT(7) | 499 | #define SC_OP_RXFLUSH BIT(7) |
507 | #define SC_OP_LED_ASSOCIATED BIT(8) | 500 | #define SC_OP_LED_ASSOCIATED BIT(8) |
508 | #define SC_OP_RFKILL_REGISTERED BIT(9) | ||
509 | #define SC_OP_WAIT_FOR_BEACON BIT(12) | 501 | #define SC_OP_WAIT_FOR_BEACON BIT(12) |
510 | #define SC_OP_LED_ON BIT(13) | 502 | #define SC_OP_LED_ON BIT(13) |
511 | #define SC_OP_SCANNING BIT(14) | 503 | #define SC_OP_SCANNING BIT(14) |
@@ -591,7 +583,6 @@ struct ath_softc { | |||
591 | 583 | ||
592 | int beacon_interval; | 584 | int beacon_interval; |
593 | 585 | ||
594 | struct ath_rfkill rf_kill; | ||
595 | struct ath_ani ani; | 586 | struct ath_ani ani; |
596 | struct ath9k_node_stats nodestats; | 587 | struct ath9k_node_stats nodestats; |
597 | #ifdef CONFIG_ATH9K_DEBUG | 588 | #ifdef CONFIG_ATH9K_DEBUG |
diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c index 1579c9407ed5..34935a8ee59d 100644 --- a/drivers/net/wireless/ath/ath9k/hw.c +++ b/drivers/net/wireless/ath/ath9k/hw.c | |||
@@ -2186,6 +2186,18 @@ static void ath9k_hw_spur_mitigate(struct ath_hw *ah, struct ath9k_channel *chan | |||
2186 | REG_WRITE(ah, AR_PHY_MASK2_P_61_45, tmp_mask); | 2186 | REG_WRITE(ah, AR_PHY_MASK2_P_61_45, tmp_mask); |
2187 | } | 2187 | } |
2188 | 2188 | ||
2189 | static void ath9k_enable_rfkill(struct ath_hw *ah) | ||
2190 | { | ||
2191 | REG_SET_BIT(ah, AR_GPIO_INPUT_EN_VAL, | ||
2192 | AR_GPIO_INPUT_EN_VAL_RFSILENT_BB); | ||
2193 | |||
2194 | REG_CLR_BIT(ah, AR_GPIO_INPUT_MUX2, | ||
2195 | AR_GPIO_INPUT_MUX2_RFSILENT); | ||
2196 | |||
2197 | ath9k_hw_cfg_gpio_input(ah, ah->rfkill_gpio); | ||
2198 | REG_SET_BIT(ah, AR_PHY_TEST, RFSILENT_BB); | ||
2199 | } | ||
2200 | |||
2189 | int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan, | 2201 | int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan, |
2190 | bool bChannelChange) | 2202 | bool bChannelChange) |
2191 | { | 2203 | { |
@@ -2313,10 +2325,9 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan, | |||
2313 | ath9k_hw_init_interrupt_masks(ah, ah->opmode); | 2325 | ath9k_hw_init_interrupt_masks(ah, ah->opmode); |
2314 | ath9k_hw_init_qos(ah); | 2326 | ath9k_hw_init_qos(ah); |
2315 | 2327 | ||
2316 | #if defined(CONFIG_RFKILL) || defined(CONFIG_RFKILL_MODULE) | ||
2317 | if (ah->caps.hw_caps & ATH9K_HW_CAP_RFSILENT) | 2328 | if (ah->caps.hw_caps & ATH9K_HW_CAP_RFSILENT) |
2318 | ath9k_enable_rfkill(ah); | 2329 | ath9k_enable_rfkill(ah); |
2319 | #endif | 2330 | |
2320 | ath9k_hw_init_user_settings(ah); | 2331 | ath9k_hw_init_user_settings(ah); |
2321 | 2332 | ||
2322 | REG_WRITE(ah, AR_STA_ID1, | 2333 | REG_WRITE(ah, AR_STA_ID1, |
@@ -3613,20 +3624,6 @@ void ath9k_hw_set_gpio(struct ath_hw *ah, u32 gpio, u32 val) | |||
3613 | AR_GPIO_BIT(gpio)); | 3624 | AR_GPIO_BIT(gpio)); |
3614 | } | 3625 | } |
3615 | 3626 | ||
3616 | #if defined(CONFIG_RFKILL) || defined(CONFIG_RFKILL_MODULE) | ||
3617 | void ath9k_enable_rfkill(struct ath_hw *ah) | ||
3618 | { | ||
3619 | REG_SET_BIT(ah, AR_GPIO_INPUT_EN_VAL, | ||
3620 | AR_GPIO_INPUT_EN_VAL_RFSILENT_BB); | ||
3621 | |||
3622 | REG_CLR_BIT(ah, AR_GPIO_INPUT_MUX2, | ||
3623 | AR_GPIO_INPUT_MUX2_RFSILENT); | ||
3624 | |||
3625 | ath9k_hw_cfg_gpio_input(ah, ah->rfkill_gpio); | ||
3626 | REG_SET_BIT(ah, AR_PHY_TEST, RFSILENT_BB); | ||
3627 | } | ||
3628 | #endif | ||
3629 | |||
3630 | u32 ath9k_hw_getdefantenna(struct ath_hw *ah) | 3627 | u32 ath9k_hw_getdefantenna(struct ath_hw *ah) |
3631 | { | 3628 | { |
3632 | return REG_READ(ah, AR_DEF_ANTENNA) & 0x7; | 3629 | return REG_READ(ah, AR_DEF_ANTENNA) & 0x7; |
diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h index dd8508ef6e05..9d0b31ad4603 100644 --- a/drivers/net/wireless/ath/ath9k/hw.h +++ b/drivers/net/wireless/ath/ath9k/hw.h | |||
@@ -565,9 +565,6 @@ u32 ath9k_hw_gpio_get(struct ath_hw *ah, u32 gpio); | |||
565 | void ath9k_hw_cfg_output(struct ath_hw *ah, u32 gpio, | 565 | void ath9k_hw_cfg_output(struct ath_hw *ah, u32 gpio, |
566 | u32 ah_signal_type); | 566 | u32 ah_signal_type); |
567 | void ath9k_hw_set_gpio(struct ath_hw *ah, u32 gpio, u32 val); | 567 | void ath9k_hw_set_gpio(struct ath_hw *ah, u32 gpio, u32 val); |
568 | #if defined(CONFIG_RFKILL) || defined(CONFIG_RFKILL_MODULE) | ||
569 | void ath9k_enable_rfkill(struct ath_hw *ah); | ||
570 | #endif | ||
571 | u32 ath9k_hw_getdefantenna(struct ath_hw *ah); | 568 | u32 ath9k_hw_getdefantenna(struct ath_hw *ah); |
572 | void ath9k_hw_setantenna(struct ath_hw *ah, u32 antenna); | 569 | void ath9k_hw_setantenna(struct ath_hw *ah, u32 antenna); |
573 | bool ath9k_hw_setantennaswitch(struct ath_hw *ah, | 570 | bool ath9k_hw_setantennaswitch(struct ath_hw *ah, |
diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c index 6516a426f6ce..91c00486b2ac 100644 --- a/drivers/net/wireless/ath/ath9k/main.c +++ b/drivers/net/wireless/ath/ath9k/main.c | |||
@@ -1197,8 +1197,6 @@ void ath_radio_disable(struct ath_softc *sc) | |||
1197 | ath9k_ps_restore(sc); | 1197 | ath9k_ps_restore(sc); |
1198 | } | 1198 | } |
1199 | 1199 | ||
1200 | #if defined(CONFIG_RFKILL) || defined(CONFIG_RFKILL_MODULE) | ||
1201 | |||
1202 | /*******************/ | 1200 | /*******************/ |
1203 | /* Rfkill */ | 1201 | /* Rfkill */ |
1204 | /*******************/ | 1202 | /*******************/ |
@@ -1211,81 +1209,27 @@ static bool ath_is_rfkill_set(struct ath_softc *sc) | |||
1211 | ah->rfkill_polarity; | 1209 | ah->rfkill_polarity; |
1212 | } | 1210 | } |
1213 | 1211 | ||
1214 | /* s/w rfkill handlers */ | 1212 | static void ath9k_rfkill_poll_state(struct ieee80211_hw *hw) |
1215 | static int ath_rfkill_set_block(void *data, bool blocked) | ||
1216 | { | ||
1217 | struct ath_softc *sc = data; | ||
1218 | |||
1219 | if (blocked) | ||
1220 | ath_radio_disable(sc); | ||
1221 | else | ||
1222 | ath_radio_enable(sc); | ||
1223 | |||
1224 | return 0; | ||
1225 | } | ||
1226 | |||
1227 | static void ath_rfkill_poll_state(struct rfkill *rfkill, void *data) | ||
1228 | { | 1213 | { |
1229 | struct ath_softc *sc = data; | 1214 | struct ath_wiphy *aphy = hw->priv; |
1215 | struct ath_softc *sc = aphy->sc; | ||
1230 | bool blocked = !!ath_is_rfkill_set(sc); | 1216 | bool blocked = !!ath_is_rfkill_set(sc); |
1231 | 1217 | ||
1232 | if (rfkill_set_hw_state(rfkill, blocked)) | 1218 | wiphy_rfkill_set_hw_state(hw->wiphy, blocked); |
1219 | |||
1220 | if (blocked) | ||
1233 | ath_radio_disable(sc); | 1221 | ath_radio_disable(sc); |
1234 | else | 1222 | else |
1235 | ath_radio_enable(sc); | 1223 | ath_radio_enable(sc); |
1236 | } | 1224 | } |
1237 | 1225 | ||
1238 | /* Init s/w rfkill */ | 1226 | static void ath_start_rfkill_poll(struct ath_softc *sc) |
1239 | static int ath_init_sw_rfkill(struct ath_softc *sc) | ||
1240 | { | 1227 | { |
1241 | sc->rf_kill.ops.set_block = ath_rfkill_set_block; | 1228 | struct ath_hw *ah = sc->sc_ah; |
1242 | if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_RFSILENT) | ||
1243 | sc->rf_kill.ops.poll = ath_rfkill_poll_state; | ||
1244 | |||
1245 | snprintf(sc->rf_kill.rfkill_name, sizeof(sc->rf_kill.rfkill_name), | ||
1246 | "ath9k-%s::rfkill", wiphy_name(sc->hw->wiphy)); | ||
1247 | |||
1248 | sc->rf_kill.rfkill = rfkill_alloc(sc->rf_kill.rfkill_name, | ||
1249 | wiphy_dev(sc->hw->wiphy), | ||
1250 | RFKILL_TYPE_WLAN, | ||
1251 | &sc->rf_kill.ops, sc); | ||
1252 | if (!sc->rf_kill.rfkill) { | ||
1253 | DPRINTF(sc, ATH_DBG_FATAL, "Failed to allocate rfkill\n"); | ||
1254 | return -ENOMEM; | ||
1255 | } | ||
1256 | |||
1257 | return 0; | ||
1258 | } | ||
1259 | |||
1260 | /* Deinitialize rfkill */ | ||
1261 | static void ath_deinit_rfkill(struct ath_softc *sc) | ||
1262 | { | ||
1263 | if (sc->sc_flags & SC_OP_RFKILL_REGISTERED) { | ||
1264 | rfkill_unregister(sc->rf_kill.rfkill); | ||
1265 | rfkill_destroy(sc->rf_kill.rfkill); | ||
1266 | sc->sc_flags &= ~SC_OP_RFKILL_REGISTERED; | ||
1267 | } | ||
1268 | } | ||
1269 | |||
1270 | static int ath_start_rfkill_poll(struct ath_softc *sc) | ||
1271 | { | ||
1272 | if (!(sc->sc_flags & SC_OP_RFKILL_REGISTERED)) { | ||
1273 | if (rfkill_register(sc->rf_kill.rfkill)) { | ||
1274 | DPRINTF(sc, ATH_DBG_FATAL, | ||
1275 | "Unable to register rfkill\n"); | ||
1276 | rfkill_destroy(sc->rf_kill.rfkill); | ||
1277 | |||
1278 | /* Deinitialize the device */ | ||
1279 | ath_cleanup(sc); | ||
1280 | return -EIO; | ||
1281 | } else { | ||
1282 | sc->sc_flags |= SC_OP_RFKILL_REGISTERED; | ||
1283 | } | ||
1284 | } | ||
1285 | 1229 | ||
1286 | return 0; | 1230 | if (ah->caps.hw_caps & ATH9K_HW_CAP_RFSILENT) |
1231 | wiphy_rfkill_start_polling(sc->hw->wiphy); | ||
1287 | } | 1232 | } |
1288 | #endif /* CONFIG_RFKILL */ | ||
1289 | 1233 | ||
1290 | void ath_cleanup(struct ath_softc *sc) | 1234 | void ath_cleanup(struct ath_softc *sc) |
1291 | { | 1235 | { |
@@ -1305,9 +1249,6 @@ void ath_detach(struct ath_softc *sc) | |||
1305 | 1249 | ||
1306 | DPRINTF(sc, ATH_DBG_CONFIG, "Detach ATH hw\n"); | 1250 | DPRINTF(sc, ATH_DBG_CONFIG, "Detach ATH hw\n"); |
1307 | 1251 | ||
1308 | #if defined(CONFIG_RFKILL) || defined(CONFIG_RFKILL_MODULE) | ||
1309 | ath_deinit_rfkill(sc); | ||
1310 | #endif | ||
1311 | ath_deinit_leds(sc); | 1252 | ath_deinit_leds(sc); |
1312 | cancel_work_sync(&sc->chan_work); | 1253 | cancel_work_sync(&sc->chan_work); |
1313 | cancel_delayed_work_sync(&sc->wiphy_work); | 1254 | cancel_delayed_work_sync(&sc->wiphy_work); |
@@ -1645,13 +1586,6 @@ int ath_attach(u16 devid, struct ath_softc *sc) | |||
1645 | if (error != 0) | 1586 | if (error != 0) |
1646 | goto error_attach; | 1587 | goto error_attach; |
1647 | 1588 | ||
1648 | #if defined(CONFIG_RFKILL) || defined(CONFIG_RFKILL_MODULE) | ||
1649 | /* Initialize s/w rfkill */ | ||
1650 | error = ath_init_sw_rfkill(sc); | ||
1651 | if (error) | ||
1652 | goto error_attach; | ||
1653 | #endif | ||
1654 | |||
1655 | INIT_WORK(&sc->chan_work, ath9k_wiphy_chan_work); | 1589 | INIT_WORK(&sc->chan_work, ath9k_wiphy_chan_work); |
1656 | INIT_DELAYED_WORK(&sc->wiphy_work, ath9k_wiphy_work); | 1590 | INIT_DELAYED_WORK(&sc->wiphy_work, ath9k_wiphy_work); |
1657 | sc->wiphy_scheduler_int = msecs_to_jiffies(500); | 1591 | sc->wiphy_scheduler_int = msecs_to_jiffies(500); |
@@ -1667,6 +1601,7 @@ int ath_attach(u16 devid, struct ath_softc *sc) | |||
1667 | /* Initialize LED control */ | 1601 | /* Initialize LED control */ |
1668 | ath_init_leds(sc); | 1602 | ath_init_leds(sc); |
1669 | 1603 | ||
1604 | ath_start_rfkill_poll(sc); | ||
1670 | 1605 | ||
1671 | return 0; | 1606 | return 0; |
1672 | 1607 | ||
@@ -2035,10 +1970,6 @@ static int ath9k_start(struct ieee80211_hw *hw) | |||
2035 | 1970 | ||
2036 | ieee80211_wake_queues(hw); | 1971 | ieee80211_wake_queues(hw); |
2037 | 1972 | ||
2038 | #if defined(CONFIG_RFKILL) || defined(CONFIG_RFKILL_MODULE) | ||
2039 | r = ath_start_rfkill_poll(sc); | ||
2040 | #endif | ||
2041 | |||
2042 | mutex_unlock: | 1973 | mutex_unlock: |
2043 | mutex_unlock(&sc->mutex); | 1974 | mutex_unlock(&sc->mutex); |
2044 | 1975 | ||
@@ -2176,7 +2107,7 @@ static void ath9k_stop(struct ieee80211_hw *hw) | |||
2176 | } else | 2107 | } else |
2177 | sc->rx.rxlink = NULL; | 2108 | sc->rx.rxlink = NULL; |
2178 | 2109 | ||
2179 | rfkill_pause_polling(sc->rf_kill.rfkill); | 2110 | wiphy_rfkill_stop_polling(sc->hw->wiphy); |
2180 | 2111 | ||
2181 | /* disable HAL and put h/w to sleep */ | 2112 | /* disable HAL and put h/w to sleep */ |
2182 | ath9k_hw_disable(sc->sc_ah); | 2113 | ath9k_hw_disable(sc->sc_ah); |
@@ -2782,6 +2713,7 @@ struct ieee80211_ops ath9k_ops = { | |||
2782 | .ampdu_action = ath9k_ampdu_action, | 2713 | .ampdu_action = ath9k_ampdu_action, |
2783 | .sw_scan_start = ath9k_sw_scan_start, | 2714 | .sw_scan_start = ath9k_sw_scan_start, |
2784 | .sw_scan_complete = ath9k_sw_scan_complete, | 2715 | .sw_scan_complete = ath9k_sw_scan_complete, |
2716 | .rfkill_poll = ath9k_rfkill_poll_state, | ||
2785 | }; | 2717 | }; |
2786 | 2718 | ||
2787 | static struct { | 2719 | static struct { |