2011-08-24 18:49:19

by Mohammed Shafi Shajakhan

[permalink] [raw]
Subject: [RFC] ath9k: Add a debug entry for current tx-power

From: Mohammed Shafi Shajakhan <[email protected]>

this is the tx-power that seems to be used by the hardware code

Signed-off-by: Mohammed Shafi Shajakhan <[email protected]>
---
drivers/net/wireless/ath/ath9k/debug.c | 43 ++++++++++++++++++++++++++++++++
1 files changed, 43 insertions(+), 0 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/debug.c b/drivers/net/wireless/ath/ath9k/debug.c
index 9bec3b8..982371f 100644
--- a/drivers/net/wireless/ath/ath9k/debug.c
+++ b/drivers/net/wireless/ath/ath9k/debug.c
@@ -176,6 +176,47 @@ static const struct file_operations fops_rx_chainmask = {
.llseek = default_llseek,
};

+static ssize_t read_file_current_txpower(struct file *file,
+ char __user *user_buf,
+ size_t count, loff_t *ppos)
+{
+ struct ath_softc *sc = file->private_data;
+ char buf[32];
+ unsigned int len;
+
+ len = sprintf(buf, "%u\n", sc->curtxpow);
+ return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+}
+
+static ssize_t write_file_current_txpower(struct file *file,
+ const char __user *user_buf,
+ size_t count, loff_t *ppos)
+{
+ struct ath_softc *sc = file->private_data;
+ unsigned long current_tx_power;
+ 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, &current_tx_power))
+ return -EINVAL;
+
+ sc->curtxpow = current_tx_power;
+ return count;
+}
+
+static const struct file_operations fops_current_txpower = {
+ .read = read_file_current_txpower,
+ .write = write_file_current_txpower,
+ .open = ath9k_debugfs_open,
+ .owner = THIS_MODULE,
+ .llseek = default_llseek,
+};
+
static ssize_t read_file_disable_ani(struct file *file, char __user *user_buf,
size_t count, loff_t *ppos)
{
@@ -1253,6 +1294,8 @@ int ath9k_init_debug(struct ath_hw *ah)
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("current_txpower", S_IRUSR | S_IWUSR,
+ sc->debug.debugfs_phy, sc, &fops_current_txpower);
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,
--
1.7.0.4