]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - arch/x86/vdso/vclock_gettime.c
Merge branch 'fix/misc' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound-2.6
[mv-sheeva.git] / arch / x86 / vdso / vclock_gettime.c
index 6a40b78b46aafae8273ad7ed12ebbfd44187733a..ee55754cc3c5ff378b76f2065a610b72e757f088 100644 (file)
@@ -86,14 +86,47 @@ notrace static noinline int do_monotonic(struct timespec *ts)
        return 0;
 }
 
+notrace static noinline int do_realtime_coarse(struct timespec *ts)
+{
+       unsigned long seq;
+       do {
+               seq = read_seqbegin(&gtod->lock);
+               ts->tv_sec = gtod->wall_time_coarse.tv_sec;
+               ts->tv_nsec = gtod->wall_time_coarse.tv_nsec;
+       } while (unlikely(read_seqretry(&gtod->lock, seq)));
+       return 0;
+}
+
+notrace static noinline int do_monotonic_coarse(struct timespec *ts)
+{
+       unsigned long seq, ns, secs;
+       do {
+               seq = read_seqbegin(&gtod->lock);
+               secs = gtod->wall_time_coarse.tv_sec;
+               ns = gtod->wall_time_coarse.tv_nsec;
+               secs += gtod->wall_to_monotonic.tv_sec;
+               ns += gtod->wall_to_monotonic.tv_nsec;
+       } while (unlikely(read_seqretry(&gtod->lock, seq)));
+       vset_normalized_timespec(ts, secs, ns);
+       return 0;
+}
+
 notrace int __vdso_clock_gettime(clockid_t clock, struct timespec *ts)
 {
-       if (likely(gtod->sysctl_enabled && gtod->clock.vread))
+       if (likely(gtod->sysctl_enabled))
                switch (clock) {
                case CLOCK_REALTIME:
-                       return do_realtime(ts);
+                       if (likely(gtod->clock.vread))
+                               return do_realtime(ts);
+                       break;
                case CLOCK_MONOTONIC:
-                       return do_monotonic(ts);
+                       if (likely(gtod->clock.vread))
+                               return do_monotonic(ts);
+                       break;
+               case CLOCK_REALTIME_COARSE:
+                       return do_realtime_coarse(ts);
+               case CLOCK_MONOTONIC_COARSE:
+                       return do_monotonic_coarse(ts);
                }
        return vdso_fallback_gettime(clock, ts);
 }