]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
staging: vt6655: CARDqGetNextTBTT calculate qwTSF using do_div
authorMalcolm Priestley <tvboxspy@gmail.com>
Sun, 10 Aug 2014 11:21:59 +0000 (12:21 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 16 Aug 2014 19:23:15 +0000 (12:23 -0700)
Use do_div to compute equation as shown replacing existing code.

Signed-off-by: Malcolm Priestley <tvboxspy@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/vt6655/card.c

index 5295463cb2bde334639dca256a32d40408258023..a5da3d26c36fa6237e6c0c365559af2dcf27e5ae 100644 (file)
@@ -1995,27 +1995,18 @@ bool CARDbGetCurrentTSF(void __iomem *dwIoBase, u64 *pqwCurrTSF)
  */
 u64 CARDqGetNextTBTT(u64 qwTSF, unsigned short wBeaconInterval)
 {
-       unsigned int uLowNextTBTT;
-       unsigned int uHighRemain, uLowRemain;
-       unsigned int uBeaconInterval;
+       u32 beacon_int;
 
-       uBeaconInterval = 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;
+       beacon_int = wBeaconInterval * 1024;
 
-       // 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 (beacon_int) {
+               do_div(qwTSF, beacon_int);
+               qwTSF += 1;
+               qwTSF *= beacon_int;
+       }
 
        return qwTSF;
 }