From patchwork Thu Nov 15 14:07:53 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Seth Forshee X-Patchwork-Id: 1749351 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id C696AE0010 for ; Thu, 15 Nov 2012 14:08:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1767942Ab2KOOIW (ORCPT ); Thu, 15 Nov 2012 09:08:22 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:58859 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1767933Ab2KOOIV (ORCPT ); Thu, 15 Nov 2012 09:08:21 -0500 Received: from 64-126-113-183.dyn.everestkc.net ([64.126.113.183] helo=canonical.com) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1TZ07A-0002ef-Ef; Thu, 15 Nov 2012 14:08:20 +0000 From: Seth Forshee To: Arend van Spriel , linux-wireless@vger.kernel.org Cc: "John W. Linville" , "Franky (Zhenhui) Lin" , Brett Rudley , Roland Vossen , Kan Yan , brcm80211-dev-list@broadcom.com, Daniel Wagner , Seth Forshee Subject: [PATCH v2 03/22] brcmsmac: Add helper function for updating txavail count Date: Thu, 15 Nov 2012 08:07:53 -0600 Message-Id: <1352988492-21340-4-git-send-email-seth.forshee@canonical.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1352988492-21340-1-git-send-email-seth.forshee@canonical.com> References: <1352988492-21340-1-git-send-email-seth.forshee@canonical.com> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Use this helper function rather than open-coding the same calculation in multiple places. Signed-off-by: Seth Forshee Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Arend van Spriel --- drivers/net/wireless/brcm80211/brcmsmac/dma.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/brcm80211/brcmsmac/dma.c b/drivers/net/wireless/brcm80211/brcmsmac/dma.c index 5e53305..6444cf1 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/dma.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/dma.c @@ -1264,6 +1264,17 @@ bool dma_rxreset(struct dma_pub *pub) return status == D64_RS0_RS_DISABLED; } +/* Update count of available tx descriptors based on current DMA state */ +static void dma_update_txavail(struct dma_info *di) +{ + /* + * Available space is number of descriptors less the number of + * active descriptors and the number of queued AMPDU frames. + */ + di->dma.txavail = di->ntxd - ntxdactive(di, di->txin, di->txout) - 1; +} + + /* * !! tx entry routine * WARNING: call must check the return value for error. @@ -1325,7 +1336,7 @@ int dma_txfast(struct dma_pub *pub, struct sk_buff *p, bool commit) di->xmtptrbase + I2B(txout, struct dma64desc)); /* tx flow control */ - di->dma.txavail = di->ntxd - ntxdactive(di, di->txin, di->txout) - 1; + dma_update_txavail(di); return 0; @@ -1412,7 +1423,7 @@ struct sk_buff *dma_getnexttxp(struct dma_pub *pub, enum txd_range range) di->txin = i; /* tx flow control */ - di->dma.txavail = di->ntxd - ntxdactive(di, di->txin, di->txout) - 1; + dma_update_txavail(di); return txp;