Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wirel...
authorDavid S. Miller <davem@davemloft.net>
Tue, 17 Mar 2009 22:04:31 +0000 (15:04 -0700)
committerDavid S. Miller <davem@davemloft.net>
Tue, 17 Mar 2009 22:04:31 +0000 (15:04 -0700)
1  2 
drivers/net/wireless/ath9k/hw.c
drivers/net/wireless/ath9k/main.c

@@@ -391,25 -391,6 +391,25 @@@ static void ath9k_hw_set_defaults(struc
        }
  
        ah->config.intr_mitigation = 1;
 +
 +      /*
 +       * We need this for PCI devices only (Cardbus, PCI, miniPCI)
 +       * _and_ if on non-uniprocessor systems (Multiprocessor/HT).
 +       * This means we use it for all AR5416 devices, and the few
 +       * minor PCI AR9280 devices out there.
 +       *
 +       * Serialization is required because these devices do not handle
 +       * well the case of two concurrent reads/writes due to the latency
 +       * involved. During one read/write another read/write can be issued
 +       * on another CPU while the previous read/write may still be working
 +       * on our hardware, if we hit this case the hardware poops in a loop.
 +       * We prevent this by serializing reads and writes.
 +       *
 +       * This issue is not present on PCI-Express devices or pre-AR5416
 +       * devices (legacy, 802.11abg).
 +       */
 +      if (num_possible_cpus() > 1)
 +              ah->config.serialize_regmode = SER_REG_MODE_AUTO;
  }
  
  static struct ath_hw *ath9k_hw_newstate(u16 devid, struct ath_softc *sc,
@@@ -629,8 -610,7 +629,8 @@@ static struct ath_hw *ath9k_hw_do_attac
        }
  
        if (ah->config.serialize_regmode == SER_REG_MODE_AUTO) {
 -              if (ah->hw_version.macVersion == AR_SREV_VERSION_5416_PCI) {
 +              if (ah->hw_version.macVersion == AR_SREV_VERSION_5416_PCI ||
 +                  (AR_SREV_9280(ah) && !ah->is_pciexpress)) {
                        ah->config.serialize_regmode =
                                SER_REG_MODE_ON;
                } else {
                ah->supp_cals = ADC_GAIN_CAL | ADC_DC_CAL | IQ_MISMATCH_CAL;
        }
  
-       if (AR_SREV_9160(ah)) {
-               ah->config.enable_ani = 1;
-               ah->ani_function = (ATH9K_ANI_SPUR_IMMUNITY_LEVEL |
-                                       ATH9K_ANI_FIRSTEP_LEVEL);
-       } else {
-               ah->ani_function = ATH9K_ANI_ALL;
-               if (AR_SREV_9280_10_OR_LATER(ah)) {
-                       ah->ani_function &=     ~ATH9K_ANI_NOISE_IMMUNITY_LEVEL;
-               }
-       }
+       ah->ani_function = ATH9K_ANI_ALL;
+       if (AR_SREV_9280_10_OR_LATER(ah))
+               ah->ani_function &= ~ATH9K_ANI_NOISE_IMMUNITY_LEVEL;
  
        DPRINTF(sc, ATH_DBG_RESET,
                "This Mac Chip Rev 0x%02x.%x is \n",
                ah->hw_version.macVersion, ah->hw_version.macRev);
  
        if (AR_SREV_9285_12_OR_LATER(ah)) {
                INIT_INI_ARRAY(&ah->iniModes, ar9285Modes_9285_1_2,
                               ARRAY_SIZE(ar9285Modes_9285_1_2), 6);
                INIT_INI_ARRAY(&ah->iniCommon, ar9285Common_9285_1_2,
        if (ecode != 0)
                goto bad;
  
+       if (AR_SREV_9285_12_OR_LATER(ah)) {
+               u32 txgain_type = ah->eep_ops->get_eeprom(ah, EEP_TXGAIN_TYPE);
+               /* txgain table */
+               if (txgain_type == AR5416_EEP_TXGAIN_HIGH_POWER) {
+                       INIT_INI_ARRAY(&ah->iniModesTxGain,
+                       ar9285Modes_high_power_tx_gain_9285_1_2,
+                       ARRAY_SIZE(ar9285Modes_high_power_tx_gain_9285_1_2), 6);
+               } else {
+                       INIT_INI_ARRAY(&ah->iniModesTxGain,
+                       ar9285Modes_original_tx_gain_9285_1_2,
+                       ARRAY_SIZE(ar9285Modes_original_tx_gain_9285_1_2), 6);
+               }
+       }
        /* rxgain table */
        if (AR_SREV_9280_20(ah))
                ath9k_hw_init_rxgain_ini(ah);
@@@ -1173,7 -1163,7 +1183,7 @@@ static void ath9k_hw_override_ini(struc
        REG_SET_BIT(ah, AR_DIAG_SW, (AR_DIAG_RX_DIS | AR_DIAG_RX_ABORT));
  
  
-       if (!AR_SREV_5416_V20_OR_LATER(ah) ||
+       if (!AR_SREV_5416_20_OR_LATER(ah) ||
            AR_SREV_9280_10_OR_LATER(ah))
                return;
  
@@@ -1275,7 -1265,7 +1285,7 @@@ static int ath9k_hw_process_ini(struct 
        REG_WRITE(ah, AR_PHY_ADC_SERIAL_CTL, AR_PHY_SEL_EXTERNAL_RADIO);
        ah->eep_ops->set_addac(ah, chan);
  
-       if (AR_SREV_5416_V22_OR_LATER(ah)) {
+       if (AR_SREV_5416_22_OR_LATER(ah)) {
                REG_WRITE_ARRAY(&ah->iniAddac, 1, regWrites);
        } else {
                struct ar5416IniArray temp;
        if (AR_SREV_9280(ah))
                REG_WRITE_ARRAY(&ah->iniModesRxGain, modesIndex, regWrites);
  
-       if (AR_SREV_9280(ah))
+       if (AR_SREV_9280(ah) || (AR_SREV_9285(ah) &&
+           AR_SREV_9285_12_OR_LATER(ah)))
                REG_WRITE_ARRAY(&ah->iniModesTxGain, modesIndex, regWrites);
  
        for (i = 0; i < ah->iniCommon.ia_rows; i++) {
@@@ -1084,12 -1084,6 +1084,6 @@@ fail
        ath_deinit_leds(sc);
  }
  
- #if defined(CONFIG_RFKILL) || defined(CONFIG_RFKILL_MODULE)
- /*******************/
- /*    Rfkill     */
- /*******************/
  void ath_radio_enable(struct ath_softc *sc)
  {
        struct ath_hw *ah = sc->sc_ah;
@@@ -1166,6 -1160,12 +1160,12 @@@ void ath_radio_disable(struct ath_soft
        ath9k_ps_restore(sc);
  }
  
+ #if defined(CONFIG_RFKILL) || defined(CONFIG_RFKILL_MODULE)
+ /*******************/
+ /*    Rfkill     */
+ /*******************/
  static bool ath_is_rfkill_set(struct ath_softc *sc)
  {
        struct ath_hw *ah = sc->sc_ah;
@@@ -1370,7 -1370,6 +1370,7 @@@ static int ath_init(u16 devid, struct a
  
        spin_lock_init(&sc->wiphy_lock);
        spin_lock_init(&sc->sc_resetlock);
 +      spin_lock_init(&sc->sc_serial_rw);
        mutex_init(&sc->mutex);
        tasklet_init(&sc->intr_tq, ath9k_tasklet, (unsigned long)sc);
        tasklet_init(&sc->bcon_tasklet, ath_beacon_tasklet,
@@@ -1583,7 -1582,8 +1583,8 @@@ void ath_set_hw_capab(struct ath_softc 
                IEEE80211_HW_SIGNAL_DBM |
                IEEE80211_HW_AMPDU_AGGREGATION |
                IEEE80211_HW_SUPPORTS_PS |
-               IEEE80211_HW_PS_NULLFUNC_STACK;
+               IEEE80211_HW_PS_NULLFUNC_STACK |
+               IEEE80211_HW_SPECTRUM_MGMT;
  
        if (AR_SREV_9160_10_OR_LATER(sc->sc_ah) || modparam_nohwcrypt)
                hw->flags |= IEEE80211_HW_MFP_CAPABLE;
@@@ -1671,7 -1671,7 +1672,7 @@@ int ath_attach(u16 devid, struct ath_so
        }
        wiphy_apply_custom_regulatory(hw->wiphy, regd);
        ath9k_reg_apply_radar_flags(hw->wiphy);
-       ath9k_reg_apply_world_flags(hw->wiphy, REGDOM_SET_BY_INIT);
+       ath9k_reg_apply_world_flags(hw->wiphy, NL80211_REGDOM_SET_BY_DRIVER);
  
        INIT_WORK(&sc->chan_work, ath9k_wiphy_chan_work);
        INIT_DELAYED_WORK(&sc->wiphy_work, ath9k_wiphy_work);
@@@ -1774,6 -1774,7 +1775,7 @@@ int ath_descdma_setup(struct ath_softc 
        DPRINTF(sc, ATH_DBG_CONFIG, "%s DMA: %u buffers %u desc/buf\n",
                name, nbuf, ndesc);
  
+       INIT_LIST_HEAD(head);
        /* ath_desc must be a multiple of DWORDs */
        if ((sizeof(struct ath_desc) % 4) != 0) {
                DPRINTF(sc, ATH_DBG_FATAL, "ath_desc not DWORD aligned\n");
  
        /* allocate descriptors */
        dd->dd_desc = dma_alloc_coherent(sc->dev, dd->dd_desc_len,
-                                        &dd->dd_desc_paddr, GFP_ATOMIC);
+                                        &dd->dd_desc_paddr, GFP_KERNEL);
        if (dd->dd_desc == NULL) {
                error = -ENOMEM;
                goto fail;
  
        /* allocate buffers */
        bsize = sizeof(struct ath_buf) * nbuf;
-       bf = kmalloc(bsize, GFP_KERNEL);
+       bf = kzalloc(bsize, GFP_KERNEL);
        if (bf == NULL) {
                error = -ENOMEM;
                goto fail2;
        }
-       memset(bf, 0, bsize);
        dd->dd_bufptr = bf;
  
-       INIT_LIST_HEAD(head);
        for (i = 0; i < nbuf; i++, bf++, ds += ndesc) {
                bf->bf_desc = ds;
                bf->bf_daddr = DS2PHYS(dd, ds);
@@@ -2859,12 -2858,20 +2859,20 @@@ static int __init ath9k_init(void
                goto err_out;
        }
  
+       error = ath9k_debug_create_root();
+       if (error) {
+               printk(KERN_ERR
+                       "ath9k: Unable to create debugfs root: %d\n",
+                       error);
+               goto err_rate_unregister;
+       }
        error = ath_pci_init();
        if (error < 0) {
                printk(KERN_ERR
                        "ath9k: No PCI devices found, driver not installed.\n");
                error = -ENODEV;
-               goto err_rate_unregister;
+               goto err_remove_root;
        }
  
        error = ath_ahb_init();
   err_pci_exit:
        ath_pci_exit();
  
+  err_remove_root:
+       ath9k_debug_remove_root();
   err_rate_unregister:
        ath_rate_control_unregister();
   err_out:
@@@ -2889,6 -2898,7 +2899,7 @@@ static void __exit ath9k_exit(void
  {
        ath_ahb_exit();
        ath_pci_exit();
+       ath9k_debug_remove_root();
        ath_rate_control_unregister();
        printk(KERN_INFO "%s: Driver unloaded\n", dev_info);
  }