Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

fbdev: radeon: use ktime_get() for HZ calibration

do_gettimeofday() is deprecated and a bit clumsy. This changes
radeon_probe_pll_params() over to using ktime_get() with monotonic
times. There is no need to check for negative values any more
since the monotonic clocksource cannot go backwards, but I'm
adding a check for zero-division in case of a bad clocksource.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>

authored by

Arnd Bergmann and committed by
Bartlomiej Zolnierkiewicz
63a4be93 defddeff

+7 -11
+7 -11
drivers/video/fbdev/aty/radeon_base.c
··· 583 583 int hTotal, vTotal, num, denom, m, n; 584 584 unsigned long long hz, vclk; 585 585 long xtal; 586 - struct timeval start_tv, stop_tv; 587 - long total_secs, total_usecs; 586 + ktime_t start_time, stop_time; 587 + u64 total_usecs; 588 588 int i; 589 589 590 590 /* Ugh, we cut interrupts, bad bad bad, but we want some precision ··· 600 600 if (((INREG(CRTC_VLINE_CRNT_VLINE) >> 16) & 0x3ff) == 0) 601 601 break; 602 602 603 - do_gettimeofday(&start_tv); 603 + start_time = ktime_get(); 604 604 605 605 for(i=0; i<1000000; i++) 606 606 if (((INREG(CRTC_VLINE_CRNT_VLINE) >> 16) & 0x3ff) != 0) ··· 610 610 if (((INREG(CRTC_VLINE_CRNT_VLINE) >> 16) & 0x3ff) == 0) 611 611 break; 612 612 613 - do_gettimeofday(&stop_tv); 613 + stop_time = ktime_get(); 614 614 615 615 local_irq_enable(); 616 616 617 - total_secs = stop_tv.tv_sec - start_tv.tv_sec; 618 - if (total_secs > 10) 617 + total_usecs = ktime_us_delta(stop_time, start_time); 618 + if (total_usecs >= 10 * USEC_PER_SEC || total_usecs == 0) 619 619 return -1; 620 - total_usecs = stop_tv.tv_usec - start_tv.tv_usec; 621 - total_usecs += total_secs * 1000000; 622 - if (total_usecs < 0) 623 - total_usecs = -total_usecs; 624 - hz = 1000000/total_usecs; 620 + hz = USEC_PER_SEC/(u32)total_usecs; 625 621 626 622 hTotal = ((INREG(CRTC_H_TOTAL_DISP) & 0x1ff) + 1) * 8; 627 623 vTotal = ((INREG(CRTC_V_TOTAL_DISP) & 0x3ff) + 1);