From patchwork Sun Feb 1 11:59:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Malcolm Priestley X-Patchwork-Id: 5756621 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id DE8C09F336 for ; Sun, 1 Feb 2015 12:00:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7197120253 for ; Sun, 1 Feb 2015 12:00:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 77B5120218 for ; Sun, 1 Feb 2015 12:00:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752827AbbBAMAO (ORCPT ); Sun, 1 Feb 2015 07:00:14 -0500 Received: from mail-wg0-f41.google.com ([74.125.82.41]:55814 "EHLO mail-wg0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752792AbbBAMAM (ORCPT ); Sun, 1 Feb 2015 07:00:12 -0500 Received: by mail-wg0-f41.google.com with SMTP id a1so34157421wgh.0 for ; Sun, 01 Feb 2015 04:00:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=DeN38PUH5KHhZrntuslQ9hR8ch8LTFc3QFBMpniAirI=; b=gN4CnzpfNz9sknpdu+9L9SIF+qcHixWI+FL2jMKXizKRwR0C6ZtOzB9XKKqaSp/j8S pWn1tIGJCudhHOs/g1j/xGQ2xxUA8JPI2VMznGwpANeUFfJdJIu+ouUlyPR+YCIhTR6c 0uwD2Ugir0GfflUeDBtWJJqPLHmRoMRF8CzZGfu2giyMbhgdKHuJcMonX3CmOgA0OP/a D41BKEbENLdX08w0UnZV0zPXfBGnu1rjgyDiwVCF2b3YXDDxwjbvxRRlzhYopARtnCWi 6TLZuo6G0wKX9B0YWJjtaKOlU8O7GvyvMgKo9DzBH65ONm6eTLAyfgpJiNRY5aYzy+Sg +1UA== X-Received: by 10.194.179.166 with SMTP id dh6mr32370120wjc.87.1422792011018; Sun, 01 Feb 2015 04:00:11 -0800 (PST) Received: from tipsey.3.home (94.196.240.163.threembb.co.uk. [94.196.240.163]) by mx.google.com with ESMTPSA id ud9sm15074446wib.5.2015.02.01.04.00.09 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 01 Feb 2015 04:00:10 -0800 (PST) From: Malcolm Priestley To: gregkh@linuxfoundation.org Cc: linux-wireless@vger.kernel.org, devel@driverdev.osuosl.org, Malcolm Priestley Subject: [PATCH 2/6] staging: vt6655: parse bb vga code out of device_intr. Date: Sun, 1 Feb 2015 11:59:39 +0000 Message-Id: <1422791983-3408-2-git-send-email-tvboxspy@gmail.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1422791983-3408-1-git-send-email-tvboxspy@gmail.com> References: <1422791983-3408-1-git-send-email-tvboxspy@gmail.com> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Reordering the code and reversing the priv->byBBVGANew verses priv->byBBVGACurrent check and using dev_dbg for pr_debug. Signed-off-by: Malcolm Priestley --- drivers/staging/vt6655/device_main.c | 93 +++++++++++++++++++++--------------- 1 file changed, 54 insertions(+), 39 deletions(-) diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index 9a80144..870cafd 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -1008,6 +1008,58 @@ static void device_free_tx_buf(struct vnt_private *pDevice, PSTxDesc pDesc) pTDInfo->byFlags = 0; } +static void vnt_check_bb_vga(struct vnt_private *priv) +{ + long dbm; + int i; + + if (!priv->bUpdateBBVGA) + return; + + if (priv->hw->conf.flags & IEEE80211_CONF_OFFCHANNEL) + return; + + if (!(priv->vif->bss_conf.assoc && priv->uCurrRSSI)) + return; + + RFvRSSITodBm(priv, (u8)priv->uCurrRSSI, &dbm); + + for (i = 0; i < BB_VGA_LEVEL; i++) { + if (dbm < priv->ldBmThreshold[i]) { + priv->byBBVGANew = priv->abyBBVGA[i]; + break; + } + } + + if (priv->byBBVGANew == priv->byBBVGACurrent) { + priv->uBBVGADiffCount = 1; + return; + } + + priv->uBBVGADiffCount++; + + if (priv->uBBVGADiffCount == 1) { + /* first VGA diff gain */ + BBvSetVGAGainOffset(priv, priv->byBBVGANew); + + dev_dbg(&priv->pcid->dev, + "First RSSI[%d] NewGain[%d] OldGain[%d] Count[%d]\n", + (int)dbm, priv->byBBVGANew, + priv->byBBVGACurrent, + (int)priv->uBBVGADiffCount); + } + + if (priv->uBBVGADiffCount >= BB_VGA_CHANGE_THRESHOLD) { + dev_dbg(&priv->pcid->dev, + "RSSI[%d] NewGain[%d] OldGain[%d] Count[%d]\n", + (int)dbm, priv->byBBVGANew, + priv->byBBVGACurrent, + (int)priv->uBBVGADiffCount); + + BBvSetVGAGainOffset(priv, priv->byBBVGANew); + } +} + static irqreturn_t device_intr(int irq, void *dev_instance) { struct vnt_private *pDevice = dev_instance; @@ -1015,7 +1067,6 @@ static irqreturn_t device_intr(int irq, void *dev_instance) unsigned long dwMIBCounter = 0; unsigned char byOrgPageSel = 0; int handled = 0; - int ii = 0; unsigned long flags; MACvReadISR(pDevice->PortOffset, &pDevice->dwIsr); @@ -1059,44 +1110,8 @@ static irqreturn_t device_intr(int irq, void *dev_instance) if (pDevice->dwIsr & ISR_TBTT) { if (pDevice->vif && - pDevice->op_mode != NL80211_IFTYPE_ADHOC) { - if (pDevice->bUpdateBBVGA && - !(pDevice->hw->conf.flags & IEEE80211_CONF_OFFCHANNEL) && - pDevice->vif->bss_conf.assoc && - pDevice->uCurrRSSI) { - long ldBm; - - RFvRSSITodBm(pDevice, (unsigned char) pDevice->uCurrRSSI, &ldBm); - for (ii = 0; ii < BB_VGA_LEVEL; ii++) { - if (ldBm < pDevice->ldBmThreshold[ii]) { - pDevice->byBBVGANew = pDevice->abyBBVGA[ii]; - break; - } - } - if (pDevice->byBBVGANew != pDevice->byBBVGACurrent) { - pDevice->uBBVGADiffCount++; - if (pDevice->uBBVGADiffCount == 1) { - // first VGA diff gain - BBvSetVGAGainOffset(pDevice, pDevice->byBBVGANew); - pr_debug("First RSSI[%d] NewGain[%d] OldGain[%d] Count[%d]\n", - (int)ldBm, - pDevice->byBBVGANew, - pDevice->byBBVGACurrent, - (int)pDevice->uBBVGADiffCount); - } - if (pDevice->uBBVGADiffCount >= BB_VGA_CHANGE_THRESHOLD) { - pr_debug("RSSI[%d] NewGain[%d] OldGain[%d] Count[%d]\n", - (int)ldBm, - pDevice->byBBVGANew, - pDevice->byBBVGACurrent, - (int)pDevice->uBBVGADiffCount); - BBvSetVGAGainOffset(pDevice, pDevice->byBBVGANew); - } - } else { - pDevice->uBBVGADiffCount = 1; - } - } - } + pDevice->op_mode != NL80211_IFTYPE_ADHOC) + vnt_check_bb_vga(pDevice); pDevice->bBeaconSent = false; if (pDevice->bEnablePSMode)