aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/ath
diff options
context:
space:
mode:
authorLuis R. Rodriguez <lrodriguez@atheros.com>2009-08-03 15:24:54 -0400
committerJohn W. Linville <linville@tuxdriver.com>2009-08-04 16:44:33 -0400
commit95fafca26dc317b7ea0667c57576b0b5389f5bef (patch)
treeaedd7cec1275411a39a90370a2a10ab98f5446ef /drivers/net/wireless/ath
parent3ce1b1a949ae849fb73556867e60977a65ca3141 (diff)
ath9k: call ath9k_hw_detach() once upon hw init failure
If hw initialization fails (ath9k_hw_init()) on ath_init_softc() we bail out and call ath9k_hw_detach(). The call ath9k_hw_detach() is conditional though as ath9k_hw_init() could itself have called ath9k_hw_detach(). Just describing this is itself a brain twister. Avoid this nonsense by removing ath9k_hw_detach() from ath9k_hw_init(). Upon hw initialization failure we expect the callers to take care of the cleanup. Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/ath')
-rw-r--r--drivers/net/wireless/ath/ath9k/hw.c24
-rw-r--r--drivers/net/wireless/ath/ath9k/main.c3
2 files changed, 9 insertions, 18 deletions
diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c
index 633fe8b6f5f7..08715299f75d 100644
--- a/drivers/net/wireless/ath/ath9k/hw.c
+++ b/drivers/net/wireless/ath/ath9k/hw.c
@@ -898,26 +898,22 @@ static void ath9k_hw_init_11a_eeprom_fix(struct ath_hw *ah)
898 898
899int ath9k_hw_init(struct ath_hw *ah) 899int ath9k_hw_init(struct ath_hw *ah)
900{ 900{
901 int r; 901 int r = 0;
902 902
903 if (!ath9k_hw_devid_supported(ah->hw_version.devid)) { 903 if (!ath9k_hw_devid_supported(ah->hw_version.devid))
904 r = -EOPNOTSUPP; 904 return -EOPNOTSUPP;
905 goto bad;
906 }
907 905
908 ath9k_hw_init_defaults(ah); 906 ath9k_hw_init_defaults(ah);
909 ath9k_hw_init_config(ah); 907 ath9k_hw_init_config(ah);
910 908
911 if (!ath9k_hw_set_reset_reg(ah, ATH9K_RESET_POWER_ON)) { 909 if (!ath9k_hw_set_reset_reg(ah, ATH9K_RESET_POWER_ON)) {
912 DPRINTF(ah->ah_sc, ATH_DBG_FATAL, "Couldn't reset chip\n"); 910 DPRINTF(ah->ah_sc, ATH_DBG_FATAL, "Couldn't reset chip\n");
913 r = -EIO; 911 return -EIO;
914 goto bad;
915 } 912 }
916 913
917 if (!ath9k_hw_setpower(ah, ATH9K_PM_AWAKE)) { 914 if (!ath9k_hw_setpower(ah, ATH9K_PM_AWAKE)) {
918 DPRINTF(ah->ah_sc, ATH_DBG_FATAL, "Couldn't wakeup chip\n"); 915 DPRINTF(ah->ah_sc, ATH_DBG_FATAL, "Couldn't wakeup chip\n");
919 r = -EIO; 916 return -EIO;
920 goto bad;
921 } 917 }
922 918
923 if (ah->config.serialize_regmode == SER_REG_MODE_AUTO) { 919 if (ah->config.serialize_regmode == SER_REG_MODE_AUTO) {
@@ -939,8 +935,7 @@ int ath9k_hw_init(struct ath_hw *ah)
939 "Mac Chip Rev 0x%02x.%x is not supported by " 935 "Mac Chip Rev 0x%02x.%x is not supported by "
940 "this driver\n", ah->hw_version.macVersion, 936 "this driver\n", ah->hw_version.macVersion,
941 ah->hw_version.macRev); 937 ah->hw_version.macRev);
942 r = -EOPNOTSUPP; 938 return -EOPNOTSUPP;
943 goto bad;
944 } 939 }
945 940
946 if (AR_SREV_9100(ah)) { 941 if (AR_SREV_9100(ah)) {
@@ -965,7 +960,7 @@ int ath9k_hw_init(struct ath_hw *ah)
965 960
966 r = ath9k_hw_post_init(ah); 961 r = ath9k_hw_post_init(ah);
967 if (r) 962 if (r)
968 goto bad; 963 return r;
969 964
970 ath9k_hw_init_mode_gain_regs(ah); 965 ath9k_hw_init_mode_gain_regs(ah);
971 ath9k_hw_fill_cap_info(ah); 966 ath9k_hw_fill_cap_info(ah);
@@ -975,7 +970,7 @@ int ath9k_hw_init(struct ath_hw *ah)
975 if (r) { 970 if (r) {
976 DPRINTF(ah->ah_sc, ATH_DBG_FATAL, 971 DPRINTF(ah->ah_sc, ATH_DBG_FATAL,
977 "Failed to initialize MAC address\n"); 972 "Failed to initialize MAC address\n");
978 goto bad; 973 return r;
979 } 974 }
980 975
981 if (AR_SREV_9285(ah)) 976 if (AR_SREV_9285(ah))
@@ -986,9 +981,6 @@ int ath9k_hw_init(struct ath_hw *ah)
986 ath9k_init_nfcal_hist_buffer(ah); 981 ath9k_init_nfcal_hist_buffer(ah);
987 982
988 return 0; 983 return 0;
989bad:
990 ath9k_hw_detach(ah);
991 return r;
992} 984}
993 985
994static void ath9k_hw_init_bb(struct ath_hw *ah, 986static void ath9k_hw_init_bb(struct ath_hw *ah,
diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
index d3d2cb667dc6..a5475b7a59de 100644
--- a/drivers/net/wireless/ath/ath9k/main.c
+++ b/drivers/net/wireless/ath/ath9k/main.c
@@ -1520,8 +1520,7 @@ bad2:
1520 if (ATH_TXQ_SETUP(sc, i)) 1520 if (ATH_TXQ_SETUP(sc, i))
1521 ath_tx_cleanupq(sc, &sc->tx.txq[i]); 1521 ath_tx_cleanupq(sc, &sc->tx.txq[i]);
1522bad: 1522bad:
1523 if (ah) 1523 ath9k_hw_detach(ah);
1524 ath9k_hw_detach(ah);
1525 sc->sc_ah = NULL; 1524 sc->sc_ah = NULL;
1526bad_no_ah: 1525bad_no_ah:
1527 ath9k_exit_debug(sc); 1526 ath9k_exit_debug(sc);