mac80211: update to wireless-testing 2016-01-10
[openwrt.git] / package / kernel / mac80211 / patches / 512-ath9k_channelbw_debugfs.patch
1 --- a/drivers/net/wireless/ath/ath9k/debug.c
2 +++ b/drivers/net/wireless/ath/ath9k/debug.c
3 @@ -1348,6 +1348,52 @@ static const struct file_operations fops
4         .owner = THIS_MODULE
5  };
6  
7 +
8 +static ssize_t read_file_chan_bw(struct file *file, char __user *user_buf,
9 +                            size_t count, loff_t *ppos)
10 +{
11 +       struct ath_softc *sc = file->private_data;
12 +       struct ath_common *common = ath9k_hw_common(sc->sc_ah);
13 +       char buf[32];
14 +       unsigned int len;
15 +
16 +       len = sprintf(buf, "0x%08x\n", common->chan_bw);
17 +       return simple_read_from_buffer(user_buf, count, ppos, buf, len);
18 +}
19 +
20 +static ssize_t write_file_chan_bw(struct file *file, const char __user *user_buf,
21 +                            size_t count, loff_t *ppos)
22 +{
23 +       struct ath_softc *sc = file->private_data;
24 +       struct ath_common *common = ath9k_hw_common(sc->sc_ah);
25 +       unsigned long chan_bw;
26 +       char buf[32];
27 +       ssize_t len;
28 +
29 +       len = min(count, sizeof(buf) - 1);
30 +       if (copy_from_user(buf, user_buf, len))
31 +               return -EFAULT;
32 +
33 +       buf[len] = '\0';
34 +       if (kstrtoul(buf, 0, &chan_bw))
35 +               return -EINVAL;
36 +
37 +       common->chan_bw = chan_bw;
38 +       if (!test_bit(ATH_OP_INVALID, &common->op_flags))
39 +               ath9k_ops.config(sc->hw, IEEE80211_CONF_CHANGE_CHANNEL);
40 +
41 +       return count;
42 +}
43 +
44 +static const struct file_operations fops_chanbw = {
45 +       .read = read_file_chan_bw,
46 +       .write = write_file_chan_bw,
47 +       .open = simple_open,
48 +       .owner = THIS_MODULE,
49 +       .llseek = default_llseek,
50 +};
51 +
52 +
53  int ath9k_init_debug(struct ath_hw *ah)
54  {
55         struct ath_common *common = ath9k_hw_common(ah);
56 @@ -1369,6 +1415,8 @@ int ath9k_init_debug(struct ath_hw *ah)
57  
58         debugfs_create_file("eeprom", S_IRUSR, sc->debug.debugfs_phy, sc,
59                             &fops_eeprom);
60 +       debugfs_create_file("chanbw", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
61 +                           sc, &fops_chanbw);
62         debugfs_create_devm_seqfile(sc->dev, "dma", sc->debug.debugfs_phy,
63                                     read_file_dma);
64         debugfs_create_devm_seqfile(sc->dev, "interrupt", sc->debug.debugfs_phy,
65 --- a/drivers/net/wireless/ath/ath.h
66 +++ b/drivers/net/wireless/ath/ath.h
67 @@ -151,6 +151,7 @@ struct ath_common {
68         int debug_mask;
69         enum ath_device_state state;
70         unsigned long op_flags;
71 +       u32 chan_bw;
72  
73         struct ath_ani ani;
74  
75 --- a/drivers/net/wireless/ath/ath9k/common.c
76 +++ b/drivers/net/wireless/ath/ath9k/common.c
77 @@ -296,11 +296,13 @@ EXPORT_SYMBOL(ath9k_cmn_get_hw_crypto_ke
78  /*
79   * Update internal channel flags.
80   */
81 -static void ath9k_cmn_update_ichannel(struct ath9k_channel *ichan,
82 +static void ath9k_cmn_update_ichannel(struct ath_common *common,
83 +                                     struct ath9k_channel *ichan,
84                                       struct cfg80211_chan_def *chandef)
85  {
86         struct ieee80211_channel *chan = chandef->chan;
87         u16 flags = 0;
88 +       int width;
89  
90         ichan->channel = chan->center_freq;
91         ichan->chan = chan;
92 @@ -308,7 +310,19 @@ static void ath9k_cmn_update_ichannel(st
93         if (chan->band == IEEE80211_BAND_5GHZ)
94                 flags |= CHANNEL_5GHZ;
95  
96 -       switch (chandef->width) {
97 +       switch (common->chan_bw) {
98 +       case 5:
99 +               width = NL80211_CHAN_WIDTH_5;
100 +               break;
101 +       case 10:
102 +               width = NL80211_CHAN_WIDTH_10;
103 +               break;
104 +       default:
105 +               width = chandef->width;
106 +               break;
107 +       }
108 +
109 +       switch (width) {
110         case NL80211_CHAN_WIDTH_5:
111                 flags |= CHANNEL_QUARTER;
112                 break;
113 @@ -341,10 +355,11 @@ struct ath9k_channel *ath9k_cmn_get_chan
114                                             struct cfg80211_chan_def *chandef)
115  {
116         struct ieee80211_channel *curchan = chandef->chan;
117 +       struct ath_common *common = ath9k_hw_common(ah);
118         struct ath9k_channel *channel;
119  
120         channel = &ah->channels[curchan->hw_value];
121 -       ath9k_cmn_update_ichannel(channel, chandef);
122 +       ath9k_cmn_update_ichannel(common, channel, chandef);
123  
124         return channel;
125  }