lkml.org 
[lkml]   [2018]   [Jul]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] staging: gasket remove current_kernel_time usage
Date
A new user of the deprecated current_kernel_time() function has appeared
here. This code won't work correct during leap seconds or a concurrent
settimeofday() call, and it probably doesn't do what the author intended
even for the normal case, as it passes a timeout in nanoseconds but
reads the time using a jiffies-granularity accessor.

I'm changing it to ktime_get_ns() here, which simplifies the logic,
and uses a high-res clocksource. This is a bit slower, but that
probably doesn't matter in a busy-wait loop.

Note: it also doesn't matter in the current version, as there are no
callers of this function.

Fixes: 9a69f5087ccc ("drivers/staging: Gasket driver framework + Apex driver")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/staging/gasket/gasket_core.c | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c
index 45914ebc8f44..248c99a841a9 100644
--- a/drivers/staging/gasket/gasket_core.c
+++ b/drivers/staging/gasket/gasket_core.c
@@ -2090,19 +2090,14 @@ int gasket_wait_sync(
u64 timeout_ns)
{
u64 reg;
- struct timespec start_time, cur_time;
- u64 diff_nanosec;
+ u64 start_time, diff_nanosec;
int count = 0;

reg = gasket_dev_read_64(gasket_dev, bar, offset);
- start_time = current_kernel_time();
+ start_time = ktime_get_ns();
while ((reg & mask) != val) {
count++;
- cur_time = current_kernel_time();
- diff_nanosec = (u64)(cur_time.tv_sec - start_time.tv_sec) *
- 1000000000LL +
- (u64)(cur_time.tv_nsec) -
- (u64)(start_time.tv_nsec);
+ diff_nanosec = ktime_get_ns() - start_time;
if (diff_nanosec > timeout_ns) {
gasket_log_error(
gasket_dev,
--
2.9.0
\
 
 \ /
  Last update: 2018-07-15 22:06    [W:2.033 / U:0.384 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site