ath9k: Add a debug entry to start/stop ANI
authorMohammed Shafi Shajakhan <mshajakhan@atheros.com>
Thu, 26 May 2011 05:26:15 +0000 (10:56 +0530)
committerJohn W. Linville <linville@tuxdriver.com>
Wed, 1 Jun 2011 19:36:29 +0000 (15:36 -0400)
this helps the user to start/stop ANI dynamically.

Signed-off-by: Mohammed Shafi Shajakhan <mshajakhan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/ath/ath.h
drivers/net/wireless/ath/ath9k/ath9k.h
drivers/net/wireless/ath/ath9k/debug.c
drivers/net/wireless/ath/ath9k/init.c
drivers/net/wireless/ath/ath9k/main.c

index 7cf4317a2a84b35dc8c19c277746aec8345220e1..17c4b56c3874306eab45aea4d927c5b2915946d6 100644 (file)
@@ -161,6 +161,7 @@ struct ath_common {
        const struct ath_bus_ops *bus_ops;
 
        bool btcoex_enabled;
+       bool disable_ani;
 };
 
 struct sk_buff *ath_rxbuf_alloc(struct ath_common *common,
index 4cc78449ed9f0c4e175c227ccdad7e2d4962492e..3bf1d83ab41f58c5b48d45ff8c463a0d9817e46d 100644 (file)
@@ -427,6 +427,7 @@ void ath_hw_check(struct work_struct *work);
 void ath_hw_pll_work(struct work_struct *work);
 void ath_paprd_calibrate(struct work_struct *work);
 void ath_ani_calibrate(unsigned long data);
+void ath_start_ani(struct ath_common *common);
 
 /**********/
 /* BTCOEX */
index 202399d4fe1737e1d014afcf54b5d3470d2dfdfb..7230d6578b15d88b8821fabd42c584d174b32982 100644 (file)
@@ -176,6 +176,56 @@ static const struct file_operations fops_rx_chainmask = {
        .llseek = default_llseek,
 };
 
+static ssize_t read_file_disable_ani(struct file *file, char __user *user_buf,
+                            size_t count, loff_t *ppos)
+{
+       struct ath_softc *sc = file->private_data;
+       struct ath_common *common = ath9k_hw_common(sc->sc_ah);
+       char buf[32];
+       unsigned int len;
+
+       len = sprintf(buf, "%d\n", common->disable_ani);
+       return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+}
+
+static ssize_t write_file_disable_ani(struct file *file,
+                                     const char __user *user_buf,
+                                     size_t count, loff_t *ppos)
+{
+       struct ath_softc *sc = file->private_data;
+       struct ath_common *common = ath9k_hw_common(sc->sc_ah);
+       unsigned long disable_ani;
+       char buf[32];
+       ssize_t len;
+
+       len = min(count, sizeof(buf) - 1);
+       if (copy_from_user(buf, user_buf, len))
+               return -EFAULT;
+
+       buf[len] = '\0';
+       if (strict_strtoul(buf, 0, &disable_ani))
+               return -EINVAL;
+
+       common->disable_ani = !!disable_ani;
+
+       if (disable_ani) {
+               sc->sc_flags &= ~SC_OP_ANI_RUN;
+               del_timer_sync(&common->ani.timer);
+       } else {
+               sc->sc_flags |= SC_OP_ANI_RUN;
+               ath_start_ani(common);
+       }
+
+       return count;
+}
+
+static const struct file_operations fops_disable_ani = {
+       .read = read_file_disable_ani,
+       .write = write_file_disable_ani,
+       .open = ath9k_debugfs_open,
+       .owner = THIS_MODULE,
+       .llseek = default_llseek,
+};
 
 static ssize_t read_file_dma(struct file *file, char __user *user_buf,
                             size_t count, loff_t *ppos)
@@ -1159,6 +1209,8 @@ int ath9k_init_debug(struct ath_hw *ah)
                            sc->debug.debugfs_phy, sc, &fops_rx_chainmask);
        debugfs_create_file("tx_chainmask", S_IRUSR | S_IWUSR,
                            sc->debug.debugfs_phy, sc, &fops_tx_chainmask);
