* better solutions..
*/
-static unsigned long __estimate_accuracy(struct timespec *tv)
+static long __estimate_accuracy(struct timespec *tv)
{
- unsigned long slack;
+ long slack;
int divfactor = 1000;
if (task_nice(current) > 0)
if (slack > 100 * NSEC_PER_MSEC)
slack = 100 * NSEC_PER_MSEC;
+
+ if (slack < 0)
+ slack = 0;
return slack;
}
-static unsigned long estimate_accuracy(struct timespec *tv)
+static long estimate_accuracy(struct timespec *tv)
{
unsigned long ret;
struct timespec now;
timed_out = 1;
}
- if (end_time)
+ if (end_time && !timed_out)
slack = estimate_accuracy(end_time);
retval = 0;
return -EFAULT;
to = &end_time;
- if (poll_select_set_timeout(to, tv.tv_sec,
- tv.tv_usec * NSEC_PER_USEC))
+ if (poll_select_set_timeout(to,
+ tv.tv_sec + (tv.tv_usec / USEC_PER_SEC),
+ (tv.tv_usec % USEC_PER_SEC) * NSEC_PER_USEC))
return -EINVAL;
}
timed_out = 1;
}
- if (end_time)
+ if (end_time && !timed_out)
slack = estimate_accuracy(end_time);
for (;;) {