From patchwork Thu Mar 31 22:31:38 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Rodriguez X-Patchwork-Id: 680261 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 p2VMW7XK029607 for ; Thu, 31 Mar 2011 22:32:07 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759422Ab1CaWcE (ORCPT ); Thu, 31 Mar 2011 18:32:04 -0400 Received: from mail.atheros.com ([12.19.149.2]:57057 "EHLO mail.atheros.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751945Ab1CaWcD (ORCPT ); Thu, 31 Mar 2011 18:32:03 -0400 Received: from mail.atheros.com ([10.10.20.105]) by sidewinder.atheros.com for ; Thu, 31 Mar 2011 15:31:39 -0700 Received: from tux (10.10.10.239) by SC1EXHC-01.global.atheros.com (10.10.20.111) with Microsoft SMTP Server (TLS) id 8.2.213.0; Thu, 31 Mar 2011 15:31:43 -0700 Received: by tux (sSMTP sendmail emulation); Thu, 31 Mar 2011 15:31:39 -0700 From: "Luis R. Rodriguez" To: , CC: , , "Luis R. Rodriguez" Subject: [PATCH] cfg80211: add a timer for invalid user reg hints Date: Thu, 31 Mar 2011 15:31:38 -0700 Message-ID: <1301610698-3688-1-git-send-email-lrodriguez@atheros.com> X-Mailer: git-send-email 1.7.4.15.g7811d MIME-Version: 1.0 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.6 (demeter1.kernel.org [140.211.167.41]); Thu, 31 Mar 2011 22:32:07 +0000 (UTC) diff --git a/net/wireless/reg.c b/net/wireless/reg.c index 3332d5b..62d9ea1 100644 --- a/net/wireless/reg.c +++ b/net/wireless/reg.c @@ -42,6 +42,7 @@ #include #include #include +#include #include #include "core.h" #include "reg.h" @@ -106,6 +107,10 @@ struct reg_beacon { static void reg_todo(struct work_struct *work); static DECLARE_WORK(reg_work, reg_todo); +static struct timer_list reg_timer; +static void reg_timeout_work(struct work_struct *work); +static DECLARE_WORK(reg_timeout, reg_timeout_work); + /* We keep a static world regulatory domain in case of the absence of CRDA */ static const struct ieee80211_regdomain world_regdom = { .n_reg_rules = 5, @@ -1330,6 +1335,9 @@ static void reg_set_request_processed(void) need_more_processing = true; spin_unlock(®_requests_lock); + if (last_request->initiator == NL80211_REGDOM_SET_BY_USER) + del_timer_sync(®_timer); + if (need_more_processing) schedule_work(®_work); } @@ -1584,6 +1592,7 @@ int regulatory_hint_user(const char *alpha2) request->initiator = NL80211_REGDOM_SET_BY_USER; queue_regulatory_request(request); + mod_timer(®_timer, jiffies + msecs_to_jiffies(3142)); return 0; } @@ -1787,7 +1796,6 @@ static void restore_regulatory_settings(bool reset_user) regulatory_hint_user(user_alpha2); } - void regulatory_hint_disconnect(void) { REG_DBG_PRINT("All devices are disconnected, going to " @@ -2125,6 +2133,18 @@ out: mutex_unlock(®_mutex); } +static void reg_timeout_work(struct work_struct *work) +{ + restore_regulatory_settings(true); +} + +static void reg_set_failed_timer(unsigned long data) +{ + REG_DBG_PRINT("Timeout while waiting for CRDA to reply," + "restoring regulatory settings"); + schedule_work(®_timeout); +} + int __init regulatory_init(void) { int err = 0; @@ -2137,6 +2157,7 @@ int __init regulatory_init(void) spin_lock_init(®_requests_lock); spin_lock_init(®_pending_beacons_lock); + setup_timer(®_timer, reg_set_failed_timer, (unsigned long) NULL); cfg80211_regdomain = cfg80211_world_regdom; @@ -2178,6 +2199,8 @@ void /* __init_or_exit */ regulatory_exit(void) struct reg_beacon *reg_beacon, *btmp; cancel_work_sync(®_work); + cancel_work_sync(®_timeout); + del_timer_sync(®_timer); mutex_lock(&cfg80211_mutex); mutex_lock(®_mutex);