+       debugfs_create_file("disable_ani", S_IRUSR | S_IWUSR,
+                           sc->debug.debugfs_phy, sc, &fops_disable_ani);
        debugfs_create_file("regidx", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
                            sc, &fops_regidx);
        debugfs_create_file("regval", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
index 45c585a337e9885b336f1ae50731170f6f63344c..d4b166cfdf6047935b6faad502ef59fae2f1d64a 100644 (file)
@@ -519,7 +519,6 @@ static void ath9k_init_misc(struct ath_softc *sc)
 {
        struct ath_common *common = ath9k_hw_common(sc->sc_ah);
        int i = 0;
-
        setup_timer(&common->ani.timer, ath_ani_calibrate, (unsigned long)sc);
 
        sc->config.txpowlimit = ATH_TXPOWER_MAX;
@@ -585,6 +584,7 @@ static int ath9k_init_softc(u16 devid, struct ath_softc *sc, u16 subsysid,
        common->priv = sc;
        common->debug_mask = ath9k_debug;
        common->btcoex_enabled = ath9k_btcoex_enable == 1;
+       common->disable_ani = false;
        spin_lock_init(&common->cc_lock);
 
        spin_lock_init(&sc->sc_serial_rw);
index 5cf2dc3c65fc296d712f499a167d7abf2e232676..7f945333e2d80bae3438c350a4ed9e1a6c3d5ef3 100644 (file)
@@ -134,7 +134,7 @@ void ath9k_ps_restore(struct ath_softc *sc)
        spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
 }
 
-static void ath_start_ani(struct ath_common *common)
+void ath_start_ani(struct ath_common *common)
 {
        struct ath_hw *ah = common->ah;
        unsigned long timestamp = jiffies_to_msecs(jiffies);
@@ -300,7 +300,8 @@ static int ath_set_channel(struct ath_softc *sc, struct ieee80211_hw *hw,
                        ath_set_beacon(sc);
                ieee80211_queue_delayed_work(sc->hw, &sc->tx_complete_work, 0);
                ieee80211_queue_delayed_work(sc->hw, &sc->hw_pll_work, HZ/2);
-               ath_start_ani(common);
+               if (!common->disable_ani)
+                       ath_start_ani(common);
        }
 
  ps_restore:
@@ -968,6 +969,7 @@ int ath_reset(struct ath_softc *sc, bool retry_tx)
        sc->hw_busy_count = 0;
 
        /* Stop ANI */
+
        del_timer_sync(&common->ani.timer);
 
        ath9k_ps_wakeup(sc);
@@ -1017,7 +1019,9 @@ int ath_reset(struct ath_softc *sc, bool retry_tx)
        spin_unlock_bh(&sc->sc_pcu_lock);
 
        /* Start ANI */
-       ath_start_ani(common);
+       if (!common->disable_ani)
+               ath_start_ani(common);
+
        ath9k_ps_restore(sc);
 
        return r;
@@ -1408,8 +1412,12 @@ static void ath9k_calculate_summary_state(struct ieee80211_hw *hw,
        /* Set up ANI */
        if (iter_data.naps > 0) {
                sc->sc_ah->stats.avgbrssi = ATH_RSSI_DUMMY_MARKER;
-               sc->sc_flags |= SC_OP_ANI_RUN;
-               ath_start_ani(common);
+
+               if (!common->disable_ani) {
+                       sc->sc_flags |= SC_OP_ANI_RUN;
+                       ath_start_ani(common);
+               }
+
        } else {
                sc->sc_flags &= ~SC_OP_ANI_RUN;
                del_timer_sync(&common->ani.timer);
@@ -1973,8 +1981,11 @@ static void ath9k_bss_iter(void *data, u8 *mac, struct ieee80211_vif *vif)
                sc->last_rssi = ATH_RSSI_DUMMY_MARKER;
                sc->sc_ah->stats.avgbrssi = ATH_RSSI_DUMMY_MARKER;
 
-               sc->sc_flags |= SC_OP_ANI_RUN;
-               ath_start_ani(common);
+               if (!common->disable_ani) {
+                       sc->sc_flags |= SC_OP_ANI_RUN;
+                       ath_start_ani(common);
+               }
+
        }
 }
 
@@ -2043,8 +2054,12 @@ static void ath9k_bss_info_changed(struct ieee80211_hw *hw,
 
                if (bss_conf->ibss_joined) {
                        sc->sc_ah->stats.avgbrssi = ATH_RSSI_DUMMY_MARKER;
-                       sc->sc_flags |= SC_OP_ANI_RUN;
-                       ath_start_ani(common);
+
+                       if (!common->disable_ani) {
+                               sc->sc_flags |= SC_OP_ANI_RUN;
+                               ath_start_ani(common);
+                       }
+
                } else {
                        sc->sc_flags &= ~SC_OP_ANI_RUN;
                        del_timer_sync(&common->ani.timer);