/* Sleep until gettimeofday() > waketime + add_usec This needs to be as precise as possible, but as the delay is usually between 2ms and 32ms, it is done using a scheduled msleep followed by usleep (normally a busy-wait loop) for the remainder  */
void dvb_frontend_sleep_until(struct timeval *waketime, u32 add_usec)
/* Sleep until gettimeofday() > waketime + add_usec This needs to be as precise as possible, but as the delay is usually between 2ms and 32ms, it is done using a scheduled msleep followed by usleep (normally a busy-wait loop) for the remainder  */
void dvb_frontend_sleep_until(struct timeval *waketime, u32 add_usec)
{
	struct timeval lasttime;
	s32 delta, newdelta;
	timeval_usec_add(waketime, add_usec);
	do_gettimeofday(&lasttime);
	delta = timeval_usec_diff(lasttime, *waketime);
	if (delta > 2500) {
		msleep((delta - 1500) / 1000);
		do_gettimeofday(&lasttime);
		newdelta = timeval_usec_diff(lasttime, *waketime);
		delta = (newdelta > delta) ? 0 : newdelta;
	}
	if (delta > 0)
		udelay(delta);
}