This patch introduces the 64bit methods for k_clock structure, that converts the timespec/itimerspec type to timespec64/itimerspec64 type.
Signed-off-by: Baolin Wang baolin.wang@linaro.org --- kernel/time/posix-clock.c | 66 +++++++++++++++++---------------------------- 1 file changed, 25 insertions(+), 41 deletions(-)
diff --git a/kernel/time/posix-clock.c b/kernel/time/posix-clock.c index fc90e98..bb5c6c8 100644 --- a/kernel/time/posix-clock.c +++ b/kernel/time/posix-clock.c @@ -297,54 +297,47 @@ 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 *tp; int err;
err = get_clock_desc(id, &cd); if (err) return err;
- if (cd.clk->ops.clock_gettime) { - *tp = timespec_to_timespec64(*ts); - err = cd.clk->ops.clock_gettime(cd.clk, tp); - } else { + if (cd.clk->ops.clock_gettime) + err = cd.clk->ops.clock_gettime(cd.clk, ts); + else err = -EOPNOTSUPP; - }
put_clock_desc(&cd);
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 *tp; int err;
err = get_clock_desc(id, &cd); if (err) return err;
- if (cd.clk->ops.clock_getres) { - *tp = timespec_to_timespec64(*ts); - err = cd.clk->ops.clock_getres(cd.clk, tp); - } else { + if (cd.clk->ops.clock_getres) + err = cd.clk->ops.clock_getres(cd.clk, ts); + else err = -EOPNOTSUPP; - }
put_clock_desc(&cd);
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 tp; int err;
err = get_clock_desc(id, &cd); @@ -356,12 +349,11 @@ static int pc_clock_settime(clockid_t id, const struct timespec *ts) goto out; }
- if (cd.clk->ops.clock_settime) { - tp = timespec_to_timespec64(*ts); - err = cd.clk->ops.clock_settime(cd.clk, &tp); - } else { + if (cd.clk->ops.clock_settime) + err = cd.clk->ops.clock_settime(cd.clk, ts); + else err = -EOPNOTSUPP; - } + out: put_clock_desc(&cd);
@@ -408,43 +400,35 @@ static int pc_timer_delete(struct k_itimer *kit) return err; }
-static void pc_timer_gettime(struct k_itimer *kit, struct itimerspec *ts) +static void pc_timer_gettime(struct k_itimer *kit, struct itimerspec64 *ts) { clockid_t id = kit->it_clock; struct posix_clock_desc cd; - struct itimerspec64 *ts64;
if (get_clock_desc(id, &cd)) return;
- if (cd.clk->ops.timer_gettime) { - *ts64 = itimerspec_to_itimerspec64(*ts); - cd.clk->ops.timer_gettime(cd.clk, kit, ts64); - } + if (cd.clk->ops.timer_gettime) + cd.clk->ops.timer_gettime(cd.clk, kit, ts);
put_clock_desc(&cd); }
static int pc_timer_settime(struct k_itimer *kit, int flags, - struct itimerspec *ts, struct itimerspec *old) + struct itimerspec64 *ts, struct itimerspec64 *old) { clockid_t id = kit->it_clock; struct posix_clock_desc cd; - struct itimerspec64 ts64; - struct itimerspec64 *old64; int err;
err = get_clock_desc(id, &cd); if (err) return err;
- if (cd.clk->ops.timer_settime) { - ts64 = itimerspec_to_itimerspec64(*ts); - *old64 = itimerspec_to_itimerspec64(*old); - err = cd.clk->ops.timer_settime(cd.clk, kit, flags, &ts64, old64); - } else { + if (cd.clk->ops.timer_settime) + err = cd.clk->ops.timer_settime(cd.clk, kit, flags, ts, old); + else err = -EOPNOTSUPP; - }
put_clock_desc(&cd);
@@ -452,12 +436,12 @@ static int pc_timer_settime(struct k_itimer *kit, int flags, }
struct k_clock clock_posix_dynamic = { - .clock_getres = pc_clock_getres, - .clock_set = pc_clock_settime, - .clock_get = pc_clock_gettime, + .clock_getres64 = pc_clock_getres, + .clock_set64 = pc_clock_settime, + .clock_get64 = pc_clock_gettime, .clock_adj = pc_clock_adjtime, .timer_create = pc_timer_create, - .timer_set = pc_timer_settime, + .timer_set64 = pc_timer_settime, .timer_del = pc_timer_delete, - .timer_get = pc_timer_gettime, + .timer_get64 = pc_timer_gettime, };