Date: Fri, 22 Jun 2018 09:08:39 +0000 (UTC) From: Andriy Gapon <avg@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r335533 - stable/11/sys/dev/acpica Message-ID: <201806220908.w5M98d78023060@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: avg Date: Fri Jun 22 09:08:38 2018 New Revision: 335533 URL: https://svnweb.freebsd.org/changeset/base/335533 Log: MFC r333209: hpet: use macros instead of magic values for the timer mode Modified: stable/11/sys/dev/acpica/acpi_hpet.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/acpica/acpi_hpet.c ============================================================================== --- stable/11/sys/dev/acpica/acpi_hpet.c Fri Jun 22 06:05:19 2018 (r335532) +++ stable/11/sys/dev/acpica/acpi_hpet.c Fri Jun 22 09:08:38 2018 (r335533) @@ -97,6 +97,9 @@ struct hpet_softc { struct hpet_softc *sc; int num; int mode; +#define TIMER_STOPPED 0 +#define TIMER_PERIODIC 1 +#define TIMER_ONESHOT 2 int intr_rid; int irq; int pcpu_cpu; @@ -207,10 +210,10 @@ hpet_start(struct eventtimer *et, sbintime_t first, sb t = (mt->pcpu_master < 0) ? mt : &sc->t[mt->pcpu_slaves[curcpu]]; if (period != 0) { - t->mode = 1; + t->mode = TIMER_PERIODIC; t->div = (sc->freq * period) >> 32; } else { - t->mode = 2; + t->mode = TIMER_ONESHOT; t->div = 0; } if (first != 0) @@ -223,7 +226,7 @@ hpet_start(struct eventtimer *et, sbintime_t first, sb now = bus_read_4(sc->mem_res, HPET_MAIN_COUNTER); restart: t->next = now + fdiv; - if (t->mode == 1 && (t->caps & HPET_TCAP_PER_INT)) { + if (t->mode == TIMER_PERIODIC && (t->caps & HPET_TCAP_PER_INT)) { t->caps |= HPET_TCNF_TYPE; bus_write_4(sc->mem_res, HPET_TIMER_CAP_CNF(t->num), t->caps | HPET_TCNF_VAL_SET); @@ -254,7 +257,7 @@ hpet_stop(struct eventtimer *et) struct hpet_softc *sc = mt->sc; t = (mt->pcpu_master < 0) ? mt : &sc->t[mt->pcpu_slaves[curcpu]]; - t->mode = 0; + t->mode = TIMER_STOPPED; t->caps &= ~(HPET_TCNF_INT_ENB | HPET_TCNF_TYPE); bus_write_4(sc->mem_res, HPET_TIMER_CAP_CNF(t->num), t->caps); return (0); @@ -268,7 +271,7 @@ hpet_intr_single(void *arg) struct hpet_softc *sc = t->sc; uint32_t now; - if (t->mode == 0) + if (t->mode == TIMER_STOPPED) return (FILTER_STRAY); /* Check that per-CPU timer interrupt reached right CPU. */ if (t->pcpu_cpu >= 0 && t->pcpu_cpu != curcpu) { @@ -282,8 +285,9 @@ hpet_intr_single(void *arg) * Reload timer, hoping that next time may be more lucky * (system will manage proper interrupt binding). */ - if ((t->mode == 1 && (t->caps & HPET_TCAP_PER_INT) == 0) || - t->mode == 2) { + if ((t->mode == TIMER_PERIODIC && + (t->caps & HPET_TCAP_PER_INT) == 0) || + t->mode == TIMER_ONESHOT) { t->next = bus_read_4(sc->mem_res, HPET_MAIN_COUNTER) + sc->freq / 8; bus_write_4(sc->mem_res, HPET_TIMER_COMPARATOR(t->num), @@ -291,7 +295,7 @@ hpet_intr_single(void *arg) } return (FILTER_HANDLED); } - if (t->mode == 1 && + if (t->mode == TIMER_PERIODIC && (t->caps & HPET_TCAP_PER_INT) == 0) { t->next += t->div; now = bus_read_4(sc->mem_res, HPET_MAIN_COUNTER); @@ -299,8 +303,8 @@ hpet_intr_single(void *arg) t->next = now + t->div / 2; bus_write_4(sc->mem_res, HPET_TIMER_COMPARATOR(t->num), t->next); - } else if (t->mode == 2) - t->mode = 0; + } else if (t->mode == TIMER_ONESHOT) + t->mode = TIMER_STOPPED; mt = (t->pcpu_master < 0) ? t : &sc->t[t->pcpu_master]; if (mt->et.et_active) mt->et.et_event_cb(&mt->et, mt->et.et_arg); @@ -529,7 +533,7 @@ hpet_attach(device_t dev) t = &sc->t[i]; t->sc = sc; t->num = i; - t->mode = 0; + t->mode = TIMER_STOPPED; t->intr_rid = -1; t->irq = -1; t->pcpu_cpu = -1; @@ -879,10 +883,11 @@ hpet_resume(device_t dev) } } #endif - if (t->mode == 0) + if (t->mode == TIMER_STOPPED) continue; t->next = bus_read_4(sc->mem_res, HPET_MAIN_COUNTER); - if (t->mode == 1 && (t->caps & HPET_TCAP_PER_INT)) { + if (t->mode == TIMER_PERIODIC && + (t->caps & HPET_TCAP_PER_INT) != 0) { t->caps |= HPET_TCNF_TYPE; t->next += t->div; bus_write_4(sc->mem_res, HPET_TIMER_CAP_CNF(t->num),
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201806220908.w5M98d78023060>