aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/ath9k/main.c
diff options
context:
space:
mode:
authorLuis R. Rodriguez <lrodriguez@atheros.com>2008-12-23 18:58:40 -0500
committerJohn W. Linville <linville@tuxdriver.com>2009-01-29 15:59:29 -0500
commitae8d2858c54f52dc4df513a818cc4e1257fd9143 (patch)
treee58f270784474a5d244b8d296b8e10bb6c912fa2 /drivers/net/wireless/ath9k/main.c
parentce111badf5ac387e9eefe1f2bba751f595994cb2 (diff)
ath9k: consolidate arguments on hw reset
HW reset calls pass the same variables or structs which we can obtain easily from ah. Although this also applies during channel changes as we will keep around the ath9k_channel passed as an argument for now. We now also now propagate the hw reset errors down. Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/ath9k/main.c')
-rw-r--r--drivers/net/wireless/ath9k/main.c110
1 files changed, 42 insertions, 68 deletions
diff --git a/drivers/net/wireless/ath9k/main.c b/drivers/net/wireless/ath9k/main.c
index 0087a907aac4..c65b27bd9f5f 100644
--- a/drivers/net/wireless/ath9k/main.c
+++ b/drivers/net/wireless/ath9k/main.c
@@ -260,6 +260,8 @@ static int ath_set_channel(struct ath_softc *sc, struct ath9k_channel *hchan)
260 struct ath_hal *ah = sc->sc_ah; 260 struct ath_hal *ah = sc->sc_ah;
261 bool fastcc = true, stopped; 261 bool fastcc = true, stopped;
262 struct ieee80211_hw *hw = sc->hw; 262 struct ieee80211_hw *hw = sc->hw;
263 struct ieee80211_channel *channel = hw->conf.channel;
264 int r;
263 265
264 if (sc->sc_flags & SC_OP_INVALID) 266 if (sc->sc_flags & SC_OP_INVALID)
265 return -EIO; 267 return -EIO;
@@ -268,7 +270,6 @@ static int ath_set_channel(struct ath_softc *sc, struct ath9k_channel *hchan)
268 hchan->channelFlags != sc->sc_ah->ah_curchan->channelFlags || 270 hchan->channelFlags != sc->sc_ah->ah_curchan->channelFlags ||
269 (sc->sc_flags & SC_OP_CHAINMASK_UPDATE) || 271 (sc->sc_flags & SC_OP_CHAINMASK_UPDATE) ||
270 (sc->sc_flags & SC_OP_FULL_RESET)) { 272 (sc->sc_flags & SC_OP_FULL_RESET)) {
271 int status;
272 /* 273 /*
273 * This is only performed if the channel settings have 274 * This is only performed if the channel settings have
274 * actually changed. 275 * actually changed.
@@ -290,22 +291,20 @@ static int ath_set_channel(struct ath_softc *sc, struct ath9k_channel *hchan)
290 fastcc = false; 291 fastcc = false;
291 292
292 DPRINTF(sc, ATH_DBG_CONFIG, 293 DPRINTF(sc, ATH_DBG_CONFIG,
293 "(%u MHz) -> (%u MHz), cflags:%x, chanwidth: %d\n", 294 "(%u MHz) -> (%u MHz), chanwidth: %d\n",
294 sc->sc_ah->ah_curchan->channel, 295 sc->sc_ah->ah_curchan->channel,
295 hchan->channel, hchan->channelFlags, sc->tx_chan_width); 296 channel->center_freq, sc->tx_chan_width);
296 297
297 spin_lock_bh(&sc->sc_resetlock); 298 spin_lock_bh(&sc->sc_resetlock);
298 if (!ath9k_hw_reset(ah, hchan, sc->tx_chan_width, 299
299 sc->sc_tx_chainmask, sc->sc_rx_chainmask, 300 r = ath9k_hw_reset(ah, hchan, fastcc);
300 sc->sc_ht_extprotspacing, fastcc, &status)) { 301 if (r) {
301 DPRINTF(sc, ATH_DBG_FATAL, 302 DPRINTF(sc, ATH_DBG_FATAL,
302 "Unable to reset channel %u (%uMhz) " 303 "Unable to reset channel (%u Mhz) "
303 "flags 0x%x hal status %u\n", 304 "reset status %u\n",
304 ath9k_hw_mhz2ieee(ah, hchan->channel, 305 channel->center_freq, r);
305 hchan->channelFlags),
306 hchan->channel, hchan->channelFlags, status);
307 spin_unlock_bh(&sc->sc_resetlock); 306 spin_unlock_bh(&sc->sc_resetlock);
308 return -EIO; 307 return r;
309 } 308 }
310 spin_unlock_bh(&sc->sc_resetlock); 309 spin_unlock_bh(&sc->sc_resetlock);
311 310
@@ -1069,23 +1068,18 @@ fail:
1069static void ath_radio_enable(struct ath_softc *sc) 1068static void ath_radio_enable(struct ath_softc *sc)
1070{ 1069{
1071 struct ath_hal *ah = sc->sc_ah; 1070 struct ath_hal *ah = sc->sc_ah;
1072 int status; 1071 struct ieee80211_channel *channel = sc->hw->conf.channel;
1072 int r;
1073 1073
1074 spin_lock_bh(&sc->sc_resetlock); 1074 spin_lock_bh(&sc->sc_resetlock);
1075 if (!ath9k_hw_reset(ah, ah->ah_curchan, 1075
1076 sc->tx_chan_width, 1076 r = ath9k_hw_reset(ah, ah->ah_curchan, false);
1077 sc->sc_tx_chainmask, 1077
1078 sc->sc_rx_chainmask, 1078 if (r) {
1079 sc->sc_ht_extprotspacing,
1080 false, &status)) {
1081 DPRINTF(sc, ATH_DBG_FATAL, 1079 DPRINTF(sc, ATH_DBG_FATAL,
1082 "Unable to reset channel %u (%uMhz) " 1080 "Unable to reset channel %u (%uMhz) ",
1083 "flags 0x%x hal status %u\n", 1081 "reset status %u\n",
1084 ath9k_hw_mhz2ieee(ah, 1082 channel->center_freq, r);
1085 ah->ah_curchan->channel,
1086 ah->ah_curchan->channelFlags),
1087 ah->ah_curchan->channel,
1088 ah->ah_curchan->channelFlags, status);
1089 } 1083 }
1090 spin_unlock_bh(&sc->sc_resetlock); 1084 spin_unlock_bh(&sc->sc_resetlock);
1091 1085
@@ -1113,8 +1107,8 @@ static void ath_radio_enable(struct ath_softc *sc)
1113static void ath_radio_disable(struct ath_softc *sc) 1107static void ath_radio_disable(struct ath_softc *sc)
1114{ 1108{
1115 struct ath_hal *ah = sc->sc_ah; 1109 struct ath_hal *ah = sc->sc_ah;
1116 int status; 1110 struct ieee80211_channel *channel = sc->hw->conf.channel;
1117 1111 int r;
1118 1112
1119 ieee80211_stop_queues(sc->hw); 1113 ieee80211_stop_queues(sc->hw);
1120 1114
@@ -1130,20 +1124,12 @@ static void ath_radio_disable(struct ath_softc *sc)
1130 ath_flushrecv(sc); /* flush recv queue */ 1124 ath_flushrecv(sc); /* flush recv queue */
1131 1125
1132 spin_lock_bh(&sc->sc_resetlock); 1126 spin_lock_bh(&sc->sc_resetlock);
1133 if (!ath9k_hw_reset(ah, ah->ah_curchan, 1127 r = ath9k_hw_reset(ah, ah->ah_curchan, false);
1134 sc->tx_chan_width, 1128 if (r) {
1135 sc->sc_tx_chainmask,
1136 sc->sc_rx_chainmask,
1137 sc->sc_ht_extprotspacing,
1138 false, &status)) {
1139 DPRINTF(sc, ATH_DBG_FATAL, 1129 DPRINTF(sc, ATH_DBG_FATAL,
1140 "Unable to reset channel %u (%uMhz) " 1130 "Unable to reset channel %u (%uMhz) "
1141 "flags 0x%x hal status %u\n", 1131 "reset status %u\n",
1142 ath9k_hw_mhz2ieee(ah, 1132 channel->center_freq, r);
1143 ah->ah_curchan->channel,
1144 ah->ah_curchan->channelFlags),
1145 ah->ah_curchan->channel,
1146 ah->ah_curchan->channelFlags, status);
1147 } 1133 }
1148 spin_unlock_bh(&sc->sc_resetlock); 1134 spin_unlock_bh(&sc->sc_resetlock);
1149 1135
@@ -1622,8 +1608,7 @@ int ath_reset(struct ath_softc *sc, bool retry_tx)
1622{ 1608{
1623 struct ath_hal *ah = sc->sc_ah; 1609 struct ath_hal *ah = sc->sc_ah;
1624 struct ieee80211_hw *hw = sc->hw; 1610 struct ieee80211_hw *hw = sc->hw;
1625 int status; 1611 int r;
1626 int error = 0;
1627 1612
1628 ath9k_hw_set_interrupts(ah, 0); 1613 ath9k_hw_set_interrupts(ah, 0);
1629 ath_draintxq(sc, retry_tx); 1614 ath_draintxq(sc, retry_tx);
@@ -1631,14 +1616,10 @@ int ath_reset(struct ath_softc *sc, bool retry_tx)
1631 ath_flushrecv(sc); 1616 ath_flushrecv(sc);
1632 1617
1633 spin_lock_bh(&sc->sc_resetlock); 1618 spin_lock_bh(&sc->sc_resetlock);
1634 if (!ath9k_hw_reset(ah, sc->sc_ah->ah_curchan, 1619 r = ath9k_hw_reset(ah, sc->sc_ah->ah_curchan, false);
1635 sc->tx_chan_width, 1620 if (r)
1636 sc->sc_tx_chainmask, sc->sc_rx_chainmask,
1637 sc->sc_ht_extprotspacing, false, &status)) {
1638 DPRINTF(sc, ATH_DBG_FATAL, 1621 DPRINTF(sc, ATH_DBG_FATAL,
1639 "Unable to reset hardware; hal status %u\n", status); 1622 "Unable to reset hardware; reset status %u\n", r);
1640 error = -EIO;
1641 }
1642 spin_unlock_bh(&sc->sc_resetlock); 1623 spin_unlock_bh(&sc->sc_resetlock);
1643 1624
1644 if (ath_startrecv(sc) != 0) 1625 if (ath_startrecv(sc) != 0)
@@ -1669,7 +1650,7 @@ int ath_reset(struct ath_softc *sc, bool retry_tx)
1669 } 1650 }
1670 } 1651 }
1671 1652
1672 return error; 1653 return r;
1673} 1654}
1674 1655
1675/* 1656/*
@@ -1852,7 +1833,7 @@ static int ath9k_start(struct ieee80211_hw *hw)
1852 struct ath_softc *sc = hw->priv; 1833 struct ath_softc *sc = hw->priv;
1853 struct ieee80211_channel *curchan = hw->conf.channel; 1834 struct ieee80211_channel *curchan = hw->conf.channel;
1854 struct ath9k_channel *init_channel; 1835 struct ath9k_channel *init_channel;
1855 int error = 0, pos, status; 1836 int r, pos;
1856 1837
1857 DPRINTF(sc, ATH_DBG_CONFIG, "Starting driver with " 1838 DPRINTF(sc, ATH_DBG_CONFIG, "Starting driver with "
1858 "initial channel: %d MHz\n", curchan->center_freq); 1839 "initial channel: %d MHz\n", curchan->center_freq);
@@ -1862,8 +1843,7 @@ static int ath9k_start(struct ieee80211_hw *hw)
1862 pos = ath_get_channel(sc, curchan); 1843 pos = ath_get_channel(sc, curchan);
1863 if (pos == -1) { 1844 if (pos == -1) {
1864 DPRINTF(sc, ATH_DBG_FATAL, "Invalid channel: %d\n", curchan->center_freq); 1845 DPRINTF(sc, ATH_DBG_FATAL, "Invalid channel: %d\n", curchan->center_freq);
1865 error = -EINVAL; 1846 return -EINVAL;
1866 goto error;
1867 } 1847 }
1868 1848
1869 sc->tx_chan_width = ATH9K_HT_MACMODE_20; 1849 sc->tx_chan_width = ATH9K_HT_MACMODE_20;
@@ -1882,17 +1862,14 @@ static int ath9k_start(struct ieee80211_hw *hw)
1882 * and then setup of the interrupt mask. 1862 * and then setup of the interrupt mask.
1883 */ 1863 */
1884 spin_lock_bh(&sc->sc_resetlock); 1864 spin_lock_bh(&sc->sc_resetlock);
1885 if (!ath9k_hw_reset(sc->sc_ah, init_channel, 1865 r = ath9k_hw_reset(sc->sc_ah, init_channel, false);
1886 sc->tx_chan_width, 1866 if (r) {
1887 sc->sc_tx_chainmask, sc->sc_rx_chainmask,
1888 sc->sc_ht_extprotspacing, false, &status)) {
1889 DPRINTF(sc, ATH_DBG_FATAL, 1867 DPRINTF(sc, ATH_DBG_FATAL,
1890 "Unable to reset hardware; hal status %u " 1868 "Unable to reset hardware; reset status %u "
1891 "(freq %u flags 0x%x)\n", status, 1869 "(freq %u MHz)\n", r,
1892 init_channel->channel, init_channel->channelFlags); 1870 curchan->center_freq);
1893 error = -EIO;
1894 spin_unlock_bh(&sc->sc_resetlock); 1871 spin_unlock_bh(&sc->sc_resetlock);
1895 goto error; 1872 return r;
1896 } 1873 }
1897 spin_unlock_bh(&sc->sc_resetlock); 1874 spin_unlock_bh(&sc->sc_resetlock);
1898 1875
@@ -1912,8 +1889,7 @@ static int ath9k_start(struct ieee80211_hw *hw)
1912 if (ath_startrecv(sc) != 0) { 1889 if (ath_startrecv(sc) != 0) {
1913 DPRINTF(sc, ATH_DBG_FATAL, 1890 DPRINTF(sc, ATH_DBG_FATAL,
1914 "Unable to start recv logic\n"); 1891 "Unable to start recv logic\n");
1915 error = -EIO; 1892 return -EIO;
1916 goto error;
1917 } 1893 }
1918 1894
1919 /* Setup our intr mask. */ 1895 /* Setup our intr mask. */
@@ -1957,11 +1933,9 @@ static int ath9k_start(struct ieee80211_hw *hw)
1957 ieee80211_wake_queues(sc->hw); 1933 ieee80211_wake_queues(sc->hw);
1958 1934
1959#if defined(CONFIG_RFKILL) || defined(CONFIG_RFKILL_MODULE) 1935#if defined(CONFIG_RFKILL) || defined(CONFIG_RFKILL_MODULE)
1960 error = ath_start_rfkill_poll(sc); 1936 r = ath_start_rfkill_poll(sc);
1961#endif 1937#endif
1962 1938 return r;
1963error:
1964 return error;
1965} 1939}
1966 1940
1967static int ath9k_tx(struct ieee80211_hw *hw, 1941static int ath9k_tx(struct ieee80211_hw *hw,