1 This adds a bwmode debugfs file which can be used to set alternate
2 channel operating bandwidths. Only tested with AR5413 and only at
5 Signed-off-by: Pat Erley <pat-lkml at erley.org>
7 Other devices will need to be added to the switch in write_file_bwmode
9 drivers/net/wireless/ath/ath5k/debug.c | 86 ++++++++++++++++++++++++++++++++
10 1 files changed, 86 insertions(+), 0 deletions(-)
12 diff --git a/drivers/net/wireless/ath/ath5k/debug.c b/drivers/net/wireless/ath/ath5k/debug.c
13 index 8c5ce8b..bb41066 100644
14 --- a/drivers/net/wireless/ath/ath5k/debug.c
15 +++ b/drivers/net/wireless/ath/ath5k/debug.c
16 @@ -815,6 +815,89 @@ static const struct file_operations fops_ani = {
17 .llseek = default_llseek,
20 +/* debugfs: bwmode */
22 +static ssize_t read_file_bwmode(struct file *file, char __user *user_buf,
23 + size_t count, loff_t *ppos)
25 + struct ath5k_hw *ah = file->private_data;
27 + unsigned int len = 0;
29 + int cur_ah_bwmode = ah->ah_bwmode;
31 +#define print_selected(MODE, LABEL) \
32 + if (cur_ah_bwmode == MODE) \
33 + len += snprintf(buf+len, sizeof(buf)-len, "[%s]", LABEL); \
35 + len += snprintf(buf+len, sizeof(buf)-len, "%s", LABEL); \
36 + len += snprintf(buf+len, sizeof(buf)-len, " ");
38 + print_selected(AR5K_BWMODE_5MHZ, "5");
39 + print_selected(AR5K_BWMODE_10MHZ, "10");
40 + print_selected(AR5K_BWMODE_DEFAULT, "20");
41 + print_selected(AR5K_BWMODE_40MHZ, "40");
42 +#undef print_selected
44 + len += snprintf(buf+len, sizeof(buf)-len, "\n");
46 + return simple_read_from_buffer(user_buf, count, ppos, buf, len);
49 +static ssize_t write_file_bwmode(struct file *file,
50 + const char __user *userbuf,
51 + size_t count, loff_t *ppos)
53 + struct ath5k_hw *ah = file->private_data;
56 + int tobwmode = AR5K_BWMODE_DEFAULT;
58 + if (copy_from_user(buf, userbuf, min(count, sizeof(buf))))
61 + /* TODO: Add check for active interface */
63 + if(strncmp(buf, "5", 1) == 0 ) {
64 + tobwmode = AR5K_BWMODE_5MHZ;
66 + } else if ( strncmp(buf, "10", 2) == 0 ) {
67 + tobwmode = AR5K_BWMODE_10MHZ;
69 + } else if ( strncmp(buf, "20", 2) == 0 ) {
70 + tobwmode = AR5K_BWMODE_DEFAULT;
72 + } else if ( strncmp(buf, "40", 2) == 0 ) {
73 + tobwmode = AR5K_BWMODE_40MHZ;
78 + ATH5K_INFO(ah, "Changing to %imhz channel width[%i]\n",
81 + switch (ah->ah_radio) {
82 + /* TODO: only define radios that actually support 5/10mhz channels */
83 + case AR5K_RF5413: case AR5K_RF5110: case AR5K_RF5111: case AR5K_RF5112: case AR5K_RF2413: case AR5K_RF2316: case AR5K_RF2317: case AR5K_RF2425:
84 + if(ah->ah_bwmode != tobwmode) {
85 + mutex_lock(&ah->lock);
86 + ah->ah_bwmode = tobwmode;
87 + mutex_unlock(&ah->lock);
96 +static const struct file_operations fops_bwmode = {
97 + .read = read_file_bwmode,
98 + .write = write_file_bwmode,
99 + .open = simple_open,
100 + .owner = THIS_MODULE,
101 + .llseek = default_llseek,
104 /* debugfs: queues etc */
106 @@ -906,6 +989,9 @@ ath5k_debug_init_device(struct ath5k_hw *ah)
107 debugfs_create_file("beacon", S_IWUSR | S_IRUSR, phydir, ah,
110 + debugfs_create_file("bwmode", S_IWUSR | S_IRUSR, phydir, ah,
113 debugfs_create_file("reset", S_IWUSR, phydir, ah, &fops_reset);
115 debugfs_create_file("antenna", S_IWUSR | S_IRUSR, phydir, ah,