/* Note: Division is quite slow on CRIS and do_gettimeofday is called rather often. Maybe we should do some kind of approximation here (a naive approximation would be to divide by 1024).  */
void do_gettimeofday(struct timeval *tv)
/* Note: Division is quite slow on CRIS and do_gettimeofday is called rather often. Maybe we should do some kind of approximation here (a naive approximation would be to divide by 1024).  */
void do_gettimeofday(struct timeval *tv)
{
	unsigned long flags;
	signed long usec, sec;
	local_irq_save(flags);
	usec = do_gettimeoffset();
	if (unlikely(time_adjust < 0) && usec > tickadj)
		usec = tickadj;
	sec = xtime.tv_sec;
	usec += xtime.tv_nsec / 1000;
	local_irq_restore(flags);
	while (usec >= 1000000) {
		usec -= 1000000;
		sec++;
	}
	tv->tv_sec = sec;
	tv->tv_usec = usec;
}