aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLuis R. Rodriguez <lrodriguez@atheros.com>2009-10-06 21:19:07 -0400
committerJohn W. Linville <linville@tuxdriver.com>2009-10-07 16:39:51 -0400
commit211f5859af951788a3fe4752142a5e9047afa5d8 (patch)
tree2d1048397c2eb66950a688ac43cebccc4f818816 /drivers
parentfaa27fae7da900b6d977124410caa3d014676478 (diff)
ath9k: initialize hw prior to debugfs
debugfs uses the hardware for several debugfs files as such the hardware must be initialized and available prior to its usage. The same applies to when we free the hw structs -- free debufs file entries prior to free'ing the hardware. Reported-by: Vasanthakumar Thiagarajan <vasanth@atheros.com> Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/wireless/ath/ath.h6
-rw-r--r--drivers/net/wireless/ath/ath9k/hw.c11
-rw-r--r--drivers/net/wireless/ath/ath9k/main.c28
3 files changed, 30 insertions, 15 deletions
diff --git a/drivers/net/wireless/ath/ath.h b/drivers/net/wireless/ath/ath.h
index b6cd752df839..5e19a7330d39 100644
--- a/drivers/net/wireless/ath/ath.h
+++ b/drivers/net/wireless/ath/ath.h
@@ -23,6 +23,11 @@
23 23
24static const u8 ath_bcast_mac[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; 24static const u8 ath_bcast_mac[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
25 25
26enum ath_device_state {
27 ATH_HW_UNAVAILABLE,
28 ATH_HW_INITIALIZED,
29};
30
26struct reg_dmn_pair_mapping { 31struct reg_dmn_pair_mapping {
27 u16 regDmnEnum; 32 u16 regDmnEnum;
28 u16 reg_5ghz_ctl; 33 u16 reg_5ghz_ctl;
@@ -59,6 +64,7 @@ struct ath_common {
59 void *priv; 64 void *priv;
60 struct ieee80211_hw *hw; 65 struct ieee80211_hw *hw;
61 int debug_mask; 66 int debug_mask;
67 enum ath_device_state state;
62 68
63 u16 cachelsz; 69 u16 cachelsz;
64 u16 curaid; 70 u16 curaid;
diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c
index 692fd1dd909e..cab17c6c8a37 100644
--- a/drivers/net/wireless/ath/ath9k/hw.c
+++ b/drivers/net/wireless/ath/ath9k/hw.c
@@ -999,6 +999,8 @@ int ath9k_hw_init(struct ath_hw *ah)
999 999
1000 ath9k_init_nfcal_hist_buffer(ah); 1000 ath9k_init_nfcal_hist_buffer(ah);
1001 1001
1002 common->state = ATH_HW_INITIALIZED;
1003
1002 return 0; 1004 return 0;
1003} 1005}
1004 1006
@@ -1239,11 +1241,18 @@ const char *ath9k_hw_probe(u16 vendorid, u16 devid)
1239 1241
1240void ath9k_hw_detach(struct ath_hw *ah) 1242void ath9k_hw_detach(struct ath_hw *ah)
1241{ 1243{
1244 struct ath_common *common = ath9k_hw_common(ah);
1245
1246 if (common->state <= ATH_HW_INITIALIZED)
1247 goto free_hw;
1248
1242 if (!AR_SREV_9100(ah)) 1249 if (!AR_SREV_9100(ah))
1243 ath9k_hw_ani_disable(ah); 1250 ath9k_hw_ani_disable(ah);
1244 1251
1245 ath9k_hw_rf_free(ah);
1246 ath9k_hw_setpower(ah, ATH9K_PM_FULL_SLEEP); 1252 ath9k_hw_setpower(ah, ATH9K_PM_FULL_SLEEP);
1253
1254free_hw:
1255 ath9k_hw_rf_free(ah);
1247 kfree(ah); 1256 kfree(ah);
1248 ah = NULL; 1257 ah = NULL;
1249} 1258}
diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
index 7f90cb872a69..0fe915acd21e 100644
--- a/drivers/net/wireless/ath/ath9k/main.c
+++ b/drivers/net/wireless/ath/ath9k/main.c
@@ -1365,8 +1365,8 @@ void ath_detach(struct ath_softc *sc)
1365 ah->btcoex_hw.scheme == ATH_BTCOEX_CFG_3WIRE) 1365 ah->btcoex_hw.scheme == ATH_BTCOEX_CFG_3WIRE)
1366 ath_gen_timer_free(ah, sc->btcoex.no_stomp_timer); 1366 ath_gen_timer_free(ah, sc->btcoex.no_stomp_timer);
1367 1367
1368 ath9k_hw_detach(ah);
1369 ath9k_exit_debug(ah); 1368 ath9k_exit_debug(ah);
1369 ath9k_hw_detach(ah);
1370 sc->sc_ah = NULL; 1370 sc->sc_ah = NULL;
1371} 1371}
1372 1372
@@ -1626,10 +1626,8 @@ static int ath_init_softc(u16 devid, struct ath_softc *sc, u16 subsysid,
1626 (unsigned long)sc); 1626 (unsigned long)sc);
1627 1627
1628 ah = kzalloc(sizeof(struct ath_hw), GFP_KERNEL); 1628 ah = kzalloc(sizeof(struct ath_hw), GFP_KERNEL);
1629 if (!ah) { 1629 if (!ah)
1630 r = -ENOMEM; 1630 return -ENOMEM;
1631 goto bad_no_ah;
1632 }
1633 1631
1634 ah->hw_version.devid = devid; 1632 ah->hw_version.devid = devid;
1635 ah->hw_version.subsysid = subsysid; 1633 ah->hw_version.subsysid = subsysid;
@@ -1651,15 +1649,18 @@ static int ath_init_softc(u16 devid, struct ath_softc *sc, u16 subsysid,
1651 /* XXX assert csz is non-zero */ 1649 /* XXX assert csz is non-zero */
1652 common->cachelsz = csz << 2; /* convert to bytes */ 1650 common->cachelsz = csz << 2; /* convert to bytes */
1653 1651
1654 if (ath9k_init_debug(ah) < 0)
1655 dev_err(sc->dev, "Unable to create debugfs files\n");
1656
1657 r = ath9k_hw_init(ah); 1652 r = ath9k_hw_init(ah);
1658 if (r) { 1653 if (r) {
1659 ath_print(common, ATH_DBG_FATAL, 1654 ath_print(common, ATH_DBG_FATAL,
1660 "Unable to initialize hardware; " 1655 "Unable to initialize hardware; "
1661 "initialization status: %d\n", r); 1656 "initialization status: %d\n", r);
1662 goto bad; 1657 goto bad_free_hw;
1658 }
1659
1660 if (ath9k_init_debug(ah) < 0) {
1661 ath_print(common, ATH_DBG_FATAL,
1662 "Unable to create debugfs files\n");
1663 goto bad_free_hw;
1663 } 1664 }
1664 1665
1665 /* Get the hardware key cache size. */ 1666 /* Get the hardware key cache size. */
@@ -1848,12 +1849,11 @@ bad2:
1848 for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) 1849 for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++)
1849 if (ATH_TXQ_SETUP(sc, i)) 1850 if (ATH_TXQ_SETUP(sc, i))
1850 ath_tx_cleanupq(sc, &sc->tx.txq[i]); 1851 ath_tx_cleanupq(sc, &sc->tx.txq[i]);
1851bad: 1852
1853 ath9k_exit_debug(ah);
1854bad_free_hw:
1852 ath9k_hw_detach(ah); 1855 ath9k_hw_detach(ah);
1853bad_no_ah:
1854 ath9k_exit_debug(sc->sc_ah);
1855 sc->sc_ah = NULL; 1856 sc->sc_ah = NULL;
1856
1857 return r; 1857 return r;
1858} 1858}
1859 1859
@@ -1966,8 +1966,8 @@ error_attach:
1966 if (ATH_TXQ_SETUP(sc, i)) 1966 if (ATH_TXQ_SETUP(sc, i))
1967 ath_tx_cleanupq(sc, &sc->tx.txq[i]); 1967 ath_tx_cleanupq(sc, &sc->tx.txq[i]);
1968 1968
1969 ath9k_hw_detach(ah);
1970 ath9k_exit_debug(ah); 1969 ath9k_exit_debug(ah);
1970 ath9k_hw_detach(ah);
1971 sc->sc_ah = NULL; 1971 sc->sc_ah = NULL;
1972 1972
1973 return error; 1973 return error;