From patchwork Tue Dec 7 09:45:26 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Helmut Schaa X-Patchwork-Id: 382172 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oB79ksRR006796 for ; Tue, 7 Dec 2010 09:46:54 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754170Ab0LGJqx (ORCPT ); Tue, 7 Dec 2010 04:46:53 -0500 Received: from mail-fx0-f46.google.com ([209.85.161.46]:62179 "EHLO mail-fx0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752904Ab0LGJqw (ORCPT ); Tue, 7 Dec 2010 04:46:52 -0500 Received: by fxm20 with SMTP id 20so5139428fxm.19 for ; Tue, 07 Dec 2010 01:46:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer; bh=y4cywdNUR4xCiwxbGotbaEZ71dNbpSJeOjg6vDdKULk=; b=c4rCKjVMuPyXW3LXrnEbUgR86xEWNy4ZDnXw7EJQklK2ubEIAJdml8w/Q28gAeHxbl /hxXCo2fGAbiyR0aiF1ZfXguIfDMZuXoPPYLONK8Ua5HEXwHNSVoE168gxEi+QGOzAP3 heodNntOjuHQ1lw7ZnmZAUTlxm76cg2Ig7s6A= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=PK2JU7MbDSAhxjs7R/qA64lMDR5FjtK5xDv3KOQhW55R7h0oH+QEgoZ6ApSTox5Lds m/Igry7at1MWj/JNRk/0I7W23XHyWvl5KnP0CaiiZQNc9H8g2zHHJI9Aml3KLzJn/Mm4 Yx3NbaptEuhBgjWN3ol8esYDQ7OJT1XEPVK0A= Received: by 10.223.79.65 with SMTP id o1mr6934436fak.145.1291715211409; Tue, 07 Dec 2010 01:46:51 -0800 (PST) Received: from localhost.localdomain (p5495E472.dip.t-dialin.net [84.149.228.114]) by mx.google.com with ESMTPS id f24sm1843831fak.24.2010.12.07.01.46.49 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 07 Dec 2010 01:46:50 -0800 (PST) From: Helmut Schaa To: linux-wireless@vger.kernel.org Cc: Helmut Schaa , Johannes Berg , "Luis R. Rodriguez" Subject: [RFC] cfg80211: Make NL80211_CMD_SET_REG synchronous Date: Tue, 7 Dec 2010 10:45:26 +0100 Message-Id: <1291715126-7652-1-git-send-email-helmut.schaa@googlemail.com> X-Mailer: git-send-email 1.7.1 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Tue, 07 Dec 2010 09:46:55 +0000 (UTC) diff --git a/include/net/regulatory.h b/include/net/regulatory.h index 356d6e3..e58a744 100644 --- a/include/net/regulatory.h +++ b/include/net/regulatory.h @@ -62,6 +62,7 @@ struct regulatory_request { bool intersect; bool processed; enum environment_cap country_ie_env; + struct completion *completion; struct list_head list; }; diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index 56508d4..8e76a63 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -2535,6 +2535,7 @@ static int parse_reg_rule(struct nlattr *tb[], static int nl80211_req_set_reg(struct sk_buff *skb, struct genl_info *info) { + DECLARE_COMPLETION_ONSTACK(completion); int r; char *data = NULL; @@ -2556,7 +2557,9 @@ static int nl80211_req_set_reg(struct sk_buff *skb, struct genl_info *info) data = nla_data(info->attrs[NL80211_ATTR_REG_ALPHA2]); - r = regulatory_hint_user(data); + r = regulatory_hint_user(data, &completion); + + wait_for_completion_interruptible(&completion); return r; } diff --git a/net/wireless/reg.c b/net/wireless/reg.c index 5ed615f..84787e3 100644 --- a/net/wireless/reg.c +++ b/net/wireless/reg.c @@ -1428,6 +1428,7 @@ static void reg_process_hint(struct regulatory_request *reg_request) int r = 0; struct wiphy *wiphy = NULL; enum nl80211_reg_initiator initiator = reg_request->initiator; + struct completion *completion = reg_request->completion; BUG_ON(!reg_request->alpha2); @@ -1437,7 +1438,7 @@ static void reg_process_hint(struct regulatory_request *reg_request) if (reg_request->initiator == NL80211_REGDOM_SET_BY_DRIVER && !wiphy) { kfree(reg_request); - return; + goto out; } r = __regulatory_hint(wiphy, reg_request); @@ -1445,6 +1446,11 @@ static void reg_process_hint(struct regulatory_request *reg_request) if (r == -EALREADY && wiphy && wiphy->flags & WIPHY_FLAG_STRICT_REGULATORY) wiphy_update_regulatory(wiphy, initiator); + +out: + /* Mark this reg request done */ + if (completion) + complete_all(completion); } /* @@ -1571,7 +1577,7 @@ static int regulatory_hint_core(const char *alpha2) } /* User hints */ -int regulatory_hint_user(const char *alpha2) +int regulatory_hint_user(const char *alpha2, struct completion *completion) { struct regulatory_request *request; @@ -1585,6 +1591,7 @@ int regulatory_hint_user(const char *alpha2) request->alpha2[0] = alpha2[0]; request->alpha2[1] = alpha2[1]; request->initiator = NL80211_REGDOM_SET_BY_USER; + request->completion = completion; queue_regulatory_request(request); @@ -1787,7 +1794,7 @@ static void restore_regulatory_settings(bool reset_user) * settings, user regulatory settings takes precedence. */ if (is_an_alpha2(alpha2)) - regulatory_hint_user(user_alpha2); + regulatory_hint_user(user_alpha2, NULL); } @@ -2149,7 +2156,7 @@ int __init regulatory_init(void) * as a user hint. */ if (!is_world_regdom(ieee80211_regdom)) - regulatory_hint_user(ieee80211_regdom); + regulatory_hint_user(ieee80211_regdom, NULL); return 0; } diff --git a/net/wireless/reg.h b/net/wireless/reg.h index c4695d0..8be4d42 100644 --- a/net/wireless/reg.h +++ b/net/wireless/reg.h @@ -6,7 +6,7 @@ extern const struct ieee80211_regdomain *cfg80211_regdomain; bool is_world_regdom(const char *alpha2); bool reg_is_valid_request(const char *alpha2); -int regulatory_hint_user(const char *alpha2); +int regulatory_hint_user(const char *alpha2, struct completion *completion); void reg_device_remove(struct wiphy *wiphy);