diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2010-11-02 14:37:57 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2010-11-02 14:37:57 +0000 |
commit | 86211cdd82533b35880c9856e39f699656bba1cb (patch) | |
tree | 60805d42ebe68856c450e064c0f5774d01162fd8 /sys | |
parent | 903ff5c04661ec38d50685a7a8f4b9dfe457aa89 (diff) |
Consolidate duplicated code removing things from the 'going' queue.
No functional change.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/ic/trm.c | 48 |
1 files changed, 22 insertions, 26 deletions
diff --git a/sys/dev/ic/trm.c b/sys/dev/ic/trm.c index 4156bc0f56f..0f5e958a3a1 100644 --- a/sys/dev/ic/trm.c +++ b/sys/dev/ic/trm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trm.c,v 1.24 2010/11/02 14:17:27 krw Exp $ +/* $OpenBSD: trm.c,v 1.25 2010/11/02 14:37:56 krw Exp $ * ------------------------------------------------------------ * O.S : OpenBSD * File Name : trm.c @@ -106,7 +106,7 @@ void trm_RequestSense(struct trm_softc *, struct trm_scsi_req_q *); void trm_initAdapter (struct trm_softc *); void trm_Disconnect (struct trm_softc *); void trm_Reselect (struct trm_softc *); -void trm_GoingSRB_Done (struct trm_softc *); +void trm_GoingSRB_Done (struct trm_softc *, struct trm_dcb *); void trm_ScsiRstDetect (struct trm_softc *); void trm_ResetSCSIBus (struct trm_softc *); void trm_reset (struct trm_softc *); @@ -614,7 +614,7 @@ trm_reset (struct trm_softc *sc) bus_space_write_2(iot, ioh, TRM_S1040_SCSI_CONTROL, DO_CLRFIFO); trm_ResetAllDevParam(sc); - trm_GoingSRB_Done(sc); + trm_GoingSRB_Done(sc, NULL); sc->pActiveDCB = NULL; /* @@ -1757,7 +1757,7 @@ void trm_Disconnect(struct trm_softc *sc) { const bus_space_handle_t ioh = sc->sc_iohandle; - struct trm_scsi_req_q *pSRB, *pNextSRB; + struct trm_scsi_req_q *pSRB; const bus_space_tag_t iot = sc->sc_iotag; struct trm_dcb *pDCB; int j; @@ -1789,22 +1789,7 @@ trm_Disconnect(struct trm_softc *sc) break; case TRM_ABORT_SENT: - pSRB = TAILQ_FIRST(&sc->goingSRB); - while (pSRB != NULL) { - /* - * Need to save pNextSRB because trm_FinishSRB() puts - * pSRB in freeSRB queue, and thus its links no longer - * point to members of the goingSRB queue. This is why - * TAILQ_FOREACH() will not work for this traversal. - */ - pNextSRB = TAILQ_NEXT(pSRB, link); - if (pSRB->pSRBDCB == pDCB) { - /* TODO XXXX: Is TIMED_OUT the best state to report? */ - pSRB->SRBFlag |= TRM_SCSI_TIMED_OUT; - trm_FinishSRB(sc, pSRB); - } - pSRB = pNextSRB; - } + trm_GoingSRB_Done(sc, pDCB); break; case TRM_START: @@ -2166,16 +2151,27 @@ trm_ReleaseSRB(struct trm_softc *sc, struct trm_scsi_req_q *pSRB) * ------------------------------------------------------------ */ void -trm_GoingSRB_Done(struct trm_softc *sc) +trm_GoingSRB_Done(struct trm_softc *sc, struct trm_dcb *pDCB) { - struct trm_scsi_req_q *pSRB; + struct trm_scsi_req_q *pSRB, *pNextSRB; /* ASSUME we are inside a splbio()/splx() pair */ - while ((pSRB = TAILQ_FIRST(&sc->goingSRB)) != NULL) { - /* TODO XXXX: Is TIMED_OUT the best status? */ - pSRB->SRBFlag |= TRM_SCSI_TIMED_OUT; - trm_FinishSRB(sc, pSRB); + pSRB = TAILQ_FIRST(&sc->goingSRB); + while (pSRB != NULL) { + /* + * Need to save pNextSRB because trm_FinishSRB() puts + * pSRB in freeSRB queue, and thus its links no longer + * point to members of the goingSRB queue. This is why + * TAILQ_FOREACH() will not work for this traversal. + */ + pNextSRB = TAILQ_NEXT(pSRB, link); + if (pDCB == NULL || pSRB->pSRBDCB == pDCB) { + /* TODO XXXX: Is TIMED_OUT the best state to report? */ + pSRB->SRBFlag |= TRM_SCSI_TIMED_OUT; + trm_FinishSRB(sc, pSRB); + } + pSRB = pNextSRB; } } |