From a71559e552f384a5795472cb1f836fc3bde648cc Mon Sep 17 00:00:00 2001 From: proski Date: Tue, 28 Apr 2009 05:33:47 +0000 Subject: [PATCH] Rewrite ar_device() using HAL magic numbers It's more reliable than a table of all device IDs. git-svn-id: http://madwifi-project.org/svn/madwifi/trunk@4014 0192ed92-7a03-0410-a25b-9323aeb14dbd --- ath/if_ath.c | 2 +- ath/if_ath_hal_extensions.c | 53 +++++++++++-------------------------- ath/if_ath_hal_extensions.h | 2 +- ath/if_ath_radar.c | 4 +-- 4 files changed, 20 insertions(+), 41 deletions(-) diff --git a/ath/if_ath.c b/ath/if_ath.c index c94bee3..27e03a3 100644 --- a/ath/if_ath.c +++ b/ath/if_ath.c @@ -11557,7 +11557,7 @@ txcont_configure_radio(struct ieee80211com *ic) ath_set_ack_bitrate(sc, sc->sc_ackrate); netif_wake_queue(dev); /* restart xmit */ - if (ar_device(sc->devid) == 5212 || ar_device(sc->devid) == 5213) { + if (ar_device(sc) == 5212) { /* registers taken from openhal */ #define AR5K_AR5212_TXCFG 0x0030 #define AR5K_AR5212_TXCFG_TXCONT_ENABLE 0x00000080 diff --git a/ath/if_ath_hal_extensions.c b/ath/if_ath_hal_extensions.c index 5c47c14..0e6a458 100644 --- a/ath/if_ath_hal_extensions.c +++ b/ath/if_ath_hal_extensions.c @@ -80,56 +80,35 @@ static struct ath5k_srev_name srev_names[] = { { "xxxxx", AR5K_VERSION_RAD, AR5K_SREV_UNKNOWN }, }; +#define AR5210_MAGIC 0x19980124 +#define AR5211_MAGIC 0x19570405 +#define AR5212_MAGIC 0x19541014 +#define AR5416_MAGIC 0x20065416 int -ar_device(int devid) +ar_device(struct ath_softc *sc) { - switch (devid) { - case AR5210_DEFAULT: - case AR5210_PROD: - case AR5210_AP: + int magic = sc->sc_ah->ah_magic; + + switch (magic) { + case AR5210_MAGIC: return 5210; - case AR5211_DEFAULT: - case AR5311_DEVID: - case AR5211_LEGACY: - case AR5211_FPGA11B: + case AR5211_MAGIC: return 5211; - case AR5212_DEFAULT: - case AR5212_DEVID: - case AR5212_FPGA: - case AR5212_DEVID_IBM: - case AR5212_AR5312_REV2: - case AR5212_AR5312_REV7: - case AR5212_AR2313_REV8: - case AR5212_AR2315_REV6: - case AR5212_AR2315_REV7: - case AR5212_AR2317_REV1: - case AR5212_DEVID_0014: - case AR5212_DEVID_0015: - case AR5212_DEVID_0016: - case AR5212_DEVID_0017: - case AR5212_DEVID_0018: - case AR5212_DEVID_0019: - case AR5212_AR2413: - case AR5212_AR5413: - case AR5212_AR5424: - case AR5212_DEVID_FF19: + case AR5212_MAGIC: return 5212; - case AR5213_SREV_1_0: - case AR5213_SREV_REG: - case AR_SUBVENDOR_ID_NOG: - case AR_SUBVENDOR_ID_NEW_A: - return 5213; + case AR5416_MAGIC: + return 5416; default: - return 0; /* unknown */ + printk(KERN_WARNING "unknown HAL magic 0x%08x\n", magic); + return 0; } } - int ath_set_ack_bitrate(struct ath_softc *sc, int high) { - if (ar_device(sc->devid) == 5212 || ar_device(sc->devid) == 5213) { + if (ar_device(sc) == 5212) { /* set ack to be sent at low bit-rate */ u_int32_t v = AR5K_STA_ID1_BASE_RATE_11B | AR5K_STA_ID1_ACKCTS_6MB; if (high) diff --git a/ath/if_ath_hal_extensions.h b/ath/if_ath_hal_extensions.h index b9ee137..95d109b 100644 --- a/ath/if_ath_hal_extensions.h +++ b/ath/if_ath_hal_extensions.h @@ -268,7 +268,7 @@ enum ath5k_dmasize { int ath_set_ack_bitrate(struct ath_softc *sc, int); -int ar_device(int devid); +int ar_device(struct ath_softc *sc); const char * ath5k_chip_name(enum ath5k_srev_type type, u_int16_t val); void ath_hw_beacon_stop(struct ath_softc *sc); int ath_hw_check_atim(struct ath_softc *sc, int window, int intval); diff --git a/ath/if_ath_radar.c b/ath/if_ath_radar.c index ce0671e..1d3a4b8 100644 --- a/ath/if_ath_radar.c +++ b/ath/if_ath_radar.c @@ -158,7 +158,7 @@ static u_int32_t interval_to_frequency(u_int32_t pri); int ath_radar_is_enabled(struct ath_softc *sc) { struct ath_hal *ah = sc->sc_ah; - if (ar_device(sc->devid) >= 5211) + if (ar_device(sc) >= 5211) return ((OS_REG_READ(ah, AR5K_AR5212_PHY_ERR_FIL) & AR5K_AR5212_PHY_ERR_FIL_RADAR) && (sc->sc_imask & HAL_INT_RXPHY) && @@ -243,7 +243,7 @@ int ath_radar_update(struct ath_softc *sc) /* configure radar pulse detector register using default values, but do * not toggle the enable bit. XXX: allow tweaking?? */ ath_radar_set_params(sc, NULL); - if (ar_device(sc->devid) >= 5211) { + if (ar_device(sc) >= 5211) { HAL_INT old_ier = ath_hal_intrget(ah); HAL_INT new_ier = old_ier; unsigned int old_radar = OS_REG_READ(ah, AR5K_PHY_RADAR);