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 --- a/drivers/net/wireless/ath/ath5k/debug.c
13 +++ b/drivers/net/wireless/ath/ath5k/debug.c
14 @@ -823,6 +823,97 @@ static const struct file_operations fops
15 .llseek = default_llseek,
18 +/* debugfs: bwmode */
20 +static ssize_t read_file_bwmode(struct file *file, char __user *user_buf,
21 + size_t count, loff_t *ppos)
23 + struct ath5k_hw *ah = file->private_data;
25 + unsigned int len = 0;
27 + int cur_ah_bwmode = ah->ah_bwmode_debug;
29 +#define print_selected(MODE, LABEL) \
30 + if (cur_ah_bwmode == MODE) \
31 + len += snprintf(buf+len, sizeof(buf)-len, "[%s]", LABEL); \
33 + len += snprintf(buf+len, sizeof(buf)-len, "%s", LABEL); \
34 + len += snprintf(buf+len, sizeof(buf)-len, " ");
36 + print_selected(AR5K_BWMODE_5MHZ, "5");
37 + print_selected(AR5K_BWMODE_10MHZ, "10");
38 + print_selected(AR5K_BWMODE_DEFAULT, "20");
39 + print_selected(AR5K_BWMODE_40MHZ, "40");
40 +#undef print_selected
42 + len += snprintf(buf+len, sizeof(buf)-len, "\n");
44 + return simple_read_from_buffer(user_buf, count, ppos, buf, len);
47 +static ssize_t write_file_bwmode(struct file *file,
48 + const char __user *userbuf,
49 + size_t count, loff_t *ppos)
51 + struct ath5k_hw *ah = file->private_data;
54 + int tobwmode = AR5K_BWMODE_DEFAULT;
56 + if (copy_from_user(buf, userbuf, min(count, sizeof(buf))))
59 + /* TODO: Add check for active interface */
61 + if(strncmp(buf, "5", 1) == 0 ) {
62 + tobwmode = AR5K_BWMODE_5MHZ;
64 + } else if ( strncmp(buf, "10", 2) == 0 ) {
65 + tobwmode = AR5K_BWMODE_10MHZ;
67 + } else if ( strncmp(buf, "20", 2) == 0 ) {
68 + tobwmode = AR5K_BWMODE_DEFAULT;
70 + } else if ( strncmp(buf, "40", 2) == 0 ) {
71 + tobwmode = AR5K_BWMODE_40MHZ;
76 + ATH5K_INFO(ah, "Changing to %imhz channel width[%i]\n",
79 + switch (ah->ah_radio) {
80 + /* TODO: only define radios that actually support 5/10mhz channels */
89 + if(ah->ah_bwmode_debug != tobwmode) {
90 + mutex_lock(&ah->lock);
91 + ah->ah_bwmode = tobwmode;
92 + ah->ah_bwmode_debug = tobwmode;
93 + mutex_unlock(&ah->lock);
102 +static const struct file_operations fops_bwmode = {
103 + .read = read_file_bwmode,
104 + .write = write_file_bwmode,
105 + .open = simple_open,
106 + .owner = THIS_MODULE,
107 + .llseek = default_llseek,
110 /* debugfs: queues etc */
112 @@ -1010,6 +1101,9 @@ ath5k_debug_init_device(struct ath5k_hw
113 debugfs_create_file("beacon", S_IWUSR | S_IRUSR, phydir, ah,
116 + debugfs_create_file("bwmode", S_IWUSR | S_IRUSR, phydir, ah,
119 debugfs_create_file("reset", S_IWUSR, phydir, ah, &fops_reset);
121 debugfs_create_file("antenna", S_IWUSR | S_IRUSR, phydir, ah,
122 --- a/drivers/net/wireless/ath/ath5k/ath5k.h
123 +++ b/drivers/net/wireless/ath/ath5k/ath5k.h
124 @@ -1370,6 +1370,7 @@ struct ath5k_hw {
125 u8 ah_coverage_class;
126 bool ah_ack_bitrate_high;
128 + u8 ah_bwmode_debug;
131 /* Antenna Control */
132 --- a/drivers/net/wireless/ath/ath5k/base.c
133 +++ b/drivers/net/wireless/ath/ath5k/base.c
134 @@ -466,6 +466,9 @@ ath5k_chan_set(struct ath5k_hw *ah, stru
138 + if (ah->ah_bwmode_debug != AR5K_BWMODE_DEFAULT)
139 + ah->ah_bwmode = ah->ah_bwmode_debug;
142 * To switch channels clear any pending DMA operations;
143 * wait long enough for the RX fifo to drain, reset the