Skip to content

Commit

Permalink
posix-timers: Make clock_getres and clock_get mandatory
Browse files Browse the repository at this point in the history
Richard said: "I would think that we can require k_clocks to provide
the read function. This could be checked and enforced in
register_posix_clock()."

Add checks for clock_getres and clock_get in the register function.

Suggested-by: Richard Cochran <richardcochran@gmail.com>
Cc: John Stultz <johnstul@us.ibm.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
  • Loading branch information
Thomas Gleixner committed Feb 2, 2011
1 parent 4228577 commit 4359ac0
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions kernel/posix-timers.c
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,18 @@ static struct pid *good_sigevent(sigevent_t * event)
void register_posix_clock(const clockid_t clock_id, struct k_clock *new_clock)
{
if ((unsigned) clock_id >= MAX_CLOCKS) {
printk("POSIX clock register failed for clock_id %d\n",
printk(KERN_WARNING "POSIX clock register failed for clock_id %d\n",
clock_id);
return;
}

if (!new_clock->clock_get) {
printk(KERN_WARNING "POSIX clock id %d lacks clock_get()\n",
clock_id);
return;
}
if (!new_clock->clock_getres) {
printk(KERN_WARNING "POSIX clock id %d lacks clock_getres()\n",
clock_id);
return;
}
Expand Down Expand Up @@ -961,8 +972,6 @@ SYSCALL_DEFINE2(clock_gettime, const clockid_t, which_clock,

if (!kc)
return -EINVAL;
if (!kc->clock_get)
return -EOPNOTSUPP;

error = kc->clock_get(which_clock, &kernel_tp);

Expand Down

0 comments on commit 4359ac0

Please sign in to comment.