diff options
author | Malcolm Priestley <tvboxspy@gmail.com> | 2014-01-01 19:20:40 +0000 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-01-08 11:02:13 -0800 |
commit | 6e28024e1690bd68e7d19af3c96a1617b08c16ac (patch) | |
tree | 3cd1ae16a307a194777e2cdc6f66aa93633ee555 | |
parent | 9acec059c0cef0bf086c738f4c0b1f4447782a48 (diff) |
staging: vt6656: CARDqGetNextTBTT replace code using do_div.
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 <tvboxspy@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/staging/vt6656/card.c | 30 |
1 files changed, 11 insertions, 19 deletions
diff --git a/drivers/staging/vt6656/card.c b/drivers/staging/vt6656/card.c index ce7ee45d308..0d8772858f0 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; } /* |