diff options
author | mav <mav@FreeBSD.org> | 2013-02-28 13:46:03 +0000 |
---|---|---|
committer | mav <mav@FreeBSD.org> | 2013-02-28 13:46:03 +0000 |
commit | 6cf7cc6e4d8da1cf9aba1c481b914e4ca5e9f38f (patch) | |
tree | c8556591f85961643a9b4ddfaaa7c1008bb03d81 /sys/arm/mv | |
parent | 240074414d4919ebd889f27087c72783a7ed9b19 (diff) | |
download | FreeBSD-src-6cf7cc6e4d8da1cf9aba1c481b914e4ca5e9f38f.zip FreeBSD-src-6cf7cc6e4d8da1cf9aba1c481b914e4ca5e9f38f.tar.gz |
MFcalloutng:
Switch eventtimers(9) from using struct bintime to sbintime_t.
Even before this not a single driver really supported full dynamic range of
struct bintime even in theory, not speaking about practical inexpediency.
This change legitimates the status quo and cleans up the code.
Diffstat (limited to 'sys/arm/mv')
-rw-r--r-- | sys/arm/mv/timer.c | 31 |
1 files changed, 11 insertions, 20 deletions
diff --git a/sys/arm/mv/timer.c b/sys/arm/mv/timer.c index db6e404..51a6c17 100644 --- a/sys/arm/mv/timer.c +++ b/sys/arm/mv/timer.c @@ -93,7 +93,7 @@ static void mv_watchdog_enable(void); static void mv_watchdog_disable(void); static void mv_watchdog_event(void *, unsigned int, int *); static int mv_timer_start(struct eventtimer *et, - struct bintime *first, struct bintime *period); + sbintime_t first, sbintime_t period); static int mv_timer_stop(struct eventtimer *et); static void mv_setup_timers(void); @@ -168,12 +168,8 @@ mv_timer_attach(device_t dev) sc->et.et_quality = 1000; sc->et.et_frequency = MV_CLOCK_SRC; - sc->et.et_min_period.sec = 0; - sc->et.et_min_period.frac = - ((0x00000002LLU << 32) / sc->et.et_frequency) << 32; - sc->et.et_max_period.sec = 0xfffffff0U / sc->et.et_frequency; - sc->et.et_max_period.frac = - ((0xfffffffeLLU << 32) / sc->et.et_frequency) << 32; + sc->et.et_min_period = (0x00000002LLU << 32) / sc->et.et_frequency; + sc->et.et_max_period = (0xfffffffeLLU << 32) / sc->et.et_frequency; sc->et.et_start = mv_timer_start; sc->et.et_stop = mv_timer_stop; sc->et.et_priv = sc; @@ -394,25 +390,20 @@ mv_watchdog_event(void *arg, unsigned int cmd, int *error) } static int -mv_timer_start(struct eventtimer *et, - struct bintime *first, struct bintime *period) +mv_timer_start(struct eventtimer *et, sbintime_t first, sbintime_t period) { struct mv_timer_softc *sc; uint32_t val, val1; /* Calculate dividers. */ sc = (struct mv_timer_softc *)et->et_priv; - if (period != NULL) { - val = (sc->et.et_frequency * (period->frac >> 32)) >> 32; - if (period->sec != 0) - val += sc->et.et_frequency * period->sec; - } else + if (period != 0) + val = ((uint32_t)sc->et.et_frequency * period) >> 32; + else val = 0; - if (first != NULL) { - val1 = (sc->et.et_frequency * (first->frac >> 32)) >> 32; - if (first->sec != 0) - val1 += sc->et.et_frequency * first->sec; - } else + if (first != 0) + val1 = ((uint32_t)sc->et.et_frequency * first) >> 32; + else val1 = val; /* Apply configuration. */ @@ -420,7 +411,7 @@ mv_timer_start(struct eventtimer *et, mv_set_timer(0, val1); val = mv_get_timer_control(); val |= CPU_TIMER0_EN; - if (period != NULL) + if (period != 0) val |= CPU_TIMER0_AUTO; else val &= ~CPU_TIMER0_AUTO; |