Update hostapd to 0.6.4
[openwrt.git] / package / b43 / src / debugfs.c
index b5c589e..210e278 100644 (file)
 #include "main.h"
 #include "debugfs.h"
 #include "dma.h"
-#include "pio.h"
 #include "xmit.h"
 
 
 /* The root directory. */
-struct dentry *rootdir;
+static struct dentry *rootdir;
 
 struct b43_debugfs_fops {
        ssize_t (*read)(struct b43_wldev *dev, char *buf, size_t bufsize);
@@ -76,7 +75,8 @@ struct b43_dfs_file * fops_to_dfs_file(struct b43_wldev *dev,
 
 
 /* wl->irq_lock is locked */
-ssize_t tsf_read_file(struct b43_wldev *dev, char *buf, size_t bufsize)
+static ssize_t tsf_read_file(struct b43_wldev *dev,
+                            char *buf, size_t bufsize)
 {
        ssize_t count = 0;
        u64 tsf;
@@ -90,7 +90,8 @@ ssize_t tsf_read_file(struct b43_wldev *dev, char *buf, size_t bufsize)
 }
 
 /* wl->irq_lock is locked */
-int tsf_write_file(struct b43_wldev *dev, const char *buf, size_t count)
+static int tsf_write_file(struct b43_wldev *dev,
+                         const char *buf, size_t count)
 {
        u64 tsf;
 
@@ -102,7 +103,8 @@ int tsf_write_file(struct b43_wldev *dev, const char *buf, size_t count)
 }
 
 /* wl->irq_lock is locked */
-ssize_t ucode_regs_read_file(struct b43_wldev *dev, char *buf, size_t bufsize)
+static ssize_t ucode_regs_read_file(struct b43_wldev *dev,
+                                   char *buf, size_t bufsize)
 {
        ssize_t count = 0;
        int i;
@@ -116,7 +118,8 @@ ssize_t ucode_regs_read_file(struct b43_wldev *dev, char *buf, size_t bufsize)
 }
 
 /* wl->irq_lock is locked */
-ssize_t shm_read_file(struct b43_wldev *dev, char *buf, size_t bufsize)
+static ssize_t shm_read_file(struct b43_wldev *dev,
+                            char *buf, size_t bufsize)
 {
        ssize_t count = 0;
        int i;
@@ -124,7 +127,7 @@ ssize_t shm_read_file(struct b43_wldev *dev, char *buf, size_t bufsize)
        __le16 *le16buf = (__le16 *)buf;
 
        for (i = 0; i < 0x1000; i++) {
-               if (bufsize <= 0)
+               if (bufsize < sizeof(tmp))
                        break;
                tmp = b43_shm_read16(dev, B43_SHM_SHARED, 2 * i);
                le16buf[i] = cpu_to_le16(tmp);
@@ -135,7 +138,8 @@ ssize_t shm_read_file(struct b43_wldev *dev, char *buf, size_t bufsize)
        return count;
 }
 
-ssize_t txstat_read_file(struct b43_wldev *dev, char *buf, size_t bufsize)
+static ssize_t txstat_read_file(struct b43_wldev *dev,
+                               char *buf, size_t bufsize)
 {
        struct b43_txstatus_log *log = &dev->dfsentry->txstatlog;
        ssize_t count = 0;
@@ -182,7 +186,8 @@ out_unlock:
        return count;
 }
 
-ssize_t txpower_g_read_file(struct b43_wldev *dev, char *buf, size_t bufsize)
+static ssize_t txpower_g_read_file(struct b43_wldev *dev,
+                                  char *buf, size_t bufsize)
 {
        ssize_t count = 0;
 
@@ -214,10 +219,9 @@ out:
        return count;
 }
 
-int txpower_g_write_file(struct b43_wldev *dev, const char *buf, size_t count)
+static int txpower_g_write_file(struct b43_wldev *dev,
+                               const char *buf, size_t count)
 {
-       unsigned long phy_flags;
-
        if (dev->phy.type != B43_PHYTYPE_G)
                return -ENODEV;
        if ((count >= 4) && (memcmp(buf, "auto", 4) == 0)) {
@@ -241,19 +245,20 @@ int txpower_g_write_file(struct b43_wldev *dev, const char *buf, size_t count)
                        dev->phy.tx_control |= B43_TXCTL_PA2DB;
                if (pa3db)
                        dev->phy.tx_control |= B43_TXCTL_PA3DB;
-               b43_phy_lock(dev, phy_flags);
+               b43_phy_lock(dev);
                b43_radio_lock(dev);
                b43_set_txpower_g(dev, &dev->phy.bbatt,
                                  &dev->phy.rfatt, dev->phy.tx_control);
                b43_radio_unlock(dev);
-               b43_phy_unlock(dev, phy_flags);
+               b43_phy_unlock(dev);
        }
 
        return 0;
 }
 
 /* wl->irq_lock is locked */
-int restart_write_file(struct b43_wldev *dev, const char *buf, size_t count)
+static int restart_write_file(struct b43_wldev *dev,
+                             const char *buf, size_t count)
 {
        int err = 0;
 
@@ -265,52 +270,69 @@ int restart_write_file(struct b43_wldev *dev, const char *buf, size_t count)
        return err;
 }
 
-static ssize_t append_lo_table(ssize_t count, char *buf, const size_t bufsize,
-                              struct b43_loctl table[B43_NR_BB][B43_NR_RF])
+static unsigned long calc_expire_secs(unsigned long now,
+                                     unsigned long time,
+                                     unsigned long expire)
 {
-       unsigned int i, j;
-       struct b43_loctl *ctl;
-
-       for (i = 0; i < B43_NR_BB; i++) {
-               for (j = 0; j < B43_NR_RF; j++) {
-                       ctl = &(table[i][j]);
-                       fappend("(bbatt %2u, rfatt %2u)  ->  "
-                               "(I %+3d, Q %+3d, Used: %d, Calibrated: %d)\n",
-                               i, j, ctl->i, ctl->q,
-                               ctl->used,
-                               b43_loctl_is_calibrated(ctl));
-               }
+       expire = time + expire;
+
+       if (time_after(now, expire))
+               return 0; /* expired */
+       if (expire < now) {
+               /* jiffies wrapped */
+               expire -= MAX_JIFFY_OFFSET;
+               now -= MAX_JIFFY_OFFSET;
        }
+       B43_WARN_ON(expire < now);
 
-       return count;
+       return (expire - now) / HZ;
 }
 
-ssize_t loctls_read_file(struct b43_wldev *dev, char *buf, size_t bufsize)
+static ssize_t loctls_read_file(struct b43_wldev *dev,
+                               char *buf, size_t bufsize)
 {
        ssize_t count = 0;
        struct b43_txpower_lo_control *lo;
        int i, err = 0;
+       struct b43_lo_calib *cal;
+       unsigned long now = jiffies;
+       struct b43_phy *phy = &dev->phy;
 
-       if (dev->phy.type != B43_PHYTYPE_G) {
+       if (phy->type != B43_PHYTYPE_G) {
                fappend("Device is not a G-PHY\n");
                err = -ENODEV;
                goto out;
        }
-       lo = dev->phy.lo_control;
+       lo = phy->lo_control;
        fappend("-- Local Oscillator calibration data --\n\n");
-       fappend("Measured: %d,  Rebuild: %d,  HW-power-control: %d\n",
-               lo->lo_measured,
-               lo->rebuild,
+       fappend("HW-power-control enabled: %d\n",
                dev->phy.hardware_power_control);
-       fappend("TX Bias: 0x%02X,  TX Magn: 0x%02X\n",
-               lo->tx_bias, lo->tx_magn);
-       fappend("Power Vector: 0x%08X%08X\n",
+       fappend("TX Bias: 0x%02X,  TX Magn: 0x%02X  (expire in %lu sec)\n",
+               lo->tx_bias, lo->tx_magn,
+               calc_expire_secs(now, lo->txctl_measured_time,
+                                B43_LO_TXCTL_EXPIRE));
+       fappend("Power Vector: 0x%08X%08X  (expires in %lu sec)\n",
                (unsigned int)((lo->power_vector & 0xFFFFFFFF00000000ULL) >> 32),
-               (unsigned int)(lo->power_vector & 0x00000000FFFFFFFFULL));
-       fappend("\nControl table WITH PADMIX:\n");
-       count = append_lo_table(count, buf, bufsize, lo->with_padmix);
-       fappend("\nControl table WITHOUT PADMIX:\n");
-       count = append_lo_table(count, buf, bufsize, lo->no_padmix);
+               (unsigned int)(lo->power_vector & 0x00000000FFFFFFFFULL),
+               calc_expire_secs(now, lo->pwr_vec_read_time,
+                                B43_LO_PWRVEC_EXPIRE));
+
+       fappend("\nCalibrated settings:\n");
+       list_for_each_entry(cal, &lo->calib_list, list) {
+               bool active;
+
+               active = (b43_compare_bbatt(&cal->bbatt, &phy->bbatt) &&
+                         b43_compare_rfatt(&cal->rfatt, &phy->rfatt));
+               fappend("BB(%d), RF(%d,%d)  ->  I=%d, Q=%d  "
+                       "(expires in %lu sec)%s\n",
+                       cal->bbatt.att,
+                       cal->rfatt.att, cal->rfatt.with_padmix,
+                       cal->ctl.i, cal->ctl.q,
+                       calc_expire_secs(now, cal->calib_time,
+                                        B43_LO_CALIB_EXPIRE),
+                       active ? "  ACTIVE" : "");
+       }
+
        fappend("\nUsed RF attenuation values:  Value(WithPadmix flag)\n");
        for (i = 0; i < lo->rfatt_list.len; i++) {
                fappend("%u(%d), ",
@@ -343,9 +365,9 @@ static ssize_t b43_debugfs_read(struct file *file, char __user *userbuf,
        struct b43_wldev *dev;
        struct b43_debugfs_fops *dfops;
        struct b43_dfs_file *dfile;
-       ssize_t ret;
+       ssize_t uninitialized_var(ret);
        char *buf;
-       const size_t bufsize = 1024 * 128;
+       const size_t bufsize = 1024 * 16; /* 16 kiB buffer */
        const size_t buforder = get_order(bufsize);
        int err = 0;
 
@@ -515,6 +537,7 @@ static void b43_add_dynamic_debug(struct b43_wldev *dev)
        add_dyn_dbg("debug_dmaverbose", B43_DBG_DMAVERBOSE, 0);
        add_dyn_dbg("debug_pwork_fast", B43_DBG_PWORK_FAST, 0);
        add_dyn_dbg("debug_pwork_stop", B43_DBG_PWORK_STOP, 0);
+       add_dyn_dbg("debug_lo", B43_DBG_LO, 0);
 
 #undef add_dyn_dbg
 }
@@ -610,6 +633,7 @@ void b43_debugfs_remove_device(struct b43_wldev *dev)
        kfree(e);
 }
 
+/* Called with IRQs disabled. */
 void b43_debugfs_log_txstat(struct b43_wldev *dev,
                            const struct b43_txstatus *status)
 {
@@ -621,8 +645,7 @@ void b43_debugfs_log_txstat(struct b43_wldev *dev,
        if (!e)
                return;
        log = &e->txstatlog;
-       B43_WARN_ON(!irqs_disabled());
-       spin_lock(&log->lock);
+       spin_lock(&log->lock); /* IRQs are already disabled. */
        i = log->end + 1;
        if (i == B43_NR_LOGGED_TXSTATUS)
                i = 0;
This page took 0.0327 seconds and 4 git commands to generate.