From patchwork Wed Jan 1 19:20:40 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Malcolm Priestley X-Patchwork-Id: 3423321 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 841509F295 for ; Wed, 1 Jan 2014 19:21:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C335B20121 for ; Wed, 1 Jan 2014 19:21:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8D03020120 for ; Wed, 1 Jan 2014 19:21:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754629AbaAATVH (ORCPT ); Wed, 1 Jan 2014 14:21:07 -0500 Received: from mail-wg0-f52.google.com ([74.125.82.52]:42861 "EHLO mail-wg0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752978AbaAATVH (ORCPT ); Wed, 1 Jan 2014 14:21:07 -0500 Received: by mail-wg0-f52.google.com with SMTP id x13so11968851wgg.7 for ; Wed, 01 Jan 2014 11:21:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:subject:from:to:cc:date:content-type:mime-version :content-transfer-encoding; bh=an1t/ODSpCn1GwiCXSRMhzozsaG4cZXBAtgRjWnUsIc=; b=xl09YfiAWM6Jr6wtJAlHaVqdMb5TEjwK7uVDqSs2Lcz1VFoLx/M0Nm+ElMTE2u/947 gkz2ktQGKFmDeYwuZkYRx8omP7LXb9QQTm/FQaJtnXDxMN5Qt+BzjQPo8OkSiHu7Iv9v PfcHXwL7OMWZ+MrO16XS2MTcFktV2YcLsQ5QIa3dTZo79v8hj+3VUDDnjoPMa/jnPdJy vborcw4rwKQDzethyEJBq0qf5nKefqU49ucFGXc/Fi8pSVeLUCEGLsaJ+rrZVtQINlhq OJV/GyOIIY/A/pyUWXysS+5jwvzMPlj2DVS0bHY1fMzHCz79NbHgSsmH0Di8JCznY4Co G0vw== X-Received: by 10.194.48.74 with SMTP id j10mr29143190wjn.41.1388604065826; Wed, 01 Jan 2014 11:21:05 -0800 (PST) Received: from [192.168.1.100] (92.40.113.40.threembb.co.uk. [92.40.113.40]) by mx.google.com with ESMTPSA id ci4sm31091071wjc.21.2014.01.01.11.21.04 for (version=SSLv3 cipher=RC4-SHA bits=128/128); Wed, 01 Jan 2014 11:21:05 -0800 (PST) Message-ID: <1388604040.29916.6.camel@canaries32-MCP7A> Subject: [PATCH 2/2] staging: vt6656: CARDqGetNextTBTT replace code using do_div. From: Malcolm Priestley To: gregkh@linuxfoundation.org Cc: linux-wireless@vger.kernel.org Date: Wed, 01 Jan 2014 19:20:40 +0000 X-Mailer: Evolution 3.10.1-2ubuntu2 Mime-Version: 1.0 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.9 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 uBeaconInterval becomes u32 get next TBTT value using vendor's equation as shown. This patch was checked against the original code and yields exactly the same value. Signed-off-by: Malcolm Priestley --- drivers/staging/vt6656/card.c | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/drivers/staging/vt6656/card.c b/drivers/staging/vt6656/card.c index ce7ee45..0d87728 100644 --- a/drivers/staging/vt6656/card.c +++ b/drivers/staging/vt6656/card.c @@ -720,28 +720,20 @@ bool CARDbClearCurrentTSF(struct vnt_private *pDevice) */ u64 CARDqGetNextTBTT(u64 qwTSF, u16 wBeaconInterval) { + u32 uBeaconInterval; - unsigned int uLowNextTBTT; - unsigned int uHighRemain, uLowRemain; - unsigned int uBeaconInterval; + uBeaconInterval = wBeaconInterval * 1024; - uBeaconInterval = wBeaconInterval * 1024; - // Next TBTT = ((local_current_TSF / beacon_interval) + 1 ) * beacon_interval - uLowNextTBTT = ((qwTSF & 0xffffffffULL) >> 10) << 10; - uLowRemain = (uLowNextTBTT) % uBeaconInterval; - uHighRemain = ((0x80000000 % uBeaconInterval) * 2 * (u32)(qwTSF >> 32)) - % uBeaconInterval; - uLowRemain = (uHighRemain + uLowRemain) % uBeaconInterval; - uLowRemain = uBeaconInterval - uLowRemain; - - // check if carry when add one beacon interval - if ((~uLowNextTBTT) < uLowRemain) - qwTSF = ((qwTSF >> 32) + 1) << 32; - - qwTSF = (qwTSF & 0xffffffff00000000ULL) | - (u64)(uLowNextTBTT + uLowRemain); + /* Next TBTT = + * ((local_current_TSF / beacon_interval) + 1) * beacon_interval + */ + if (uBeaconInterval) { + do_div(qwTSF, uBeaconInterval); + qwTSF += 1; + qwTSF *= uBeaconInterval; + } - return (qwTSF); + return qwTSF; } /*