From 6f7bf811629949f5c95dfb3b40982cfb39e2230f Mon Sep 17 00:00:00 2001 From: Michael Knudsen Date: Wed, 16 Apr 2008 16:08:40 +0000 Subject: Use the timeout(9) API the right way: Don't initialize the timeout cookie all the time, and only call timeout_del if we're not going to timeout_add right away. Testing by johan@, oga@, sthen@, and possibly some more people (thanks). Ok krw@, oga@, sthen@. --- sys/dev/usb/ehci.c | 10 +++------- sys/dev/usb/ukbd.c | 6 +++--- 2 files changed, 6 insertions(+), 10 deletions(-) (limited to 'sys/dev/usb') diff --git a/sys/dev/usb/ehci.c b/sys/dev/usb/ehci.c index 9ab378fb69f..992b48c05e4 100644 --- a/sys/dev/usb/ehci.c +++ b/sys/dev/usb/ehci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ehci.c,v 1.77 2007/06/15 11:41:47 mbalmer Exp $ */ +/* $OpenBSD: ehci.c,v 1.78 2008/04/16 16:08:39 mk Exp $ */ /* $NetBSD: ehci.c,v 1.66 2004/06/30 03:11:56 mycroft Exp $ */ /* @@ -472,8 +472,8 @@ ehci_init(ehci_softc_t *sc) sc->sc_async_head = sqh; EOWRITE4(sc, EHCI_ASYNCLISTADDR, sqh->physaddr | EHCI_LINK_QH); - timeout_set(&sc->sc_tmo_pcd, NULL, NULL); - timeout_set(&sc->sc_tmo_intrlist, NULL, NULL); + timeout_set(&sc->sc_tmo_pcd, ehci_pcd_enable, sc); + timeout_set(&sc->sc_tmo_intrlist, ehci_intrlist_timeout, sc); rw_init(&sc->sc_doorbell_lock, "ehcidb"); @@ -587,8 +587,6 @@ ehci_intr1(ehci_softc_t *sc) */ ehci_pcd_able(sc, 0); /* Do not allow RHSC interrupts > 1 per second */ - timeout_del(&sc->sc_tmo_pcd); - timeout_set(&sc->sc_tmo_pcd, ehci_pcd_enable, sc); timeout_add(&sc->sc_tmo_pcd, hz); eintrs &= ~EHCI_STS_PCD; } @@ -679,8 +677,6 @@ ehci_softintr(void *v) /* Schedule a callout to catch any dropped transactions. */ if ((sc->sc_flags & EHCIF_DROPPED_INTR_WORKAROUND) && !LIST_EMPTY(&sc->sc_intrhead)) { - timeout_del(&sc->sc_tmo_intrlist); - timeout_set(&sc->sc_tmo_intrlist, ehci_intrlist_timeout, sc); timeout_add(&sc->sc_tmo_intrlist, hz); } diff --git a/sys/dev/usb/ukbd.c b/sys/dev/usb/ukbd.c index d73e1bb7ca9..ff6c16459cd 100644 --- a/sys/dev/usb/ukbd.c +++ b/sys/dev/usb/ukbd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ukbd.c,v 1.39 2008/01/24 14:50:38 robert Exp $ */ +/* $OpenBSD: ukbd.c,v 1.40 2008/04/16 16:08:39 mk Exp $ */ /* $NetBSD: ukbd.c,v 1.85 2003/03/11 16:44:00 augustss Exp $ */ /* @@ -735,12 +735,12 @@ ukbd_decode(struct ukbd_softc *sc, struct ukbd_data *ud) s = spltty(); wskbd_rawinput(sc->sc_wskbddev, cbuf, j); splx(s); - timeout_del(&sc->sc_rawrepeat_ch); if (npress != 0) { sc->sc_nrep = npress; timeout_add(&sc->sc_rawrepeat_ch, hz * REP_DELAY1 / 1000); - } + } else + timeout_del(&sc->sc_rawrepeat_ch); return; } #endif -- cgit v1.2.3