From patchwork Wed Aug 12 14:52:01 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kalle Valo X-Patchwork-Id: 40883 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n7CEqXbB030049 for ; Wed, 12 Aug 2009 14:52:34 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753220AbZHLOwa (ORCPT ); Wed, 12 Aug 2009 10:52:30 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752981AbZHLOwa (ORCPT ); Wed, 12 Aug 2009 10:52:30 -0400 Received: from smtp.nokia.com ([192.100.122.233]:46859 "EHLO mgw-mx06.nokia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752735AbZHLOw3 (ORCPT ); Wed, 12 Aug 2009 10:52:29 -0400 Received: from vaebh105.NOE.Nokia.com (vaebh105.europe.nokia.com [10.160.244.31]) by mgw-mx06.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id n7CEpl4U027124; Wed, 12 Aug 2009 17:52:05 +0300 Received: from esebh102.NOE.Nokia.com ([172.21.138.183]) by vaebh105.NOE.Nokia.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 12 Aug 2009 17:52:07 +0300 Received: from mgw-da02.ext.nokia.com ([147.243.128.26]) by esebh102.NOE.Nokia.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959); Wed, 12 Aug 2009 17:52:05 +0300 Received: from [127.0.1.1] (essapo-nirac25247.europe.nokia.com [10.162.252.47]) by mgw-da02.ext.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id n7CEpvJf004461; Wed, 12 Aug 2009 17:51:57 +0300 From: Kalle Valo Subject: [PATCH 1/3] mac80211: refactor dynamic power save check To: linville@tuxdriver.com Cc: johannes@sipsolutions.net, linux-wireless@vger.kernel.org Date: Wed, 12 Aug 2009 17:52:01 +0300 Message-ID: <20090812145200.23691.17281.stgit@tikku> User-Agent: StGIT/0.14.2 MIME-Version: 1.0 X-OriginalArrivalTime: 12 Aug 2009 14:52:06.0342 (UTC) FILETIME=[75F51E60:01CA1B5C] X-Nokia-AV: Clean Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Kalle Valo Refactor dynamic power save checks to a function of it's own for better readibility. No functional changes. Signed-off-by: Kalle Valo --- net/mac80211/tx.c | 24 +++++++++++++++++++++--- 1 files changed, 21 insertions(+), 3 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index 10a1099..03005f9 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c @@ -1384,6 +1384,26 @@ static int ieee80211_skb_resize(struct ieee80211_local *local, return 0; } +static bool is_dynamic_ps_enabled(struct ieee80211_local *local) +{ + if (!(local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK)) + /* driver doesn't support power save */ + return false; + + if (local->hw.conf.dynamic_ps_timeout <= 0) + /* dynamic power save disabled */ + return false; + + if (local->scanning) + /* we are scanning, don't enable power save */ + return false; + + if (!local->ps_sdata) + return false; + + return true; +} + static void ieee80211_xmit(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb) { @@ -1396,9 +1416,7 @@ static void ieee80211_xmit(struct ieee80211_sub_if_data *sdata, dev_hold(sdata->dev); - if ((local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK) && - local->hw.conf.dynamic_ps_timeout > 0 && - !(local->scanning) && local->ps_sdata) { + if (is_dynamic_ps_enabled(local)) { if (local->hw.conf.flags & IEEE80211_CONF_PS) { ieee80211_stop_queues_by_reason(&local->hw, IEEE80211_QUEUE_STOP_REASON_PS);