diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2004-12-25 23:02:27 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2004-12-25 23:02:27 +0000 |
commit | f817c58ea799274eb832d25dc61acb5955f9b2d9 (patch) | |
tree | d81a72a842cf99a20e3b22543a17b8e53ad25961 /sys/arch/hp300 | |
parent | f1b1a2a9897fb5e4903d7922e7d05f99ad07b847 (diff) |
Use list and queue macros where applicable to make the code easier to read;
no functional change.
Diffstat (limited to 'sys/arch/hp300')
-rw-r--r-- | sys/arch/hp300/dev/dma.c | 5 | ||||
-rw-r--r-- | sys/arch/hp300/dev/fhpib.c | 8 | ||||
-rw-r--r-- | sys/arch/hp300/dev/hpib.c | 8 | ||||
-rw-r--r-- | sys/arch/hp300/dev/mb89352.c | 4 | ||||
-rw-r--r-- | sys/arch/hp300/dev/nhpib.c | 8 | ||||
-rw-r--r-- | sys/arch/hp300/hp300/autoconf.c | 43 | ||||
-rw-r--r-- | sys/arch/hp300/hp300/intr.c | 16 |
7 files changed, 44 insertions, 48 deletions
diff --git a/sys/arch/hp300/dev/dma.c b/sys/arch/hp300/dev/dma.c index ba2a7cbeba4..15c1f722591 100644 --- a/sys/arch/hp300/dev/dma.c +++ b/sys/arch/hp300/dev/dma.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dma.c,v 1.15 2004/12/16 16:48:44 miod Exp $ */ +/* $OpenBSD: dma.c,v 1.16 2004/12/25 23:02:23 miod Exp $ */ /* $NetBSD: dma.c,v 1.19 1997/05/05 21:02:39 thorpej Exp $ */ /* @@ -310,8 +310,7 @@ dmafree(dq) */ dc->dm_job = NULL; chan = 1 << unit; - for (dn = sc->sc_queue.tqh_first; dn != NULL; - dn = dn->dq_list.tqe_next) { + TAILQ_FOREACH(dn, &sc->sc_queue, dq_list) { if (dn->dq_chan & chan) { /* Found one... */ TAILQ_REMOVE(&sc->sc_queue, dn, dq_list); diff --git a/sys/arch/hp300/dev/fhpib.c b/sys/arch/hp300/dev/fhpib.c index c3dcfbf8c20..2bf82aea1fe 100644 --- a/sys/arch/hp300/dev/fhpib.c +++ b/sys/arch/hp300/dev/fhpib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fhpib.c,v 1.13 2004/09/29 07:35:52 miod Exp $ */ +/* $OpenBSD: fhpib.c,v 1.14 2004/12/25 23:02:23 miod Exp $ */ /* $NetBSD: fhpib.c,v 1.18 1997/05/05 21:04:16 thorpej Exp $ */ /* @@ -466,7 +466,7 @@ fhpibdmadone(arg) hs->sc_flags &= ~(HPIBF_DONE|HPIBF_IO|HPIBF_READ|HPIBF_TIMO); dmafree(hs->sc_dq); - hq = hs->sc_queue.tqh_first; + hq = TAILQ_FIRST(&hs->sc_queue); (hq->hq_intr)(hq->hq_softc); } splx(s); @@ -546,7 +546,7 @@ fhpibintr(arg) if ((fhpibdebug & FDB_DMA) && fhpibdebugunit == sc->sc_dev.dv_unit) printf("fhpibintr: flags %x\n", hs->sc_flags); #endif - hq = hs->sc_queue.tqh_first; + hq = TAILQ_FIRST(&hs->sc_queue); if (hs->sc_flags & HPIBF_IO) { if (hs->sc_flags & HPIBF_TIMO) timeout_del(&sc->sc_dma_to); @@ -651,7 +651,7 @@ fhpibppwatch(arg) if ((hs->sc_flags & HPIBF_PPOLL) == 0) return; - slave = (0x80 >> hs->sc_queue.tqh_first->hq_slave); + slave = (0x80 >> TAILQ_FIRST(&hs->sc_queue)->hq_slave); #ifdef DEBUG if (!doppollint) { if (fhpibppoll(hs) & slave) { diff --git a/sys/arch/hp300/dev/hpib.c b/sys/arch/hp300/dev/hpib.c index 3ef5983265f..d972d9d315e 100644 --- a/sys/arch/hp300/dev/hpib.c +++ b/sys/arch/hp300/dev/hpib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hpib.c,v 1.10 2003/06/02 23:27:44 millert Exp $ */ +/* $OpenBSD: hpib.c,v 1.11 2004/12/25 23:02:24 miod Exp $ */ /* $NetBSD: hpib.c,v 1.16 1997/04/27 20:58:57 thorpej Exp $ */ /* @@ -262,7 +262,7 @@ hpibreq(pdev, hq) TAILQ_INSERT_TAIL(&sc->sc_queue, hq, hq_list); splx(s); - if (sc->sc_queue.tqh_first == hq) + if (TAILQ_FIRST(&sc->sc_queue) == hq) return (1); return (0); @@ -280,7 +280,7 @@ hpibfree(pdev, hq) TAILQ_REMOVE(&sc->sc_queue, hq, hq_list); splx(s); - if ((hq = sc->sc_queue.tqh_first) != NULL) + if ((hq = TAILQ_FIRST(&sc->sc_queue)) != NULL) (*hq->hq_start)(hq->hq_softc); } @@ -394,7 +394,7 @@ hpibstart(arg) struct hpibbus_softc *sc = arg; struct hpibqueue *hq; - hq = sc->sc_queue.tqh_first; + hq = TAILQ_FIRST(&sc->sc_queue); (*hq->hq_go)(hq->hq_softc); } diff --git a/sys/arch/hp300/dev/mb89352.c b/sys/arch/hp300/dev/mb89352.c index a80fd43f805..9f0de06a403 100644 --- a/sys/arch/hp300/dev/mb89352.c +++ b/sys/arch/hp300/dev/mb89352.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mb89352.c,v 1.11 2004/12/22 21:11:12 miod Exp $ */ +/* $OpenBSD: mb89352.c,v 1.12 2004/12/25 23:02:24 miod Exp $ */ /* $NetBSD: mb89352.c,v 1.5 2000/03/23 07:01:31 thorpej Exp $ */ /* NecBSD: mb89352.c,v 1.4 1998/03/14 07:31:20 kmatsuda Exp */ @@ -341,7 +341,7 @@ spc_free_acb(struct spc_softc *sc, struct spc_acb *acb, int flags) * If there were none, wake anybody waiting for one to come free, * starting with queued entries. */ - if (acb->chain.tqe_next == 0) + if (TAILQ_NEXT(acb, chain) == NULL) wakeup(&sc->free_list); splx(s); diff --git a/sys/arch/hp300/dev/nhpib.c b/sys/arch/hp300/dev/nhpib.c index 9cd0f88c727..3053f999a03 100644 --- a/sys/arch/hp300/dev/nhpib.c +++ b/sys/arch/hp300/dev/nhpib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nhpib.c,v 1.13 2004/09/29 07:35:52 miod Exp $ */ +/* $OpenBSD: nhpib.c,v 1.14 2004/12/25 23:02:24 miod Exp $ */ /* $NetBSD: nhpib.c,v 1.17 1997/05/05 21:06:41 thorpej Exp $ */ /* @@ -411,7 +411,7 @@ nhpibreadtimo(arg) hs->sc_flags &= ~(HPIBF_DONE|HPIBF_IO|HPIBF_READ|HPIBF_TIMO); dmafree(hs->sc_dq); - hq = hs->sc_queue.tqh_first; + hq = TAILQ_FIRST(&hs->sc_queue); (hq->hq_intr)(hq->hq_softc); } splx(s); @@ -467,7 +467,7 @@ nhpibintr(arg) stat0 = hd->hpib_mis; stat1 = hd->hpib_lis; - hq = hs->sc_queue.tqh_first; + hq = TAILQ_FIRST(&hs->sc_queue); if (hs->sc_flags & HPIBF_IO) { hd->hpib_mim = 0; @@ -545,7 +545,7 @@ nhpibppwatch(arg) if ((hs->sc_flags & HPIBF_PPOLL) == 0) return; again: - if (nhpibppoll(hs) & (0x80 >> hs->sc_queue.tqh_first->hq_slave)) + if (nhpibppoll(hs) & (0x80 >> TAILQ_FIRST(&hs->sc_queue)->hq_slave)) sc->sc_regs->hpib_mim = MIS_BO; else if (cold) /* timeouts not working yet */ diff --git a/sys/arch/hp300/hp300/autoconf.c b/sys/arch/hp300/hp300/autoconf.c index 20140db6314..7c57c118bde 100644 --- a/sys/arch/hp300/hp300/autoconf.c +++ b/sys/arch/hp300/hp300/autoconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: autoconf.c,v 1.26 2004/08/03 21:46:58 miod Exp $ */ +/* $OpenBSD: autoconf.c,v 1.27 2004/12/25 23:02:24 miod Exp $ */ /* $NetBSD: autoconf.c,v 1.45 1999/04/10 17:31:02 kleink Exp $ */ /* @@ -460,8 +460,7 @@ getdisk(str, len, defpart, devp) if ((dv = parsedisk(str, len, defpart, devp)) == NULL) { printf("use one of:"); - for (dv = alldevs.tqh_first; dv != NULL; - dv = dv->dv_list.tqe_next) { + TAILQ_FOREACH(dv, &alldevs, dv_list) { if (dv->dv_class == DV_DISK) printf(" %s[a-p]", dv->dv_xname); #ifdef NFSCLIENT @@ -498,7 +497,7 @@ parsedisk(str, len, defpart, devp) } else part = defpart; - for (dv = alldevs.tqh_first; dv != NULL; dv = dv->dv_list.tqe_next) { + TAILQ_FOREACH(dv, &alldevs, dv_list) { if (dv->dv_class == DV_DISK && strcmp(str, dv->dv_xname) == 0) { majdev = findblkmajor(dv); @@ -683,8 +682,7 @@ setroot() * `root on nfs'. Find the first network * interface. */ - for (dd = dev_data_list.lh_first; - dd != NULL; dd = dd->dd_list.le_next) { + LIST_FOREACH(dd, &dev_data_list, dd_list) { if (dd->dd_dev->dv_class == DV_IFNET) { /* Got it! */ break; @@ -707,8 +705,7 @@ setroot() snprintf(buf, sizeof buf, "%s%d", rootdevname, DISKUNIT(rootdev)); - for (dv = alldevs.tqh_first; dv != NULL; - dv = dv->dv_list.tqe_next) { + TAILQ_FOREACH(dv, &alldevs, dv_list) { if (strcmp(buf, dv->dv_xname) == 0) { root_device = dv; break; @@ -842,8 +839,7 @@ findbootdev() * always starts at scode 0 and works its way up. */ if (netboot) { - for (dd = dev_data_list.lh_first; dd != NULL; - dd = dd->dd_list.le_next) { + LIST_FOREACH(dd, &dev_data_list, dd_list) { if (dd->dd_dev->dv_class == DV_IFNET) { /* * Found it! @@ -918,8 +914,8 @@ findbootdev_slave(ddlist, ctlr, slave, punit) /* * Find the booted controller. */ - for (cdd = ddlist->lh_first; ctlr != 0 && cdd != NULL; - cdd = cdd->dd_clist.le_next) + for (cdd = LIST_FIRST(ddlist); ctlr != 0 && cdd != LIST_END(ddlist); + cdd = LIST_NEXT(cdd, dd_clist)) ctlr--; if (cdd == NULL) { /* @@ -932,8 +928,7 @@ findbootdev_slave(ddlist, ctlr, slave, punit) * Now find the device with the right slave/punit * that's a child of the controller. */ - for (dd = dev_data_list.lh_first; dd != NULL; - dd = dd->dd_list.le_next) { + LIST_FOREACH(dd, &dev_data_list, dd_list) { /* * "sd" / "st" / "cd" -> "scsibus" -> "spc" * "hd" -> "hpibbus" -> "fhpib" @@ -1015,8 +1010,9 @@ setbootdev() * "hd" -> "hpibbus" -> "fhpib" * "sd" / "cd" / "st" -> "scsibus" -> "spc" */ - for (cdd = dev_data_list_hpib.lh_first, ctlr = 0; - cdd != NULL; cdd = cdd->dd_clist.le_next, ctlr++) { + for (cdd = LIST_FIRST(&dev_data_list_hpib), ctlr = 0; + cdd != LIST_END(&dev_data_list_hpib); + cdd = LIST_NEXT(cdd, dd_clist), ctlr++) { if (cdd->dd_dev == root_device->dv_parent->dv_parent) { /* * Found it! @@ -1029,9 +1025,10 @@ setbootdev() out: /* Don't need this anymore. */ - for (dd = dev_data_list.lh_first; dd != NULL; ) { + for (dd = LIST_FIRST(&dev_data_list); + dd != LIST_END(&dev_data_list); ) { cdd = dd; - dd = dd->dd_list.le_next; + dd = LIST_NEXT(dd, dd_list); free(cdd, M_DEVBUF); } } @@ -1045,7 +1042,7 @@ dev_data_lookup(dev) { struct dev_data *dd; - for (dd = dev_data_list.lh_first; dd != NULL; dd = dd->dd_list.le_next) + LIST_FOREACH(dd, &dev_data_list, dd_list) if (dd->dd_dev == dev) return (dd); @@ -1068,12 +1065,10 @@ dev_data_insert(dd, ddlist) } #endif - de = ddlist->lh_first; - /* * Just insert at head if list is empty. */ - if (de == NULL) { + if (LIST_EMPTY(ddlist)) { LIST_INSERT_HEAD(ddlist, dd, dd_clist); return; } @@ -1083,7 +1078,9 @@ dev_data_insert(dd, ddlist) * is greater than ours. When we find it, insert ourselves * into the list before it. */ - for (; de->dd_clist.le_next != NULL; de = de->dd_clist.le_next) { + for (de = LIST_FIRST(ddlist); + LIST_NEXT(de, dd_clist) != LIST_END(ddlist); + de = LIST_NEXT(de, dd_clist)) { if (de->dd_scode > dd->dd_scode) { LIST_INSERT_BEFORE(de, dd, dd_clist); return; diff --git a/sys/arch/hp300/hp300/intr.c b/sys/arch/hp300/hp300/intr.c index d1b3c4d3933..41cc5a693e7 100644 --- a/sys/arch/hp300/hp300/intr.c +++ b/sys/arch/hp300/hp300/intr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: intr.c,v 1.14 2004/12/24 22:50:29 miod Exp $ */ +/* $OpenBSD: intr.c,v 1.15 2004/12/25 23:02:24 miod Exp $ */ /* $NetBSD: intr.c,v 1.5 1998/02/16 20:58:30 thorpej Exp $ */ /*- @@ -100,8 +100,7 @@ intr_computeipl() (PSL_S|PSL_IPL3); for (ipl = 0; ipl < NISR; ipl++) { - for (isr = isr_list[ipl].lh_first; isr != NULL; - isr = isr->isr_link.le_next) { + LIST_FOREACH(isr, &isr_list[ipl], isr_link) { /* * Bump up the level for a given priority, * if necessary. @@ -191,7 +190,7 @@ intr_establish(struct isr *isr, const char *name) * at the head of the list. */ list = &isr_list[isr->isr_ipl]; - if (list->lh_first == NULL) { + if (LIST_EMPTY(list)) { LIST_INSERT_HEAD(list, isr, isr_link); goto compute; } @@ -201,8 +200,9 @@ intr_establish(struct isr *isr, const char *name) * and place ourselves after any ISRs with our current (or * higher) priority. */ - for (curisr = list->lh_first; curisr->isr_link.le_next != NULL; - curisr = curisr->isr_link.le_next) { + for (curisr = LIST_FIRST(list); + LIST_NEXT(curisr, isr_link) != LIST_END(list); + curisr = LIST_NEXT(curisr, isr_link)) { if (isr->isr_priority > curisr->isr_priority) { LIST_INSERT_BEFORE(curisr, isr, isr_link); goto compute; @@ -254,7 +254,7 @@ intr_dispatch(evec) uvmexp.intrs++; list = &isr_list[ipl]; - if (list->lh_first == NULL) { + if (LIST_EMPTY(list)) { printf("intr_dispatch: ipl %d unexpected\n", ipl); if (++unexpected > 10) panic("intr_dispatch: too many unexpected interrupts"); @@ -263,7 +263,7 @@ intr_dispatch(evec) handled = 0; /* Give all the handlers a chance. */ - for (isr = list->lh_first ; isr != NULL; isr = isr->isr_link.le_next) { + LIST_FOREACH(isr, list, isr_link) { rc = (*isr->isr_func)(isr->isr_arg); if (rc > 0) isr->isr_count.ec_count++; |