From owner-svn-src-all@freebsd.org Thu May 3 13:14:32 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 298DAFAAD84; Thu, 3 May 2018 13:14:32 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id CB5FB7BF2F; Thu, 3 May 2018 13:14:31 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C65902044A; Thu, 3 May 2018 13:14:31 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w43DEVFR071826; Thu, 3 May 2018 13:14:31 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w43DEVdH071825; Thu, 3 May 2018 13:14:31 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201805031314.w43DEVdH071825@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Thu, 3 May 2018 13:14:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r333209 - head/sys/dev/acpica X-SVN-Group: head X-SVN-Commit-Author: avg X-SVN-Commit-Paths: head/sys/dev/acpica X-SVN-Commit-Revision: 333209 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2018 13:14:32 -0000 Author: avg Date: Thu May 3 13:14:31 2018 New Revision: 333209 URL: https://svnweb.freebsd.org/changeset/base/333209 Log: hpet: use macros instead of magic values for the timer mode MFC after: 1 week Modified: head/sys/dev/acpica/acpi_hpet.c Modified: head/sys/dev/acpica/acpi_hpet.c ============================================================================== --- head/sys/dev/acpica/acpi_hpet.c Thu May 3 10:17:37 2018 (r333208) +++ head/sys/dev/acpica/acpi_hpet.c Thu May 3 13:14:31 2018 (r333209) @@ -96,6 +96,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; @@ -206,10 +209,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) @@ -222,7 +225,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); @@ -253,7 +256,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); @@ -267,7 +270,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) { @@ -281,8 +284,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), @@ -290,7 +294,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); @@ -298,8 +302,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); @@ -528,7 +532,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; @@ -878,10 +882,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),