From: Deepa Dinamani <deepa.kernel@gmail.com>
To: tglx@linutronix.de, linux-kernel@vger.kernel.org
Cc: john.stultz@linaro.org, arnd@arndb.de, y2038@lists.linaro.org
Subject: [PATCH 5/7] Change k_clock clock_set() to use timespec64
Date: Sat, 18 Mar 2017 20:57:36 -0700 [thread overview]
Message-ID: <1489895858-29012-6-git-send-email-deepa.kernel@gmail.com> (raw)
In-Reply-To: <1489895858-29012-1-git-send-email-deepa.kernel@gmail.com>
struct timespec is not y2038 safe. The plan is to
get rid of all uses of timespec internally in the
kernel. Replace uses of timespec with timespec64.
The syscall interfaces themselves will be changed
in a separate series.
Signed-off-by: Deepa Dinamani <deepa.kernel@gmail.com>
---
drivers/char/mmtimer.c | 2 +-
include/linux/posix-timers.h | 2 +-
kernel/time/posix-clock.c | 5 ++---
kernel/time/posix-cpu-timers.c | 2 +-
kernel/time/posix-timers.c | 11 +++++------
5 files changed, 10 insertions(+), 12 deletions(-)
diff --git a/drivers/char/mmtimer.c b/drivers/char/mmtimer.c
index 79d8ada..ba1b892 100644
--- a/drivers/char/mmtimer.c
+++ b/drivers/char/mmtimer.c
@@ -489,7 +489,7 @@ static int sgi_clock_get(clockid_t clockid, struct timespec64 *tp)
return 0;
};
-static int sgi_clock_set(const clockid_t clockid, const struct timespec *tp)
+static int sgi_clock_set(const clockid_t clockid, const struct timespec64 *tp)
{
u64 nsec;
diff --git a/include/linux/posix-timers.h b/include/linux/posix-timers.h
index 2555d1c..249429c 100644
--- a/include/linux/posix-timers.h
+++ b/include/linux/posix-timers.h
@@ -89,7 +89,7 @@ struct k_itimer {
struct k_clock {
int (*clock_getres) (const clockid_t which_clock, struct timespec64 *tp);
int (*clock_set) (const clockid_t which_clock,
- const struct timespec *tp);
+ const struct timespec64 *tp);
int (*clock_get) (const clockid_t which_clock, struct timespec64 * tp);
int (*clock_adj) (const clockid_t which_clock, struct timex *tx);
int (*timer_create) (struct k_itimer *timer);
diff --git a/kernel/time/posix-clock.c b/kernel/time/posix-clock.c
index d5a4bec..6378fc6 100644
--- a/kernel/time/posix-clock.c
+++ b/kernel/time/posix-clock.c
@@ -335,10 +335,9 @@ static int pc_clock_getres(clockid_t id, struct timespec64 *ts)
return err;
}
-static int pc_clock_settime(clockid_t id, const struct timespec *ts)
+static int pc_clock_settime(clockid_t id, const struct timespec64 *ts)
{
struct posix_clock_desc cd;
- struct timespec64 ts64 = timespec_to_timespec64(*ts);
int err;
err = get_clock_desc(id, &cd);
@@ -351,7 +350,7 @@ static int pc_clock_settime(clockid_t id, const struct timespec *ts)
}
if (cd.clk->ops.clock_settime)
- err = cd.clk->ops.clock_settime(cd.clk, &ts64);
+ err = cd.clk->ops.clock_settime(cd.clk, ts);
else
err = -EOPNOTSUPP;
out:
diff --git a/kernel/time/posix-cpu-timers.c b/kernel/time/posix-cpu-timers.c
index 42ca205..0db0e16 100644
--- a/kernel/time/posix-cpu-timers.c
+++ b/kernel/time/posix-cpu-timers.c
@@ -135,7 +135,7 @@ posix_cpu_clock_getres(const clockid_t which_clock, struct timespec64 *tp)
}
static int
-posix_cpu_clock_set(const clockid_t which_clock, const struct timespec *tp)
+posix_cpu_clock_set(const clockid_t which_clock, const struct timespec64 *tp)
{
/*
* You can never reset a CPU clock, but we check for other errors
diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c
index a314a63..6c09f87 100644
--- a/kernel/time/posix-timers.c
+++ b/kernel/time/posix-timers.c
@@ -212,12 +212,9 @@ static int posix_clock_realtime_get(clockid_t which_clock, struct timespec64 *tp
/* Set clock_realtime */
static int posix_clock_realtime_set(const clockid_t which_clock,
- const struct timespec *tp)
+ const struct timespec64 *tp)
{
- struct timespec64 tp64;
-
- tp64 = timespec_to_timespec64(*tp);
- return do_sys_settimeofday64(&tp64, NULL);
+ return do_sys_settimeofday64(tp, NULL);
}
static int posix_clock_realtime_adj(const clockid_t which_clock,
@@ -1018,14 +1015,16 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
{
struct k_clock *kc = clockid_to_kclock(which_clock);
struct timespec new_tp;
+ struct timespec64 new_tp64;
if (!kc || !kc->clock_set)
return -EINVAL;
if (copy_from_user(&new_tp, tp, sizeof (*tp)))
return -EFAULT;
+ new_tp64 = timespec_to_timespec64(new_tp);
- return kc->clock_set(which_clock, &new_tp);
+ return kc->clock_set(which_clock, &new_tp64);
}
SYSCALL_DEFINE2(clock_gettime, const clockid_t, which_clock,
--
2.7.4
next prev parent reply other threads:[~2017-03-19 3:59 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-19 3:57 [PATCH 0/7] Change k_clock interfaces to use timespec64 Deepa Dinamani
2017-03-19 3:57 ` [PATCH 1/7] time: Delete do_sys_setimeofday() Deepa Dinamani
2017-03-19 3:57 ` [PATCH 2/7] time: Change posix clocks ops interfaces to use timespec64 Deepa Dinamani
2017-03-19 3:57 ` [PATCH 3/7] Change k_clock clock_get() " Deepa Dinamani
2017-03-19 3:57 ` [PATCH 4/7] Change k_clock clock_getres() " Deepa Dinamani
2017-03-19 3:57 ` Deepa Dinamani [this message]
2017-03-19 3:57 ` [PATCH 6/7] Change k_clock timer_set() and timer_get() " Deepa Dinamani
2017-03-19 3:57 ` [PATCH 7/7] Change k_clock nsleep() " Deepa Dinamani
2017-03-21 9:16 ` Arnd Bergmann
2017-03-21 19:00 ` Deepa Dinamani
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=1489895858-29012-6-git-send-email-deepa.kernel@gmail.com \
--to=deepa.kernel@gmail.com \
--cc=arnd@arndb.de \
--cc=john.stultz@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tglx@linutronix.de \
--cc=y2038@lists.linaro.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