rewrite the device subsystem interfaces (#48)
[lunaix-os.git] / lunaix-os / kernel / time / clock.c
index 2bf61d4f48700fed442252b8a694c51c15598405..a5b9dd838a6a04e119f3ef28a082d0ddec455d5e 100644 (file)
@@ -19,12 +19,8 @@ __clock_read_datetime(struct twimap* map)
     clock_walltime(&dt);
     twimap_printf(map,
                   "%.4d-%.2d-%.2d %.2d:%.2d:%.2d",
-                  dt.year,
-                  dt.month,
-                  dt.day,
-                  dt.hour,
-                  dt.minute,
-                  dt.second);
+                  dt.year, dt.month, dt.day,
+                  dt.hour, dt.minute, dt.second);
 }
 
 void
@@ -67,26 +63,16 @@ clock_systime()
 
     ticks_t t = hwtimer_current_systicks();
     ticks_t tu = systimer->running_freq / 1000;
-    return t / (tu + 1);
-}
 
-void
-clock_walltime(datetime_t* datetime)
-{
-    sysrtc->get_walltime(sysrtc, datetime);
+    if (unlikely(!tu)) {
+        return t;
+    }
+
+    return t / (tu);
 }
 
 void
-clock_init()
+clock_walltime(datetime_t* datetime)
 {
-    int idx = 0;
-    struct device_def* pos;
-    foreach_exported_device_of(load_timedev, idx, pos)
-    {
-        if (pos->class.device != DEV_RTC) {
-            continue;
-        }
-
-        pos->init(pos);
-    }
+    sysrtc->ops->get_walltime(sysrtc, datetime);
 }
\ No newline at end of file