Say N.
 
+config CFG80211_DEVELOPER_WARNINGS
+       bool "enable developer warnings"
+       depends on CFG80211
+       default n
+       help
+         This option enables some additional warnings that help
+         cfg80211 developers and driver developers, but that can
+         trigger due to races with userspace.
+
+         For example, when a driver reports that it was disconnected
+         from the AP, but the user disconnects manually at the same
+         time, the warning might trigger spuriously due to races.
+
+         Say Y only if you are developing cfg80211 or a driver based
+         on it (or mac80211).
+
+
 config CFG80211_REG_DEBUG
        bool "cfg80211 regulatory debugging"
        depends on CFG80211
 
                  struct wireless_dev *for_wdev,
                  int freq, enum nl80211_channel_type channel_type);
 
+#ifdef CONFIG_CFG80211_DEVELOPER_WARNINGS
+#define CFG80211_DEV_WARN_ON(cond)     WARN_ON(cond)
+#else
+/*
+ * Trick to enable using it as a condition,
+ * and also not give a warning when it's
+ * not used that way.
+ */
+#define CFG80211_DEV_WARN_ON(cond)     ({bool __r = (cond); __r; })
+#endif
+
 #endif /* __NET_WIRELESS_CORE_H */
 
        if (WARN_ON(wdev->iftype != NL80211_IFTYPE_ADHOC))
                return;
 
-       if (WARN_ON(!wdev->ssid_len))
+       if (!wdev->ssid_len)
                return;
 
        bss = cfg80211_get_bss(wdev->wiphy, NULL, bssid,
        struct cfg80211_event *ev;
        unsigned long flags;
 
+       CFG80211_DEV_WARN_ON(!wdev->ssid_len);
+
        ev = kzalloc(sizeof(*ev), gfp);
        if (!ev)
                return;
 
        if (WARN_ON(wdev->iftype != NL80211_IFTYPE_STATION))
                return;
 
-       if (WARN_ON(wdev->sme_state != CFG80211_SME_CONNECTING))
+       if (wdev->sme_state != CFG80211_SME_CONNECTING)
                return;
 
        nl80211_send_connect_result(wiphy_to_dev(wdev->wiphy), dev,
        struct cfg80211_event *ev;
        unsigned long flags;
 
+       CFG80211_DEV_WARN_ON(wdev->sme_state != CFG80211_SME_CONNECTING);
+
        ev = kzalloc(sizeof(*ev) + req_ie_len + resp_ie_len, gfp);
        if (!ev)
                return;
        if (WARN_ON(wdev->iftype != NL80211_IFTYPE_STATION))
                return;
 
-       if (WARN_ON(wdev->sme_state != CFG80211_SME_CONNECTED))
+       if (wdev->sme_state != CFG80211_SME_CONNECTED)
                return;
 
        /* internal error -- how did we get to CONNECTED w/o BSS? */
        struct cfg80211_event *ev;
        unsigned long flags;
 
+       CFG80211_DEV_WARN_ON(wdev->sme_state != CFG80211_SME_CONNECTED);
+
        ev = kzalloc(sizeof(*ev) + req_ie_len + resp_ie_len, gfp);
        if (!ev)
                return;
        if (WARN_ON(wdev->iftype != NL80211_IFTYPE_STATION))
                return;
 
-       if (WARN_ON(wdev->sme_state != CFG80211_SME_CONNECTED))
+       if (wdev->sme_state != CFG80211_SME_CONNECTED)
                return;
 
        if (wdev->current_bss) {
        struct cfg80211_event *ev;
        unsigned long flags;
 
+       CFG80211_DEV_WARN_ON(wdev->sme_state != CFG80211_SME_CONNECTED);
+
        ev = kzalloc(sizeof(*ev) + ie_len, gfp);
        if (!ev)
                return;