cfg80211: send regulatory beacon hint events to userspace
[safe/jmp/linux-2.6] / net / wireless / reg.c
index 4af4304..574e217 100644 (file)
@@ -1049,18 +1049,10 @@ static void handle_reg_beacon(struct wiphy *wiphy,
                              unsigned int chan_idx,
                              struct reg_beacon *reg_beacon)
 {
-#ifdef CONFIG_CFG80211_REG_DEBUG
-#define REG_DEBUG_BEACON_FLAG(desc) \
-       printk(KERN_DEBUG "cfg80211: Enabling " desc " on " \
-               "frequency: %d MHz (Ch %d) on %s\n", \
-               reg_beacon->chan.center_freq, \
-               ieee80211_frequency_to_channel(reg_beacon->chan.center_freq), \
-               wiphy_name(wiphy));
-#else
-#define REG_DEBUG_BEACON_FLAG(desc) do {} while (0)
-#endif
        struct ieee80211_supported_band *sband;
        struct ieee80211_channel *chan;
+       bool channel_changed = false;
+       struct ieee80211_channel chan_before;
 
        assert_cfg80211_lock();
 
@@ -1070,20 +1062,28 @@ static void handle_reg_beacon(struct wiphy *wiphy,
        if (likely(chan->center_freq != reg_beacon->chan.center_freq))
                return;
 
+       if (chan->beacon_found)
+               return;
+
+       chan->beacon_found = true;
+
+       chan_before.center_freq = chan->center_freq;
+       chan_before.flags = chan->flags;
+
        if ((chan->flags & IEEE80211_CHAN_PASSIVE_SCAN) &&
            !(chan->orig_flags & IEEE80211_CHAN_PASSIVE_SCAN)) {
                chan->flags &= ~IEEE80211_CHAN_PASSIVE_SCAN;
-               REG_DEBUG_BEACON_FLAG("active scanning");
+               channel_changed = true;
        }
 
        if ((chan->flags & IEEE80211_CHAN_NO_IBSS) &&
            !(chan->orig_flags & IEEE80211_CHAN_NO_IBSS)) {
                chan->flags &= ~IEEE80211_CHAN_NO_IBSS;
-               REG_DEBUG_BEACON_FLAG("beaconing");
+               channel_changed = true;
        }
 
-       chan->beacon_found = true;
-#undef REG_DEBUG_BEACON_FLAG
+       if (channel_changed)
+               nl80211_send_beacon_hint_event(wiphy, &chan_before, chan);
 }
 
 /*