From: Arnd Bergmann <arnd@arndb.de>
To: Rob Springer <rspringer@google.com>,
John Joseph <jnjoseph@google.com>,
Ben Chan <benchan@chromium.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Arnd Bergmann <arnd@arndb.de>, Simon Que <sque@chromium.org>,
devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org
Subject: [PATCH] staging: gasket remove current_kernel_time usage
Date: Fri, 13 Jul 2018 17:06:37 +0200 [thread overview]
Message-ID: <20180713150703.3156256-1-arnd@arndb.de> (raw)
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
next reply other threads:[~2018-07-13 15:07 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-13 15:06 Arnd Bergmann [this message]
2018-07-13 15:33 ` Greg Kroah-Hartman
2018-07-13 15:46 ` Greg Kroah-Hartman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180713150703.3156256-1-arnd@arndb.de \
--to=arnd@arndb.de \
--cc=benchan@chromium.org \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=jnjoseph@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rspringer@google.com \
--cc=sque@chromium.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome