aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/ath/ath9k/debug.c
diff options
context:
space:
mode:
authorSujith Manoharan <c_manoha@qualcomm.com>2012-09-25 22:25:18 -0400
committerJohn W. Linville <linville@tuxdriver.com>2012-09-28 13:54:03 -0400
commit302a3c3a387eb01cc055684094e9450a79780acd (patch)
tree66790ab6ac6e3fa7dd272157481a7efafcafd131 /drivers/net/wireless/ath/ath9k/debug.c
parent69c6ac60f559f85ed47fbfc2bcaa43a7bc1583ff (diff)
ath9k: Add a debugfs file to adjust antenna diversity
Location: /<debugfs>/ieee80211/phy#/ath9k/diversity Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/ath/ath9k/debug.c')
-rw-r--r--drivers/net/wireless/ath/ath9k/debug.c55
1 files changed, 53 insertions, 2 deletions
diff --git a/drivers/net/wireless/ath/ath9k/debug.c b/drivers/net/wireless/ath/ath9k/debug.c
index ab3bc85a1f8..ed38216c3ca 100644
--- a/drivers/net/wireless/ath/ath9k/debug.c
+++ b/drivers/net/wireless/ath/ath9k/debug.c
@@ -222,6 +222,57 @@ static const struct file_operations fops_disable_ani = {
222 .llseek = default_llseek, 222 .llseek = default_llseek,
223}; 223};
224 224
225static ssize_t read_file_ant_diversity(struct file *file, char __user *user_buf,
226 size_t count, loff_t *ppos)
227{
228 struct ath_softc *sc = file->private_data;
229 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
230 char buf[32];
231 unsigned int len;
232
233 len = sprintf(buf, "%d\n", common->antenna_diversity);
234 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
235}
236
237static ssize_t write_file_ant_diversity(struct file *file,
238 const char __user *user_buf,
239 size_t count, loff_t *ppos)
240{
241 struct ath_softc *sc = file->private_data;
242 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
243 unsigned long antenna_diversity;
244 char buf[32];
245 ssize_t len;
246
247 len = min(count, sizeof(buf) - 1);
248 if (copy_from_user(buf, user_buf, len))
249 return -EFAULT;
250
251 if (!AR_SREV_9565(sc->sc_ah))
252 goto exit;
253
254 buf[len] = '\0';
255 if (strict_strtoul(buf, 0, &antenna_diversity))
256 return -EINVAL;
257
258 common->antenna_diversity = !!antenna_diversity;
259 ath9k_ps_wakeup(sc);
260 ath_ant_comb_update(sc);
261 ath_dbg(common, CONFIG, "Antenna diversity: %d\n",
262 common->antenna_diversity);
263 ath9k_ps_restore(sc);
264exit:
265 return count;
266}
267
268static const struct file_operations fops_ant_diversity = {
269 .read = read_file_ant_diversity,
270 .write = write_file_ant_diversity,
271 .open = simple_open,
272 .owner = THIS_MODULE,
273 .llseek = default_llseek,
274};
275
225static ssize_t read_file_dma(struct file *file, char __user *user_buf, 276static ssize_t read_file_dma(struct file *file, char __user *user_buf,
226 size_t count, loff_t *ppos) 277 size_t count, loff_t *ppos)
227{ 278{
@@ -1599,12 +1650,12 @@ int ath9k_init_debug(struct ath_hw *ah)
1599 debugfs_create_file("samples", S_IRUSR, sc->debug.debugfs_phy, sc, 1650 debugfs_create_file("samples", S_IRUSR, sc->debug.debugfs_phy, sc,
1600 &fops_samps); 1651 &fops_samps);
1601#endif 1652#endif
1602
1603 debugfs_create_u32("gpio_mask", S_IRUSR | S_IWUSR, 1653 debugfs_create_u32("gpio_mask", S_IRUSR | S_IWUSR,
1604 sc->debug.debugfs_phy, &sc->sc_ah->gpio_mask); 1654 sc->debug.debugfs_phy, &sc->sc_ah->gpio_mask);
1605
1606 debugfs_create_u32("gpio_val", S_IRUSR | S_IWUSR, 1655 debugfs_create_u32("gpio_val", S_IRUSR | S_IWUSR,
1607 sc->debug.debugfs_phy, &sc->sc_ah->gpio_val); 1656 sc->debug.debugfs_phy, &sc->sc_ah->gpio_val);
1657 debugfs_create_file("diversity", S_IRUSR | S_IWUSR,
1658 sc->debug.debugfs_phy, sc, &fops_ant_diversity);
1608 1659
1609 return 0; 1660 return 0;
1610} 1661}