Commit a69b40a9 authored by Michal Kazior's avatar Michal Kazior Committed by Johannes Berg

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: default avatarMichal Kazior <michal.kazior@tieto.com>
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent b78e8cea
...@@ -717,6 +717,35 @@ static struct device_type wiphy_type = { ...@@ -717,6 +717,35 @@ static struct device_type wiphy_type = {
.name = "wlan", .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, void cfg80211_update_iface_num(struct cfg80211_registered_device *rdev,
enum nl80211_iftype iftype, int num) enum nl80211_iftype iftype, int num)
{ {
...@@ -737,6 +766,8 @@ void cfg80211_update_iface_num(struct cfg80211_registered_device *rdev, ...@@ -737,6 +766,8 @@ void cfg80211_update_iface_num(struct cfg80211_registered_device *rdev,
if (!has_monitors_only_new) { if (!has_monitors_only_new) {
rdev->monitor_channel = NULL; rdev->monitor_channel = NULL;
rdev->monitor_channel_type = NL80211_CHAN_NO_HT; rdev->monitor_channel_type = NL80211_CHAN_NO_HT;
} else {
cfg80211_init_mon_chan(rdev);
} }
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment