diff options
author | Johannes Berg <johannes.berg@intel.com> | 2012-11-08 15:25:48 -0500 |
---|---|---|
committer | Johannes Berg <johannes.berg@intel.com> | 2012-11-26 06:42:58 -0500 |
commit | 683b6d3b31a51956ea540df00abb0b78894924c1 (patch) | |
tree | 558e0f316b56368ab259755cb4eeaeb40331853d /net/wireless/chan.c | |
parent | fe4b31810c06cc6518fb193efb9b3c3289b55832 (diff) |
cfg80211: pass a channel definition struct
Instead of passing a channel pointer and channel type
to all functions and driver methods, pass a new channel
definition struct. Right now, this struct contains just
the control channel and channel type, but for VHT this
will change.
Also, add a small inline cfg80211_get_chandef_type() so
that drivers don't need to use the _type field of the
new structure all the time, which will change.
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net/wireless/chan.c')
-rw-r--r-- | net/wireless/chan.c | 59 |
1 files changed, 9 insertions, 50 deletions
diff --git a/net/wireless/chan.c b/net/wireless/chan.c index 48febd2160ba..e834422de40a 100644 --- a/net/wireless/chan.c +++ b/net/wireless/chan.c | |||
@@ -11,51 +11,15 @@ | |||
11 | #include "core.h" | 11 | #include "core.h" |
12 | #include "rdev-ops.h" | 12 | #include "rdev-ops.h" |
13 | 13 | ||
14 | struct ieee80211_channel * | 14 | bool cfg80211_reg_can_beacon(struct wiphy *wiphy, |
15 | rdev_freq_to_chan(struct cfg80211_registered_device *rdev, | 15 | struct cfg80211_chan_def *chandef) |
16 | int freq, enum nl80211_channel_type channel_type) | ||
17 | { | ||
18 | struct ieee80211_channel *chan; | ||
19 | struct ieee80211_sta_ht_cap *ht_cap; | ||
20 | |||
21 | chan = ieee80211_get_channel(&rdev->wiphy, freq); | ||
22 | |||
23 | /* Primary channel not allowed */ | ||
24 | if (!chan || chan->flags & IEEE80211_CHAN_DISABLED) | ||
25 | return NULL; | ||
26 | |||
27 | if (channel_type == NL80211_CHAN_HT40MINUS && | ||
28 | chan->flags & IEEE80211_CHAN_NO_HT40MINUS) | ||
29 | return NULL; | ||
30 | else if (channel_type == NL80211_CHAN_HT40PLUS && | ||
31 | chan->flags & IEEE80211_CHAN_NO_HT40PLUS) | ||
32 | return NULL; | ||
33 | |||
34 | ht_cap = &rdev->wiphy.bands[chan->band]->ht_cap; | ||
35 | |||
36 | if (channel_type != NL80211_CHAN_NO_HT) { | ||
37 | if (!ht_cap->ht_supported) | ||
38 | return NULL; | ||
39 | |||
40 | if (channel_type != NL80211_CHAN_HT20 && | ||
41 | (!(ht_cap->cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40) || | ||
42 | ht_cap->cap & IEEE80211_HT_CAP_40MHZ_INTOLERANT)) | ||
43 | return NULL; | ||
44 | } | ||
45 | |||
46 | return chan; | ||
47 | } | ||
48 | |||
49 | bool cfg80211_can_beacon_sec_chan(struct wiphy *wiphy, | ||
50 | struct ieee80211_channel *chan, | ||
51 | enum nl80211_channel_type channel_type) | ||
52 | { | 16 | { |
53 | struct ieee80211_channel *sec_chan; | 17 | struct ieee80211_channel *sec_chan; |
54 | int diff; | 18 | int diff; |
55 | 19 | ||
56 | trace_cfg80211_can_beacon_sec_chan(wiphy, chan, channel_type); | 20 | trace_cfg80211_reg_can_beacon(wiphy, chandef); |
57 | 21 | ||
58 | switch (channel_type) { | 22 | switch (chandef->_type) { |
59 | case NL80211_CHAN_HT40PLUS: | 23 | case NL80211_CHAN_HT40PLUS: |
60 | diff = 20; | 24 | diff = 20; |
61 | break; | 25 | break; |
@@ -67,7 +31,8 @@ bool cfg80211_can_beacon_sec_chan(struct wiphy *wiphy, | |||
67 | return true; | 31 | return true; |
68 | } | 32 | } |
69 | 33 | ||
70 | sec_chan = ieee80211_get_channel(wiphy, chan->center_freq + diff); | 34 | sec_chan = ieee80211_get_channel(wiphy, |
35 | chandef->chan->center_freq + diff); | ||
71 | if (!sec_chan) { | 36 | if (!sec_chan) { |
72 | trace_cfg80211_return_bool(false); | 37 | trace_cfg80211_return_bool(false); |
73 | return false; | 38 | return false; |
@@ -84,23 +49,17 @@ bool cfg80211_can_beacon_sec_chan(struct wiphy *wiphy, | |||
84 | trace_cfg80211_return_bool(true); | 49 | trace_cfg80211_return_bool(true); |
85 | return true; | 50 | return true; |
86 | } | 51 | } |
87 | EXPORT_SYMBOL(cfg80211_can_beacon_sec_chan); | 52 | EXPORT_SYMBOL(cfg80211_reg_can_beacon); |
88 | 53 | ||
89 | int cfg80211_set_monitor_channel(struct cfg80211_registered_device *rdev, | 54 | int cfg80211_set_monitor_channel(struct cfg80211_registered_device *rdev, |
90 | int freq, enum nl80211_channel_type chantype) | 55 | struct cfg80211_chan_def *chandef) |
91 | { | 56 | { |
92 | struct ieee80211_channel *chan; | ||
93 | |||
94 | if (!rdev->ops->set_monitor_channel) | 57 | if (!rdev->ops->set_monitor_channel) |
95 | return -EOPNOTSUPP; | 58 | return -EOPNOTSUPP; |
96 | if (!cfg80211_has_monitors_only(rdev)) | 59 | if (!cfg80211_has_monitors_only(rdev)) |
97 | return -EBUSY; | 60 | return -EBUSY; |
98 | 61 | ||
99 | chan = rdev_freq_to_chan(rdev, freq, chantype); | 62 | return rdev_set_monitor_channel(rdev, chandef); |
100 | if (!chan) | ||
101 | return -EINVAL; | ||
102 | |||
103 | return rdev_set_monitor_channel(rdev, chan, chantype); | ||
104 | } | 63 | } |
105 | 64 | ||
106 | void | 65 | void |