ath9k: clean up some patches
[openwrt/staging/wigyori.git] / package / kernel / mac80211 / patches / 512-ath9k_channelbw_debugfs.patch
1 --- a/drivers/net/wireless/ath/ath9k/ath9k.h
2 +++ b/drivers/net/wireless/ath/ath9k/ath9k.h
3 @@ -701,6 +701,7 @@ struct ath_softc {
4 struct ieee80211_hw *hw;
5 struct device *dev;
6
7 + u32 chan_bw;
8 struct survey_info *cur_survey;
9 struct survey_info survey[ATH9K_NUM_CHANNELS];
10
11 --- a/drivers/net/wireless/ath/ath9k/debug.c
12 +++ b/drivers/net/wireless/ath/ath9k/debug.c
13 @@ -1918,6 +1918,50 @@ static const struct file_operations fops
14 .owner = THIS_MODULE
15 };
16
17 +
18 +static ssize_t read_file_chan_bw(struct file *file, char __user *user_buf,
19 + size_t count, loff_t *ppos)
20 +{
21 + struct ath_softc *sc = file->private_data;
22 + char buf[32];
23 + unsigned int len;
24 +
25 + len = sprintf(buf, "0x%08x\n", sc->chan_bw);
26 + return simple_read_from_buffer(user_buf, count, ppos, buf, len);
27 +}
28 +
29 +static ssize_t write_file_chan_bw(struct file *file, const char __user *user_buf,
30 + size_t count, loff_t *ppos)
31 +{
32 + struct ath_softc *sc = file->private_data;
33 + unsigned long chan_bw;
34 + char buf[32];
35 + ssize_t len;
36 +
37 + len = min(count, sizeof(buf) - 1);
38 + if (copy_from_user(buf, user_buf, len))
39 + return -EFAULT;
40 +
41 + buf[len] = '\0';
42 + if (kstrtoul(buf, 0, &chan_bw))
43 + return -EINVAL;
44 +
45 + sc->chan_bw = chan_bw;
46 + if (!test_bit(SC_OP_INVALID, &sc->sc_flags))
47 + ath9k_ops.config(sc->hw, IEEE80211_CONF_CHANGE_CHANNEL);
48 +
49 + return count;
50 +}
51 +
52 +static const struct file_operations fops_chanbw = {
53 + .read = read_file_chan_bw,
54 + .write = write_file_chan_bw,
55 + .open = simple_open,
56 + .owner = THIS_MODULE,
57 + .llseek = default_llseek,
58 +};
59 +
60 +
61 int ath9k_init_debug(struct ath_hw *ah)
62 {
63 struct ath_common *common = ath9k_hw_common(ah);
64 @@ -1937,6 +1981,8 @@ int ath9k_init_debug(struct ath_hw *ah)
65
66 debugfs_create_file("eeprom", S_IRUSR, sc->debug.debugfs_phy, sc,
67 &fops_eeprom);
68 + debugfs_create_file("chanbw", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
69 + sc, &fops_chanbw);
70 debugfs_create_file("dma", S_IRUSR, sc->debug.debugfs_phy, sc,
71 &fops_dma);
72 debugfs_create_file("interrupt", S_IRUSR, sc->debug.debugfs_phy, sc,
73 --- a/drivers/net/wireless/ath/ath9k/main.c
74 +++ b/drivers/net/wireless/ath/ath9k/main.c
75 @@ -1200,8 +1200,10 @@ static int ath9k_config(struct ieee80211
76
77 if ((changed & IEEE80211_CONF_CHANGE_CHANNEL) || reset_channel) {
78 struct ieee80211_channel *curchan = hw->conf.chandef.chan;
79 + struct ath9k_channel *hchan;
80 int pos = curchan->hw_value;
81 int old_pos = -1;
82 + u32 oldflags;
83 unsigned long flags;
84
85 if (ah->curchan)
86 @@ -1238,7 +1240,23 @@ static int ath9k_config(struct ieee80211
87 memset(&sc->survey[pos], 0, sizeof(struct survey_info));
88 }
89
90 - if (ath_set_channel(sc, hw, &sc->sc_ah->channels[pos]) < 0) {
91 + hchan = &sc->sc_ah->channels[pos];
92 + oldflags = hchan->channelFlags;
93 + switch (sc->chan_bw) {
94 + case 5:
95 + hchan->channelFlags &= ~CHANNEL_HALF;
96 + hchan->channelFlags |= CHANNEL_QUARTER;
97 + break;
98 + case 10:
99 + hchan->channelFlags &= ~CHANNEL_QUARTER;
100 + hchan->channelFlags |= CHANNEL_HALF;
101 + break;
102 + default:
103 + hchan->channelFlags &= ~(CHANNEL_HALF | CHANNEL_QUARTER);
104 + break;
105 + }
106 +
107 + if (ath_set_channel(sc, hw, hchan) < 0) {
108 ath_err(common, "Unable to set channel\n");
109 mutex_unlock(&sc->mutex);
110 ath9k_ps_restore(sc);