diff options
author | Michal Kazior <michal.kazior@tieto.com> | 2012-06-29 12:47:05 +0200 |
---|---|---|
committer | Johannes Berg <johannes.berg@intel.com> | 2012-06-29 13:39:18 +0200 |
commit | a69b40a95b121c4bfc52a20cccd28708ae550af1 (patch) | |
tree | 372d59aee76bdd212d3d4618f4c2342604c8d128 /net/wireless | |
parent | b78e8ceac23655e1e06b30aa95ab11742d1ac7c0 (diff) | |
download | op-kernel-dev-a69b40a95b121c4bfc52a20cccd28708ae550af1.zip op-kernel-dev-a69b40a95b121c4bfc52a20cccd28708ae550af1.tar.gz |
cfg80211: set initial monitor channel
Implements behaviour seen in mac80211. A running
monitor always has a channel - even before
.set_channel. This way we won't break current
behaviour.
Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net/wireless')
-rw-r--r-- | net/wireless/core.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/net/wireless/core.c b/net/wireless/core.c index 1b5daa7..580551e 100644 --- a/net/wireless/core.c +++ b/net/wireless/core.c @@ -717,6 +717,35 @@ static struct device_type wiphy_type = { .name = "wlan", }; +static struct ieee80211_channel * +cfg80211_get_any_chan(struct cfg80211_registered_device *rdev) +{ + struct ieee80211_supported_band *sband; + int i; + + for (i = 0; i < IEEE80211_NUM_BANDS; i++) { + sband = rdev->wiphy.bands[i]; + if (sband && sband->n_channels > 0) + return &sband->channels[0]; + } + + return NULL; +} + +static void cfg80211_init_mon_chan(struct cfg80211_registered_device *rdev) +{ + struct ieee80211_channel *chan; + + chan = cfg80211_get_any_chan(rdev); + if (WARN_ON(!chan)) + return; + + mutex_lock(&rdev->devlist_mtx); + WARN_ON(cfg80211_set_monitor_channel(rdev, chan->center_freq, + NL80211_CHAN_NO_HT)); + mutex_unlock(&rdev->devlist_mtx); +} + void cfg80211_update_iface_num(struct cfg80211_registered_device *rdev, enum nl80211_iftype iftype, int num) { @@ -737,6 +766,8 @@ void cfg80211_update_iface_num(struct cfg80211_registered_device *rdev, if (!has_monitors_only_new) { rdev->monitor_channel = NULL; rdev->monitor_channel_type = NL80211_CHAN_NO_HT; + } else { + cfg80211_init_mon_chan(rdev); } } } |