Staging: fbtbt: Replace timespec with ktime_t
[deliverable/linux.git] / drivers / staging / fbtft / fbtft-core.c
index bfbf15c31d0fe90b9ddc91b8d0c71eb1518c38c4..deccb1d9925134665d6e5fdd2d84c3b7507485fa 100644 (file)
@@ -346,8 +346,7 @@ static void fbtft_update_display(struct fbtft_par *par, unsigned start_line,
                                 unsigned end_line)
 {
        size_t offset, len;
-       struct timespec ts_start, ts_end, ts_fps, ts_duration;
-       long fps_ms, fps_us, duration_ms, duration_us;
+       ktime_t ts_start, ts_end;
        long fps, throughput;
        bool timeit = false;
        int ret = 0;
@@ -355,7 +354,7 @@ static void fbtft_update_display(struct fbtft_par *par, unsigned start_line,
        if (unlikely(par->debug & (DEBUG_TIME_FIRST_UPDATE | DEBUG_TIME_EACH_UPDATE))) {
                if ((par->debug & DEBUG_TIME_EACH_UPDATE) ||
                                ((par->debug & DEBUG_TIME_FIRST_UPDATE) && !par->first_update_done)) {
-                       getnstimeofday(&ts_start);
+                       ts_start = ktime_get();
                        timeit = true;
                }
        }
@@ -392,30 +391,21 @@ static void fbtft_update_display(struct fbtft_par *par, unsigned start_line,
                        __func__);
 
        if (unlikely(timeit)) {
-               getnstimeofday(&ts_end);
-               if (par->update_time.tv_nsec == 0 && par->update_time.tv_sec == 0) {
-                       par->update_time.tv_sec = ts_start.tv_sec;
-                       par->update_time.tv_nsec = ts_start.tv_nsec;
-               }
-               ts_fps = timespec_sub(ts_start, par->update_time);
-               par->update_time.tv_sec = ts_start.tv_sec;
-               par->update_time.tv_nsec = ts_start.tv_nsec;
-               fps_ms = (ts_fps.tv_sec * 1000) + ((ts_fps.tv_nsec / 1000000) % 1000);
-               fps_us = (ts_fps.tv_nsec / 1000) % 1000;
-               fps = fps_ms * 1000 + fps_us;
+               ts_end = ktime_get();
+               if (ktime_to_ns(par->update_time))
+                       par->update_time = ts_start;
+
+               par->update_time = ts_start;
+               fps = ktime_us_delta(ts_start, par->update_time);
                fps = fps ? 1000000 / fps : 0;
 
-               ts_duration = timespec_sub(ts_end, ts_start);
-               duration_ms = (ts_duration.tv_sec * 1000) + ((ts_duration.tv_nsec / 1000000) % 1000);
-               duration_us = (ts_duration.tv_nsec / 1000) % 1000;
-               throughput = duration_ms * 1000 + duration_us;
+               throughput = ktime_us_delta(ts_end, ts_start);
                throughput = throughput ? (len * 1000) / throughput : 0;
                throughput = throughput * 1000 / 1024;
 
                dev_info(par->info->device,
-                       "Display update: %ld kB/s (%ld.%.3ld ms), fps=%ld (%ld.%.3ld ms)\n",
-                       throughput, duration_ms, duration_us,
-                       fps, fps_ms, fps_us);
+                       "Display update: %ld kB/s, fps=%ld\n",
+                       throughput, fps);
                par->first_update_done = true;
        }
 }
This page took 0.050586 seconds and 5 git commands to generate.