On Wednesday 15 April 2015 19:56:49 Baolin Wang wrote:
struct k_clock {
- int (*clock_getres) (const clockid_t which_clock, struct timespec *tp); int (*clock_getres64) (const clockid_t which_clock, struct timespec64 *tp);
- int (*clock_set) (const clockid_t which_clock,
int (*clock_set64) (const clockid_t which_clock, const struct timespec64 *tp);const struct timespec *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_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, struct timespec *, struct timespec __user *); long (*nsleep_restart) (struct restart_block *restart_block);
- int (*timer_set) (struct k_itimer * timr, int flags,
struct itimerspec * new_setting,
int (*timer_set64) (struct k_itimer *timr, int flags, struct itimerspec64 *new_setting, struct itimerspec64 *old_setting); int (*timer_del) (struct k_itimer * timr);struct itimerspec * old_setting);
#define TIMER_RETRY 1
- void (*timer_get) (struct k_itimer * timr,
void (*timer_get64) (struct k_itimer *timr, struct itimerspec64 *cur_setting);struct itimerspec * cur_setting);
};
So far looks good.
diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c index fce456d..3504928 100644 --- a/kernel/time/posix-timers.c +++ b/kernel/time/posix-timers.c @@ -528,13 +528,13 @@ void posix_timers_register_clock(const clockid_t clock_id, return; }
- if (!new_clock->clock_get) {
printk(KERN_WARNING "POSIX clock id %d lacks clock_get()\n",
- if (!new_clock->clock_get64) {
return; }printk(KERN_WARNING "POSIX clock id %d lacks clock_get64()\n", clock_id);
- if (!new_clock->clock_getres) {
printk(KERN_WARNING "POSIX clock id %d lacks clock_getres()\n",
- if (!new_clock->clock_getres64) {
return; }printk(KERN_WARNING "POSIX clock id %d lacks clock_getres64()\n", clock_id);
This part tells me that you forgot to add the caller for clock_getres64 in patch 5, so any k_clock implementation that had only clock_getres64 but not clock_getres was broken until this patch.
@@ -585,7 +585,7 @@ static struct k_clock *clockid_to_kclock(const clockid_t id) return (id & CLOCKFD_MASK) == CLOCKFD ? &clock_posix_dynamic : &clock_posix_cpu;
- if (id >= MAX_CLOCKS || !posix_clocks[id].clock_getres)
- if (id >= MAX_CLOCKS || !posix_clocks[id].clock_getres64) return NULL; return &posix_clocks[id];
}
Same here.
@@ -788,15 +788,11 @@ SYSCALL_DEFINE2(timer_gettime, timer_t, timer_id, return -EINVAL; kc = clockid_to_kclock(timr->it_clock);
- if (WARN_ON_ONCE(!kc || !kc->timer_get64 || !kc->timer_get)) {
- if (WARN_ON_ONCE(!kc || !kc->timer_get64)) { ret = -EINVAL; } else {
if (kc->timer_get64) {
kc->timer_get64(timr, &cur_setting64);
cur_setting = itimerspec64_to_itimerspec(cur_setting64);
} else {
kc->timer_get(timr, &cur_setting);
}
kc->timer_get64(timr, &cur_setting64);
}cur_setting = itimerspec64_to_itimerspec(cur_setting64);
unlock_timer(timr, flags);
This and the rest of the patch looks good again.
Arnd