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: [RESEND PATCH 4/7] Change k_clock clock_getres() to use timespec64
Date: Sat, 18 Mar 2017 22:17:43 -0700 [thread overview]
Message-ID: <1489900666-32268-5-git-send-email-deepa.kernel@gmail.com> (raw)
In-Reply-To: <1489900666-32268-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/alarmtimer.c | 2 +-
kernel/time/posix-clock.c | 9 +++------
kernel/time/posix-cpu-timers.c | 6 +++---
kernel/time/posix-timers.c | 10 ++++++----
6 files changed, 15 insertions(+), 16 deletions(-)
diff --git a/drivers/char/mmtimer.c b/drivers/char/mmtimer.c
index 40d880b..79d8ada 100644
--- a/drivers/char/mmtimer.c
+++ b/drivers/char/mmtimer.c
@@ -765,7 +765,7 @@ static int sgi_timer_set(struct k_itimer *timr, int flags,
return err;
}
-static int sgi_clock_getres(const clockid_t which_clock, struct timespec *tp)
+static int sgi_clock_getres(const clockid_t which_clock, struct timespec64 *tp)
{
tp->tv_sec = 0;
tp->tv_nsec = sgi_clock_period;
diff --git a/include/linux/posix-timers.h b/include/linux/posix-timers.h
index db54f1b..2555d1c 100644
--- a/include/linux/posix-timers.h
+++ b/include/linux/posix-timers.h
@@ -87,7 +87,7 @@ struct k_itimer {
};
struct k_clock {
- int (*clock_getres) (const clockid_t which_clock, struct timespec *tp);
+ int (*clock_getres) (const clockid_t which_clock, struct timespec64 *tp);
int (*clock_set) (const clockid_t which_clock,
const struct timespec *tp);
int (*clock_get) (const clockid_t which_clock, struct timespec64 * tp);
diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
index 944ca6e..e8a45e2 100644
--- a/kernel/time/alarmtimer.c
+++ b/kernel/time/alarmtimer.c
@@ -541,7 +541,7 @@ static enum alarmtimer_restart alarm_handle_timer(struct alarm *alarm,
*
* Returns the granularity of underlying alarm base clock
*/
-static int alarm_clock_getres(const clockid_t which_clock, struct timespec *tp)
+static int alarm_clock_getres(const clockid_t which_clock, struct timespec64 *tp)
{
if (!alarmtimer_get_rtcdev())
return -EINVAL;
diff --git a/kernel/time/posix-clock.c b/kernel/time/posix-clock.c
index 0427c8c..d5a4bec 100644
--- a/kernel/time/posix-clock.c
+++ b/kernel/time/posix-clock.c
@@ -316,20 +316,17 @@ static int pc_clock_gettime(clockid_t id, struct timespec64 *ts)
return err;
}
-static int pc_clock_getres(clockid_t id, struct timespec *ts)
+static int pc_clock_getres(clockid_t id, struct timespec64 *ts)
{
struct posix_clock_desc cd;
- struct timespec64 ts64;
int err;
err = get_clock_desc(id, &cd);
if (err)
return err;
- if (cd.clk->ops.clock_getres) {
- err = cd.clk->ops.clock_getres(cd.clk, &ts64);
- *ts = timespec64_to_timespec(ts64);
- }
+ if (cd.clk->ops.clock_getres)
+ err = cd.clk->ops.clock_getres(cd.clk, ts);
else
err = -EOPNOTSUPP;
diff --git a/kernel/time/posix-cpu-timers.c b/kernel/time/posix-cpu-timers.c
index 6c509ea..42ca205 100644
--- a/kernel/time/posix-cpu-timers.c
+++ b/kernel/time/posix-cpu-timers.c
@@ -116,7 +116,7 @@ static inline u64 virt_ticks(struct task_struct *p)
}
static int
-posix_cpu_clock_getres(const clockid_t which_clock, struct timespec *tp)
+posix_cpu_clock_getres(const clockid_t which_clock, struct timespec64 *tp)
{
int error = check_clock(which_clock);
if (!error) {
@@ -1364,7 +1364,7 @@ static long posix_cpu_nsleep_restart(struct restart_block *restart_block)
#define THREAD_CLOCK MAKE_THREAD_CPUCLOCK(0, CPUCLOCK_SCHED)
static int process_cpu_clock_getres(const clockid_t which_clock,
- struct timespec *tp)
+ struct timespec64 *tp)
{
return posix_cpu_clock_getres(PROCESS_CLOCK, tp);
}
@@ -1389,7 +1389,7 @@ static long process_cpu_nsleep_restart(struct restart_block *restart_block)
return -EINVAL;
}
static int thread_cpu_clock_getres(const clockid_t which_clock,
- struct timespec *tp)
+ struct timespec64 *tp)
{
return posix_cpu_clock_getres(THREAD_CLOCK, tp);
}
diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c
index ba0c472..a314a63 100644
--- a/kernel/time/posix-timers.c
+++ b/kernel/time/posix-timers.c
@@ -258,9 +258,9 @@ static int posix_get_monotonic_coarse(clockid_t which_clock,
return 0;
}
-static int posix_get_coarse_res(const clockid_t which_clock, struct timespec *tp)
+static int posix_get_coarse_res(const clockid_t which_clock, struct timespec64 *tp)
{
- *tp = ktime_to_timespec(KTIME_LOW_RES);
+ *tp = ktime_to_timespec64(KTIME_LOW_RES);
return 0;
}
@@ -276,7 +276,7 @@ static int posix_get_tai(clockid_t which_clock, struct timespec64 *tp)
return 0;
}
-static int posix_get_hrtimer_res(clockid_t which_clock, struct timespec *tp)
+static int posix_get_hrtimer_res(clockid_t which_clock, struct timespec64 *tp)
{
tp->tv_sec = 0;
tp->tv_nsec = hrtimer_resolution;
@@ -1076,12 +1076,14 @@ SYSCALL_DEFINE2(clock_getres, const clockid_t, which_clock,
{
struct k_clock *kc = clockid_to_kclock(which_clock);
struct timespec rtn_tp;
+ struct timespec64 rtn_tp64;
int error;
if (!kc)
return -EINVAL;
- error = kc->clock_getres(which_clock, &rtn_tp);
+ error = kc->clock_getres(which_clock, &rtn_tp64);
+ rtn_tp = timespec64_to_timespec(rtn_tp64);
if (!error && tp && copy_to_user(tp, &rtn_tp, sizeof (rtn_tp)))
error = -EFAULT;
--
2.7.4
next prev parent reply other threads:[~2017-03-19 5:26 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-19 5:17 [RESEND PATCH 0/7] Change k_clock interfaces to use timespec64 Deepa Dinamani
2017-03-19 5:17 ` [RESEND PATCH 1/7] time: Delete do_sys_setimeofday() Deepa Dinamani
2017-03-19 10:57 ` Thomas Gleixner
2017-03-21 17:21 ` kbuild test robot
2017-03-21 18:57 ` Deepa Dinamani
2017-03-19 5:17 ` [RESEND PATCH 2/7] time: Change posix clocks ops interfaces to use timespec64 Deepa Dinamani
2017-03-19 10:51 ` Thomas Gleixner
2017-03-20 20:39 ` Deepa Dinamani
2017-03-20 20:40 ` Thomas Gleixner
2017-03-21 8:19 ` Arnd Bergmann
2017-03-21 9:04 ` Thomas Gleixner
2017-03-20 21:40 ` [Y2038] " Tomoyoshi ASANO
2017-03-19 18:06 ` Richard Cochran
2017-03-20 20:38 ` Deepa Dinamani
2017-03-19 5:17 ` [RESEND PATCH 3/7] Change k_clock clock_get() " Deepa Dinamani
2017-03-19 11:03 ` Thomas Gleixner
2017-03-19 5:17 ` Deepa Dinamani [this message]
2017-03-19 5:17 ` [RESEND PATCH 5/7] Change k_clock clock_set() " Deepa Dinamani
2017-03-19 5:17 ` [RESEND PATCH 6/7] Change k_clock timer_set() and timer_get() " Deepa Dinamani
2017-03-19 5:17 ` [RESEND PATCH 7/7] Change k_clock nsleep() " Deepa Dinamani
2017-03-19 11:06 ` [RESEND PATCH 0/7] Change k_clock interfaces " Thomas Gleixner
2017-03-20 20:39 ` 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=1489900666-32268-5-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;
as well as URLs for NNTP newsgroup(s).