Kernel: Fix counting of individual seconds with CONFIG_RTC_INTERVAL
authorWill Sowerbutts <will@sowerbutts.com>
Sun, 22 Jan 2017 22:44:43 +0000 (22:44 +0000)
committerWill Sowerbutts <will@sowerbutts.com>
Sun, 22 Jan 2017 22:44:43 +0000 (22:44 +0000)
Kernel/timer.c

index eda5c3e..4308f3f 100644 (file)
@@ -88,8 +88,14 @@ void updatetod(void)
 #ifdef CONFIG_RTC_INTERVAL
        /* on some platforms reading the RTC is expensive so we don't do it
           every decisecond. */
-       if(++tod_deci != CONFIG_RTC_INTERVAL)
+       if(++tod_deci != CONFIG_RTC_INTERVAL){
+            if(!(tod_deci % 10)){ /* we still need to count each second */
+                rtcsec++;
+                slide=1;
+                goto addtod;
+            }
            return;
+        }
        tod_deci = 0;
 #endif
 
@@ -98,12 +104,13 @@ void updatetod(void)
        if (rtcnew == rtcsec)
                return;
        slide = rtcnew - rtcsec;        /* Seconds elapsed */
+       rtcsec = rtcnew;
+addtod:
        if (slide < 0)
                slide += 60;            /* Seconds wrapped */
        tod.low += slide;
        if (tod.low < slide)            /* 32bit wrap ? */
                tod.high++;
-       rtcsec = rtcnew;
 }
 
 void inittod(void)