Commit 989ae860 authored by Malcolm Priestley's avatar Malcolm Priestley Committed by Greg Kroah-Hartman

staging: vt6655: CARDqGetNextTBTT calculate qwTSF using do_div

Use do_div to compute equation as shown replacing existing code.
Signed-off-by: default avatarMalcolm Priestley <tvboxspy@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 0fc2a76e
...@@ -1995,27 +1995,18 @@ bool CARDbGetCurrentTSF(void __iomem *dwIoBase, u64 *pqwCurrTSF) ...@@ -1995,27 +1995,18 @@ bool CARDbGetCurrentTSF(void __iomem *dwIoBase, u64 *pqwCurrTSF)
*/ */
u64 CARDqGetNextTBTT(u64 qwTSF, unsigned short wBeaconInterval) u64 CARDqGetNextTBTT(u64 qwTSF, unsigned short wBeaconInterval)
{ {
unsigned int uLowNextTBTT; u32 beacon_int;
unsigned int uHighRemain, uLowRemain;
unsigned int uBeaconInterval;
uBeaconInterval = wBeaconInterval * 1024; beacon_int = wBeaconInterval * 1024;
// Next TBTT = ((local_current_TSF / beacon_interval) + 1) * beacon_interval
uLowNextTBTT = ((qwTSF & 0xffffffffULL) >> 10) << 10;
// low dword (mod) bcn
uLowRemain = (uLowNextTBTT) % uBeaconInterval;
// high dword (mod) bcn
uHighRemain = (((0xffffffff % uBeaconInterval) + 1) * (u32)(qwTSF >> 32))
% uBeaconInterval;
uLowRemain = (uHighRemain + uLowRemain) % uBeaconInterval;
uLowRemain = uBeaconInterval - uLowRemain;
// check if carry when add one beacon interval /* Next TBTT =
if ((~uLowNextTBTT) < uLowRemain) * ((local_current_TSF / beacon_interval) + 1) * beacon_interval
qwTSF = ((qwTSF >> 32) + 1) << 32; */
if (beacon_int) {
qwTSF = (qwTSF & 0xffffffff00000000ULL) | do_div(qwTSF, beacon_int);
(u64)(uLowNextTBTT + uLowRemain); qwTSF += 1;
qwTSF *= beacon_int;
}
return qwTSF; return qwTSF;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment