aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/ath/ath9k/hw.c
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/ath9k/hw.c
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/ath9k/hw.c')
-rw-r--r--drivers/net/wireless/ath/ath9k/hw.c24
1 files changed, 8 insertions, 16 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,