Commit 3c9c12f4 authored by Deepa Dinamani's avatar Deepa Dinamani Committed by Thomas Gleixner
Browse files

time: Change k_clock clock_get() to use timespec64



struct timespec is not y2038 safe on 32 bit machines.  Replace uses of
struct timespec with struct timespec64 in the kernel.

The syscall interfaces themselves will be changed in a separate series.

Signed-off-by: default avatarDeepa Dinamani <deepa.kernel@gmail.com>
Cc: y2038@lists.linaro.org
Cc: john.stultz@linaro.org
Cc: arnd@arndb.de
Link: http://lkml.kernel.org/r/1490555058-4603-4-git-send-email-deepa.kernel@gmail.com


Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
parent d340266e
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -478,13 +478,13 @@ static int sgi_clock_period;
static struct timespec sgi_clock_offset;
static int sgi_clock_period;

static int sgi_clock_get(clockid_t clockid, struct timespec *tp)
static int sgi_clock_get(clockid_t clockid, struct timespec64 *tp)
{
	u64 nsec;

	nsec = rtc_time() * sgi_clock_period
			+ sgi_clock_offset.tv_nsec;
	*tp = ns_to_timespec(nsec);
	*tp = ns_to_timespec64(nsec);
	tp->tv_sec += sgi_clock_offset.tv_sec;
	return 0;
};
+1 −1
Original line number Diff line number Diff line
@@ -90,7 +90,7 @@ struct k_clock {
	int (*clock_getres) (const clockid_t which_clock, struct timespec *tp);
	int (*clock_set) (const clockid_t which_clock,
			  const struct timespec *tp);
	int (*clock_get) (const clockid_t which_clock, struct timespec * 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);
	int (*nsleep) (const clockid_t which_clock, int flags,
+5 −0
Original line number Diff line number Diff line
@@ -258,6 +258,11 @@ static inline void timekeeping_clocktai(struct timespec *ts)
	*ts = ktime_to_timespec(ktime_get_clocktai());
}

static inline void timekeeping_clocktai64(struct timespec64 *ts)
{
	*ts = ktime_to_timespec64(ktime_get_clocktai());
}

/*
 * RTC specific
 */
+2 −2
Original line number Diff line number Diff line
@@ -558,14 +558,14 @@ static int alarm_clock_getres(const clockid_t which_clock, struct timespec *tp)
 *
 * Provides the underlying alarm base time.
 */
static int alarm_clock_get(clockid_t which_clock, struct timespec *tp)
static int alarm_clock_get(clockid_t which_clock, struct timespec64 *tp)
{
	struct alarm_base *base = &alarm_bases[clock2alarm(which_clock)];

	if (!alarmtimer_get_rtcdev())
		return -EINVAL;

	*tp = ktime_to_timespec(base->gettime());
	*tp = ktime_to_timespec64(base->gettime());
	return 0;
}

+3 −6
Original line number Diff line number Diff line
@@ -297,20 +297,17 @@ out:
	return err;
}

static int pc_clock_gettime(clockid_t id, struct timespec *ts)
static int pc_clock_gettime(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_gettime) {
		err = cd.clk->ops.clock_gettime(cd.clk, &ts64);
		*ts = timespec64_to_timespec(ts64);
	}
	if (cd.clk->ops.clock_gettime)
		err = cd.clk->ops.clock_gettime(cd.clk, ts);
	else
		err = -EOPNOTSUPP;

Loading