Return-path: Received: from mail-pb0-f46.google.com ([209.85.160.46]:52872 "EHLO mail-pb0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756358Ab2LMSwL (ORCPT ); Thu, 13 Dec 2012 13:52:11 -0500 Received: by mail-pb0-f46.google.com with SMTP id wy7so1756244pbc.19 for ; Thu, 13 Dec 2012 10:52:11 -0800 (PST) From: Marco Porsch To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, devel@lists.open80211s.org, Marco Porsch Subject: [PATCH 3/6] mac80211: move add_tim to subfunction Date: Thu, 13 Dec 2012 10:51:55 -0800 Message-Id: <1355424718-2982-4-git-send-email-marco@cozybit.com> (sfid-20121213_195219_338321_227CE1B4) In-Reply-To: <1355424718-2982-1-git-send-email-marco@cozybit.com> References: <1355424718-2982-1-git-send-email-marco@cozybit.com> Sender: linux-wireless-owner@vger.kernel.org List-ID: This functions will be used for mesh beacons, too. Signed-off-by: Marco Porsch --- net/mac80211/tx.c | 48 +++++++++++++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 19 deletions(-) diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index e9eadc4..1b04984 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c @@ -2261,9 +2261,9 @@ void ieee80211_tx_pending(unsigned long data) /* functions for drivers to get certain frames */ -static void ieee80211_beacon_add_tim(struct ieee80211_sub_if_data *sdata, - struct ps_data *ps, - struct sk_buff *skb) +static void __ieee80211_beacon_add_tim(struct ieee80211_sub_if_data *sdata, + struct ps_data *ps, + struct sk_buff *skb) { u8 *pos, *tim; int aid0 = 0; @@ -2325,6 +2325,31 @@ static void ieee80211_beacon_add_tim(struct ieee80211_sub_if_data *sdata, } } +static int ieee80211_beacon_add_tim(struct ieee80211_sub_if_data *sdata, + struct ps_data *ps, + struct sk_buff *skb) +{ + struct ieee80211_local *local = sdata->local; + + /* Not very nice, but we want to allow the driver to call + * ieee80211_beacon_get() as a response to the set_tim() callback. + * That, however, is already invoked under the sta_lock to guarantee + * consistent and race-free update of the tim bitmap in mac80211 and + * the driver. + */ + if (local->tim_in_locked_section) { + __ieee80211_beacon_add_tim(sdata, ps, skb); + } else { + unsigned long flags; + + spin_lock_irqsave(&local->tim_lock, flags); + __ieee80211_beacon_add_tim(sdata, ps, skb); + spin_unlock_irqrestore(&local->tim_lock, flags); + } + + return 0; +} + struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw, struct ieee80211_vif *vif, u16 *tim_offset, u16 *tim_length) @@ -2369,22 +2394,7 @@ struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw, memcpy(skb_put(skb, beacon->head_len), beacon->head, beacon->head_len); - /* - * Not very nice, but we want to allow the driver to call - * ieee80211_beacon_get() as a response to the set_tim() - * callback. That, however, is already invoked under the - * sta_lock to guarantee consistent and race-free update - * of the tim bitmap in mac80211 and the driver. - */ - if (local->tim_in_locked_section) { - ieee80211_beacon_add_tim(sdata, &ap->ps, skb); - } else { - unsigned long flags; - - spin_lock_irqsave(&local->tim_lock, flags); - ieee80211_beacon_add_tim(sdata, &ap->ps, skb); - spin_unlock_irqrestore(&local->tim_lock, flags); - } + ieee80211_beacon_add_tim(sdata, &ap->ps, skb); if (tim_offset) *tim_offset = beacon->head_len; -- 1.7.9.5