From: Luis R. Rodriguez Date: Wed, 12 Nov 2008 22:21:58 +0000 (-0800) Subject: cfg80211: separate intersection section in __set_regdom() X-Git-Tag: v2.6.29-rc1~581^2~383^2~73 X-Git-Url: https://openfabrics.org/gitweb/?a=commitdiff_plain;h=b8295acdc323e6e383ec822fc1e95edeb9148513;p=~emulex%2Finfiniband.git cfg80211: separate intersection section in __set_regdom() So far the __set_regdom() code is pretty generic as the intersection case is fairly straight forward; this will however change when 802.11d support is added so lets separate intersection code for now in preparation for 802.11d support. This patch only has slight functional changes. Signed-off-by: Luis R. Rodriguez Acked-by: Johannes Berg Signed-off-by: John W. Linville --- diff --git a/net/wireless/reg.c b/net/wireless/reg.c index 290ececd4f1..845e2d32663 100644 --- a/net/wireless/reg.c +++ b/net/wireless/reg.c @@ -826,10 +826,6 @@ static int __set_regdom(const struct ieee80211_regdomain *rd) if (WARN_ON(!reg_is_valid_request(rd->alpha2))) return -EINVAL; - reset_regdomains(); - - /* Country IE parsing coming soon */ - if (!is_valid_rd(rd)) { printk(KERN_ERR "cfg80211: Invalid " "regulatory domain detected:\n"); @@ -837,16 +833,33 @@ static int __set_regdom(const struct ieee80211_regdomain *rd) return -EINVAL; } - if (unlikely(last_request->intersect)) { + if (!last_request->intersect) { + reset_regdomains(); + cfg80211_regdomain = rd; + return 0; + } + + /* Intersection requires a bit more work */ + + if (last_request->initiator != REGDOM_SET_BY_COUNTRY_IE) { + intersected_rd = regdom_intersect(rd, cfg80211_regdomain); if (!intersected_rd) return -EINVAL; + + /* We can trash what CRDA provided now */ kfree(rd); - rd = intersected_rd; + rd = NULL; + + reset_regdomains(); + cfg80211_regdomain = intersected_rd; + + return 0; } - /* Tada! */ - cfg80211_regdomain = rd; + /* Country IE parsing coming soon */ + reset_regdomains(); + WARN_ON(1); return 0; }