Thanks, I'll fix these issues in next patch.
On 14 April 2015 at 03:16, Arnd Bergmann arnd@linaro.org wrote:
On Saturday 11 April 2015 18:46:56 Baolin Wang wrote:
All of the k_clock users have been converted to the new methods. This
patch
removes the older methods with timepsec type. As a result, the k_clock structure is ready for the year 2038.
Signed-off-by: Baolin Wang baolin.wang@linaro.org
As mentioned in my earlier reply to an older thread, a better way to do this would be to just remove the unused function calls (clock_set, clock_get, clock_getres) and leave the newly introduced code in place.
Otherwise the patch is technically correct as far as I can tell, so this is more of a style issue.
Arnd
diff --git a/drivers/char/mmtimer.c b/drivers/char/mmtimer.c index 1d64a0e..c70f82b 100644 --- a/drivers/char/mmtimer.c +++ b/drivers/char/mmtimer.c @@ -773,9 +773,9 @@ static int sgi_clock_getres(const clockid_t
which_clock, struct timespec64 *tp)
}
static struct k_clock sgi_clock = {
.clock_set64 = sgi_clock_set,
.clock_get64 = sgi_clock_get,
.clock_getres64 = sgi_clock_getres,
.clock_set = sgi_clock_set,
.clock_get = sgi_clock_get,
.clock_getres = sgi_clock_getres, .timer_create = sgi_timer_create, .timer_set = sgi_timer_set, .timer_del = sgi_timer_del,
diff --git a/include/linux/posix-timers.h b/include/linux/posix-timers.h index ff0b81f..4059129 100644 --- a/include/linux/posix-timers.h +++ b/include/linux/posix-timers.h @@ -97,15 +97,11 @@ struct k_itimer { };
struct k_clock {
int (*clock_getres) (const clockid_t which_clock, struct timespec
*tp);
int (*clock_getres64) (const clockid_t which_clock,
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_set64) (const clockid_t which_clock, const struct timespec64 *tp);
int (*clock_get) (const clockid_t which_clock, struct timespec *
tp);
int (*clock_get64) (const clockid_t which_clock, 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); int (*nsleep) (const clockid_t which_clock, int flags,
diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c index 7aefb7f..114e8fb 100644 --- a/kernel/time/alarmtimer.c +++ b/kernel/time/alarmtimer.c @@ -825,8 +825,8 @@ static int __init alarmtimer_init(void) int error = 0; int i; struct k_clock alarm_clock = {
.clock_getres64 = alarm_clock_getres,
.clock_get64 = alarm_clock_get,
.clock_getres = alarm_clock_getres,
.clock_get = alarm_clock_get, .timer_create = alarm_timer_create, .timer_set = alarm_timer_set, .timer_del = alarm_timer_del,
diff --git a/kernel/time/posix-clock.c b/kernel/time/posix-clock.c index f425caf..0a1eb98 100644 --- a/kernel/time/posix-clock.c +++ b/kernel/time/posix-clock.c @@ -435,9 +435,9 @@ static int pc_timer_settime(struct k_itimer *kit,
int flags,
}
struct k_clock clock_posix_dynamic = {
.clock_getres64 = pc_clock_getres,
.clock_set64 = pc_clock_settime,
.clock_get64 = pc_clock_gettime,
.clock_getres = pc_clock_getres,
.clock_set = pc_clock_settime,
.clock_get = pc_clock_gettime, .clock_adj = pc_clock_adjtime, .timer_create = pc_timer_create, .timer_set = pc_timer_settime,
diff --git a/kernel/time/posix-cpu-timers.c
b/kernel/time/posix-cpu-timers.c
index 7bd88f6..d7fa1ab 100644 --- a/kernel/time/posix-cpu-timers.c +++ b/kernel/time/posix-cpu-timers.c @@ -1446,9 +1446,9 @@ static int thread_cpu_timer_create(struct k_itimer
*timer)
}
struct k_clock clock_posix_cpu = {
.clock_getres64 = posix_cpu_clock_getres,
.clock_set64 = posix_cpu_clock_set,
.clock_get64 = posix_cpu_clock_get,
.clock_getres = posix_cpu_clock_getres,
.clock_set = posix_cpu_clock_set,
.clock_get = posix_cpu_clock_get, .timer_create = posix_cpu_timer_create, .nsleep = posix_cpu_nsleep, .nsleep_restart = posix_cpu_nsleep_restart,
@@ -1460,15 +1460,15 @@ struct k_clock clock_posix_cpu = { static __init int init_posix_cpu_timers(void) { struct k_clock process = {
.clock_getres64 = process_cpu_clock_getres,
.clock_get64 = process_cpu_clock_get,
.clock_getres = process_cpu_clock_getres,
.clock_get = process_cpu_clock_get, .timer_create = process_cpu_timer_create, .nsleep = process_cpu_nsleep, .nsleep_restart = process_cpu_nsleep_restart, }; struct k_clock thread = {
.clock_getres64 = thread_cpu_clock_getres,
.clock_get64 = thread_cpu_clock_get,
.clock_getres = thread_cpu_clock_getres,
.clock_get = thread_cpu_clock_get, .timer_create = thread_cpu_timer_create, }; struct timespec ts;
diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c index 2c55be1..1625541 100644 --- a/kernel/time/posix-timers.c +++ b/kernel/time/posix-timers.c @@ -284,9 +284,9 @@ static int posix_get_tai(clockid_t which_clock,
struct timespec64 *tp)
static __init int init_posix_timers(void) { struct k_clock clock_realtime = {
.clock_getres64 = hrtimer_get_res64,
.clock_get64 = posix_clock_realtime_get,
.clock_set64 = posix_clock_realtime_set,
.clock_getres = hrtimer_get_res64,
.clock_get = posix_clock_realtime_get,
.clock_set = posix_clock_realtime_set, .clock_adj = posix_clock_realtime_adj, .nsleep = common_nsleep, .nsleep_restart = hrtimer_nanosleep_restart,
@@ -296,8 +296,8 @@ static __init int init_posix_timers(void) .timer_del = common_timer_del, }; struct k_clock clock_monotonic = {
.clock_getres64 = hrtimer_get_res64,
.clock_get64 = posix_ktime_get_ts,
.clock_getres = hrtimer_get_res64,
.clock_get = posix_ktime_get_ts, .nsleep = common_nsleep, .nsleep_restart = hrtimer_nanosleep_restart, .timer_create = common_timer_create,
@@ -306,20 +306,20 @@ static __init int init_posix_timers(void) .timer_del = common_timer_del, }; struct k_clock clock_monotonic_raw = {
.clock_getres64 = hrtimer_get_res64,
.clock_get64 = posix_get_monotonic_raw,
.clock_getres = hrtimer_get_res64,
.clock_get = posix_get_monotonic_raw, }; struct k_clock clock_realtime_coarse = {
.clock_getres64 = posix_get_coarse_res,
.clock_get64 = posix_get_realtime_coarse,
.clock_getres = posix_get_coarse_res,
.clock_get = posix_get_realtime_coarse, }; struct k_clock clock_monotonic_coarse = {
.clock_getres64 = posix_get_coarse_res,
.clock_get64 = posix_get_monotonic_coarse,
.clock_getres = posix_get_coarse_res,
.clock_get = posix_get_monotonic_coarse, }; struct k_clock clock_tai = {
.clock_getres64 = hrtimer_get_res64,
.clock_get64 = posix_get_tai,
.clock_getres = hrtimer_get_res64,
.clock_get = posix_get_tai, .nsleep = common_nsleep, .nsleep_restart = hrtimer_nanosleep_restart, .timer_create = common_timer_create,
@@ -328,8 +328,8 @@ static __init int init_posix_timers(void) .timer_del = common_timer_del, }; struct k_clock clock_boottime = {
.clock_getres64 = hrtimer_get_res64,
.clock_get64 = posix_get_boottime,
.clock_getres = hrtimer_get_res64,
.clock_get = posix_get_boottime, .nsleep = common_nsleep, .nsleep_restart = hrtimer_nanosleep_restart, .timer_create = common_timer_create,
@@ -1021,12 +1021,8 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t,
which_clock,
if (copy_from_user(&new_tp, tp, sizeof (*tp))) return -EFAULT;
if (kc->clock_set64) {
new_tp64 = timespec_to_timespec64(new_tp);
return kc->clock_set64(which_clock, &new_tp64);
} else {
return kc->clock_set(which_clock, &new_tp);
}
new_tp64 = timespec_to_timespec64(new_tp);
return kc->clock_set(which_clock, &new_tp64);
}
SYSCALL_DEFINE2(clock_gettime, const clockid_t, which_clock, @@ -1040,14 +1036,13 @@ SYSCALL_DEFINE2(clock_gettime, const clockid_t,
which_clock,
if (!kc) return -EINVAL;
if (kc->clock_get64) {
error = kc->clock_get64(which_clock, &kernel_tp64);
kernel_tp = timespec64_to_timespec(kernel_tp64);
} else {
error = kc->clock_get(which_clock, &kernel_tp);
}
error = kc->clock_get(which_clock, &kernel_tp64);
if (!error)
return error;
if (!error && copy_to_user(tp, &kernel_tp, sizeof (kernel_tp)))
kernel_tp = timespec64_to_timespec(kernel_tp64);
if (copy_to_user(tp, &kernel_tp, sizeof (kernel_tp))) error = -EFAULT; return error;
@@ -1087,14 +1082,13 @@ SYSCALL_DEFINE2(clock_getres, const clockid_t,
which_clock,
if (!kc) return -EINVAL;
if (kc->clock_getres64) {
error = kc->clock_getres64(which_clock, &rtn_tp64);
rtn_tp = timespec64_to_timespec(rtn_tp64);
} else {
error = kc->clock_getres(which_clock, &rtn_tp);
}
error = kc->clock_getres(which_clock, &rtn_tp64);
if (!error)
return error;
rtn_tp = timespec64_to_timespec(rtn_tp64);
if (!error && tp && copy_to_user(tp, &rtn_tp, sizeof (rtn_tp)))
if (tp && copy_to_user(tp, &rtn_tp, sizeof (rtn_tp))) error = -EFAULT; return error;