diff options
author | simokawa <simokawa@FreeBSD.org> | 2003-02-01 14:42:49 +0000 |
---|---|---|
committer | simokawa <simokawa@FreeBSD.org> | 2003-02-01 14:42:49 +0000 |
commit | 5790015ee5af3be4881a7c551011f422bf8e697a (patch) | |
tree | 4b21e97d57a5e183801cf31e4f90b629d703c6f0 | |
parent | e8efa7328e487806fb77d3ec54bf5fa5f8b017ed (diff) | |
download | FreeBSD-src-5790015ee5af3be4881a7c551011f422bf8e697a.zip FreeBSD-src-5790015ee5af3be4881a7c551011f422bf8e697a.tar.gz |
- replace timeout with callout_*.
- replace TAILQ with STAILQ for device list.
- some clean up.
-rw-r--r-- | sys/dev/firewire/firewire.c | 65 | ||||
-rw-r--r-- | sys/dev/firewire/firewire.h | 2 | ||||
-rw-r--r-- | sys/dev/firewire/firewirereg.h | 10 | ||||
-rw-r--r-- | sys/dev/firewire/fwdev.c | 10 | ||||
-rw-r--r-- | sys/dev/firewire/fwohci.c | 4 | ||||
-rw-r--r-- | sys/dev/firewire/sbp.c | 13 |
6 files changed, 51 insertions, 53 deletions
diff --git a/sys/dev/firewire/firewire.c b/sys/dev/firewire/firewire.c index 5c9652d6..4311643 100644 --- a/sys/dev/firewire/firewire.c +++ b/sys/dev/firewire/firewire.c @@ -133,7 +133,7 @@ fw_noderesolve_nodeid(struct firewire_comm *fc, int dst) int s; s = splfw(); - TAILQ_FOREACH(fwdev, &fc->devices, link) + STAILQ_FOREACH(fwdev, &fc->devices, link) if (fwdev->dst == dst) break; splx(s); @@ -153,8 +153,8 @@ fw_noderesolve_eui64(struct firewire_comm *fc, struct fw_eui64 eui) int s; s = splfw(); - TAILQ_FOREACH(fwdev, &fc->devices, link) - if (fwdev->eui.hi == eui.hi && fwdev->eui.lo == eui.lo) + STAILQ_FOREACH(fwdev, &fc->devices, link) + if (FW_EUI64_EQUAL(fwdev->eui, eui)) break; splx(s); @@ -366,14 +366,18 @@ firewire_attach( device_t dev ) #else sc->dev[i] = d; #endif - sc->fc->timeouthandle = timeout((timeout_t *)sc->fc->timeout, (void *)sc->fc, hz * 10); - - callout_init(&sc->fc->busprobe_callout #if __FreeBSD_version >= 500000 - , /* mpsafe? */ 0); +#define CALLOUT_INIT(x) callout_init(x, 0 /* mpsafe */) #else - ); +#define CALLOUT_INIT(x) callout_init(x) #endif + CALLOUT_INIT(&sc->fc->timeout_callout); + CALLOUT_INIT(&sc->fc->bmr_callout); + CALLOUT_INIT(&sc->fc->retry_probe_callout); + CALLOUT_INIT(&sc->fc->busprobe_callout); + + callout_reset(&sc->fc->timeout_callout, hz * 10, + (void *)sc->fc->timeout, (void *)sc->fc); /* Locate our children */ bus_generic_probe(dev); @@ -426,7 +430,10 @@ firewire_detach( device_t dev ) } #endif /* XXX xfree_free and untimeout on all xfers */ - untimeout((timeout_t *)sc->fc->timeout, sc->fc, sc->fc->timeouthandle); + callout_stop(&sc->fc->timeout_callout); + callout_stop(&sc->fc->bmr_callout); + callout_stop(&sc->fc->retry_probe_callout); + callout_stop(&sc->fc->busprobe_callout); free(sc->fc->topology_map, M_DEVBUF); free(sc->fc->speed_map, M_DEVBUF); bus_generic_detach(dev); @@ -451,7 +458,7 @@ fw_busreset(struct firewire_comm *fc) switch(fc->status){ case FWBUSMGRELECT: - untimeout((timeout_t *)fw_try_bmr, (void *)fc, fc->bmrhandle); + callout_stop(&fc->bmr_callout); break; default: break; @@ -612,7 +619,7 @@ void fw_init(struct firewire_comm *fc) CSRARC(fc, SPED_MAP) = 0x3f1 << 16; CSRARC(fc, SPED_MAP + 4) = 1; - TAILQ_INIT(&fc->devices); + STAILQ_INIT(&fc->devices); STAILQ_INIT(&fc->pending); /* Initialize csr ROM work space */ @@ -1049,8 +1056,8 @@ void fw_sidrcv(struct firewire_comm* fc, caddr_t buf, u_int len, u_int off) CSRARC(fc, BUS_MGR_ID) = fc->set_bmr(fc, fc->irm); } else { fc->status = FWBUSMGRELECT; - fc->bmrhandle = timeout((timeout_t *)fw_try_bmr, - (void *)fc, hz / 8); + callout_reset(&fc->bmr_callout, hz/8, + (void *)fw_try_bmr, (void *)fc); } } else { fc->status = FWBUSMGRDONE; @@ -1085,15 +1092,15 @@ fw_bus_probe(struct firewire_comm *fc) * Invalidate all devices, just after bus reset. Devices * to be removed has not been seen longer time. */ - for(fwdev = TAILQ_FIRST(&fc->devices); fwdev != NULL; fwdev = next) { - next = TAILQ_NEXT(fwdev, link); - if(fwdev->status != FWDEVINVAL){ + for (fwdev = STAILQ_FIRST(&fc->devices); fwdev != NULL; fwdev = next) { + next = STAILQ_NEXT(fwdev, link); + if (fwdev->status != FWDEVINVAL) { fwdev->status = FWDEVINVAL; fwdev->rcnt = 0; - }else if(fwdev->rcnt < FW_MAXDEVRCNT){ + } else if(fwdev->rcnt < FW_MAXDEVRCNT) { fwdev->rcnt ++; - }else{ - TAILQ_REMOVE(&fc->devices, fwdev, link); + } else { + STAILQ_REMOVE(&fc->devices, fwdev, fw_device, link); free(fwdev, M_DEVBUF); } } @@ -1146,12 +1153,9 @@ loop: fc->ongoaddr = CSRROMOFF + 0x10; addr = 0xf0000000 | fc->ongoaddr; }else if(fc->ongodev == NULL){ - for(fwdev = TAILQ_FIRST(&fc->devices); fwdev != NULL; - fwdev = TAILQ_NEXT(fwdev, link)){ - if(fwdev->eui.hi == fc->ongoeui.hi && fwdev->eui.lo == fc->ongoeui.lo){ + STAILQ_FOREACH(fwdev, &fc->devices, link) + if (FW_EUI64_EQUAL(fwdev->eui, fc->ongoeui)) break; - } - } if(fwdev != NULL){ fwdev->dst = fc->ongonode; fwdev->status = FWDEVATTACHED; @@ -1177,7 +1181,7 @@ loop: #endif pfwdev = NULL; - TAILQ_FOREACH(tfwdev, &fc->devices, link) { + STAILQ_FOREACH(tfwdev, &fc->devices, link) { if (tfwdev->eui.hi > fwdev->eui.hi || (tfwdev->eui.hi == fwdev->eui.hi && tfwdev->eui.lo > fwdev->eui.lo)) @@ -1185,9 +1189,9 @@ loop: pfwdev = tfwdev; } if (pfwdev == NULL) - TAILQ_INSERT_HEAD(&fc->devices, fwdev, link); + STAILQ_INSERT_HEAD(&fc->devices, fwdev, link); else - TAILQ_INSERT_AFTER(&fc->devices, pfwdev, fwdev, link); + STAILQ_INSERT_AFTER(&fc->devices, pfwdev, fwdev, link); device_printf(fc->bdev, "New %s device ID:%08x%08x\n", linkspeed[fwdev->speed], @@ -1479,8 +1483,7 @@ fw_attach_dev(struct firewire_comm *fc) struct firewire_dev_comm *fdc; u_int32_t spec, ver; - for(fwdev = TAILQ_FIRST(&fc->devices); fwdev != NULL; - fwdev = TAILQ_NEXT(fwdev, link)){ + STAILQ_FOREACH(fwdev, &fc->devices, link) { if(fwdev->status == FWDEVINIT){ spec = getcsrdata(fwdev, CSRKEY_SPEC); if(spec == 0) @@ -1567,8 +1570,8 @@ fw_attach_dev(struct firewire_comm *fc) printf("fw_attach_dev: %d pending handlers called\n", i); if (fc->retry_count > 0) { printf("retry_count = %d\n", fc->retry_count); - fc->retry_probe_handle = timeout((timeout_t *)fc->ibr, - (void *)fc, hz*2); + callout_reset(&fc->retry_probe_callout, hz*2, + (void *)fc->ibr, (void *)fc); } return; } diff --git a/sys/dev/firewire/firewire.h b/sys/dev/firewire/firewire.h index e07dfd7..f96e331 100644 --- a/sys/dev/firewire/firewire.h +++ b/sys/dev/firewire/firewire.h @@ -315,6 +315,8 @@ struct fw_eui64 { ((eui)->hi >> (8*(3-(x)))): \ ((eui)->lo >> (8*(7-(x)))) \ ) & 0xff) +#define FW_EUI64_EQUAL(x, y) \ + ((x).hi == (y).hi && (x).lo == (y).lo) struct fw_asyreq { struct fw_asyreq_t{ diff --git a/sys/dev/firewire/firewirereg.h b/sys/dev/firewire/firewirereg.h index 568bff7..1c71eca 100644 --- a/sys/dev/firewire/firewirereg.h +++ b/sys/dev/firewire/firewirereg.h @@ -65,7 +65,7 @@ struct fw_device{ #define FWDEVINIT 1 #define FWDEVATTACHED 2 #define FWDEVINVAL 3 - TAILQ_ENTRY(fw_device) link; + STAILQ_ENTRY(fw_device) link; #if 0 LIST_HEAD(, fw_xfer) txqueue; LIST_HEAD(, fw_xfer) rxqueue; @@ -141,7 +141,7 @@ struct firewire_comm{ *arq, *atq, *ars, *ats, *it[FW_MAX_DMACH],*ir[FW_MAX_DMACH]; STAILQ_HEAD(, tlabel) tlabels[0x40]; STAILQ_HEAD(, fw_bind) binds; - TAILQ_HEAD(, fw_device) devices; + STAILQ_HEAD(, fw_device) devices; STAILQ_HEAD(, fw_xfer) pending; volatile u_int32_t *sid_buf; u_int sid_cnt; @@ -152,9 +152,9 @@ struct firewire_comm{ struct fw_topology_map *topology_map; struct fw_speed_map *speed_map; struct callout busprobe_callout; - struct callout_handle bmrhandle; - struct callout_handle timeouthandle; - struct callout_handle retry_probe_handle; + struct callout bmr_callout; + struct callout timeout_callout; + struct callout retry_probe_callout; u_int32_t (*cyctimer) __P((struct firewire_comm *)); void (*ibr) __P((struct firewire_comm *)); u_int32_t (*set_bmr) __P((struct firewire_comm *, u_int32_t)); diff --git a/sys/dev/firewire/fwdev.c b/sys/dev/firewire/fwdev.c index 0a74018..4652eb6 100644 --- a/sys/dev/firewire/fwdev.c +++ b/sys/dev/firewire/fwdev.c @@ -841,8 +841,7 @@ error: devinfo->status = 0; /* XXX */ devinfo->eui.hi = sc->fc->eui.hi; devinfo->eui.lo = sc->fc->eui.lo; - for (fwdev = TAILQ_FIRST(&sc->fc->devices); fwdev != NULL; - fwdev = TAILQ_NEXT(fwdev, link)) { + STAILQ_FOREACH(fwdev, &sc->fc->devices, link) { if(len < FW_MAX_DEVLST){ devinfo = &fwdevlst->dev[len++]; devinfo->dst = fwdev->dst; @@ -861,12 +860,9 @@ error: (sc->fc->topology_map->crc_len + 1) * 4); break; case FW_GCROM: - for (fwdev = TAILQ_FIRST(&sc->fc->devices); fwdev != NULL; - fwdev = TAILQ_NEXT(fwdev, link)) { - if (fwdev->eui.hi == crom_buf->eui.hi && - fwdev->eui.lo == crom_buf->eui.lo) + STAILQ_FOREACH(fwdev, &sc->fc->devices, link) + if (FW_EUI64_EQUAL(fwdev->eui, crom_buf->eui)) break; - } if (fwdev == NULL) { err = FWNODE_INVAL; break; diff --git a/sys/dev/firewire/fwohci.c b/sys/dev/firewire/fwohci.c index 2c0a267..2f196da 100644 --- a/sys/dev/firewire/fwohci.c +++ b/sys/dev/firewire/fwohci.c @@ -718,8 +718,8 @@ fwohci_timeout(void *arg) struct fwohci_softc *sc; sc = (struct fwohci_softc *)arg; - sc->fc.timeouthandle = timeout(fwohci_timeout, - (void *)sc, FW_XFERTIMEOUT * hz * 10); + callout_reset(&sc->fc.timeout_callout, FW_XFERTIMEOUT * hz * 10, + (void *)fwohci_timeout, (void *)sc); } u_int32_t diff --git a/sys/dev/firewire/sbp.c b/sys/dev/firewire/sbp.c index 1b63057..81d5711 100644 --- a/sys/dev/firewire/sbp.c +++ b/sys/dev/firewire/sbp.c @@ -669,11 +669,9 @@ END_DEBUG /* Gabage Collection */ for(i = 0 ; i < SBP_NUM_TARGETS ; i ++){ target = &sbp->targets[i]; - for( fwdev = TAILQ_FIRST(&sbp->fd.fc->devices); - fwdev != NULL; fwdev = TAILQ_NEXT(fwdev, link)){ - if(target->fwdev == NULL) break; - if(target->fwdev == fwdev) break; - } + STAILQ_FOREACH(fwdev, &sbp->fd.fc->devices, link) + if (target->fwdev == NULL || target->fwdev == fwdev) + break; if(fwdev == NULL){ /* device has removed in lower driver */ sbp_cam_detach_target(target); @@ -685,8 +683,7 @@ END_DEBUG } } /* traverse device list */ - for( fwdev = TAILQ_FIRST(&sbp->fd.fc->devices); - fwdev != NULL; fwdev = TAILQ_NEXT(fwdev, link)){ + STAILQ_FOREACH(fwdev, &sbp->fd.fc->devices, link) { SBP_DEBUG(0) printf("sbp_post_explore: EUI:%08x%08x ", fwdev->eui.hi, fwdev->eui.lo); @@ -1781,7 +1778,7 @@ sbp_cam_detach_target(struct sbp_target *target) SBP_DEBUG(0) printf("sbp_detach_target %d\n", target->target_id); END_DEBUG - for (i=0; i < target->num_lun; i++) { + for (i = 0; i < target->num_lun; i++) { sdev = &target->luns[i]; if (sdev->status == SBP_DEV_RESET || sdev->status == SBP_DEV_DEAD) |