diff options
Diffstat (limited to 'net/wireless/chan.c')
| -rw-r--r-- | net/wireless/chan.c | 41 |
1 files changed, 27 insertions, 14 deletions
diff --git a/net/wireless/chan.c b/net/wireless/chan.c index a46ac6c9b365..bf1737fc9a7e 100644 --- a/net/wireless/chan.c +++ b/net/wireless/chan.c | |||
| @@ -41,44 +41,57 @@ rdev_fixed_channel(struct cfg80211_registered_device *rdev, | |||
| 41 | return result; | 41 | return result; |
| 42 | } | 42 | } |
| 43 | 43 | ||
| 44 | int rdev_set_freq(struct cfg80211_registered_device *rdev, | 44 | struct ieee80211_channel * |
| 45 | struct wireless_dev *for_wdev, | 45 | rdev_freq_to_chan(struct cfg80211_registered_device *rdev, |
| 46 | int freq, enum nl80211_channel_type channel_type) | 46 | int freq, enum nl80211_channel_type channel_type) |
| 47 | { | 47 | { |
| 48 | struct ieee80211_channel *chan; | 48 | struct ieee80211_channel *chan; |
| 49 | struct ieee80211_sta_ht_cap *ht_cap; | 49 | struct ieee80211_sta_ht_cap *ht_cap; |
| 50 | int result; | ||
| 51 | |||
| 52 | if (rdev_fixed_channel(rdev, for_wdev)) | ||
| 53 | return -EBUSY; | ||
| 54 | |||
| 55 | if (!rdev->ops->set_channel) | ||
| 56 | return -EOPNOTSUPP; | ||
| 57 | 50 | ||
| 58 | chan = ieee80211_get_channel(&rdev->wiphy, freq); | 51 | chan = ieee80211_get_channel(&rdev->wiphy, freq); |
| 59 | 52 | ||
| 60 | /* Primary channel not allowed */ | 53 | /* Primary channel not allowed */ |
| 61 | if (!chan || chan->flags & IEEE80211_CHAN_DISABLED) | 54 | if (!chan || chan->flags & IEEE80211_CHAN_DISABLED) |
| 62 | return -EINVAL; | 55 | return NULL; |
| 63 | 56 | ||
| 64 | if (channel_type == NL80211_CHAN_HT40MINUS && | 57 | if (channel_type == NL80211_CHAN_HT40MINUS && |
| 65 | chan->flags & IEEE80211_CHAN_NO_HT40MINUS) | 58 | chan->flags & IEEE80211_CHAN_NO_HT40MINUS) |
| 66 | return -EINVAL; | 59 | return NULL; |
| 67 | else if (channel_type == NL80211_CHAN_HT40PLUS && | 60 | else if (channel_type == NL80211_CHAN_HT40PLUS && |
| 68 | chan->flags & IEEE80211_CHAN_NO_HT40PLUS) | 61 | chan->flags & IEEE80211_CHAN_NO_HT40PLUS) |
| 69 | return -EINVAL; | 62 | return NULL; |
| 70 | 63 | ||
| 71 | ht_cap = &rdev->wiphy.bands[chan->band]->ht_cap; | 64 | ht_cap = &rdev->wiphy.bands[chan->band]->ht_cap; |
| 72 | 65 | ||
| 73 | if (channel_type != NL80211_CHAN_NO_HT) { | 66 | if (channel_type != NL80211_CHAN_NO_HT) { |
| 74 | if (!ht_cap->ht_supported) | 67 | if (!ht_cap->ht_supported) |
| 75 | return -EINVAL; | 68 | return NULL; |
| 76 | 69 | ||
| 77 | if (!(ht_cap->cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40) || | 70 | if (!(ht_cap->cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40) || |
| 78 | ht_cap->cap & IEEE80211_HT_CAP_40MHZ_INTOLERANT) | 71 | ht_cap->cap & IEEE80211_HT_CAP_40MHZ_INTOLERANT) |
| 79 | return -EINVAL; | 72 | return NULL; |
| 80 | } | 73 | } |
| 81 | 74 | ||
| 75 | return chan; | ||
| 76 | } | ||
| 77 | |||
| 78 | int rdev_set_freq(struct cfg80211_registered_device *rdev, | ||
| 79 | struct wireless_dev *for_wdev, | ||
| 80 | int freq, enum nl80211_channel_type channel_type) | ||
| 81 | { | ||
| 82 | struct ieee80211_channel *chan; | ||
| 83 | int result; | ||
| 84 | |||
| 85 | if (rdev_fixed_channel(rdev, for_wdev)) | ||
| 86 | return -EBUSY; | ||
| 87 | |||
| 88 | if (!rdev->ops->set_channel) | ||
| 89 | return -EOPNOTSUPP; | ||
| 90 | |||
| 91 | chan = rdev_freq_to_chan(rdev, freq, channel_type); | ||
| 92 | if (!chan) | ||
| 93 | return -EINVAL; | ||
| 94 | |||
| 82 | result = rdev->ops->set_channel(&rdev->wiphy, chan, channel_type); | 95 | result = rdev->ops->set_channel(&rdev->wiphy, chan, channel_type); |
| 83 | if (result) | 96 | if (result) |
| 84 | return result; | 97 | return result; |
