diff --git a/sys/dev/eisa/ahb.c b/sys/dev/eisa/ahb.c index f2f2d7c3f452..f727a3c97552 100644 --- a/sys/dev/eisa/ahb.c +++ b/sys/dev/eisa/ahb.c @@ -1,4 +1,4 @@ -/* $NetBSD: ahb.c,v 1.26 1998/12/05 19:43:48 mjacob Exp $ */ +/* $NetBSD: ahb.c,v 1.27 1998/12/09 08:43:30 thorpej Exp $ */ #include "opt_ddb.h" @@ -114,8 +114,7 @@ struct ahb_softc { struct scsipi_link sc_link; struct scsipi_adapter sc_adapter; - LIST_HEAD(, scsipi_xfer) sc_queue; - struct scsipi_xfer *sc_queuelast; + TAILQ_HEAD(, scsipi_xfer) sc_queue; }; /* @@ -142,8 +141,6 @@ int ahb_scsi_cmd __P((struct scsipi_xfer *)); int ahb_poll __P((struct ahb_softc *, struct scsipi_xfer *, int)); void ahb_timeout __P((void *)); int ahb_create_ecbs __P((struct ahb_softc *, struct ahb_ecb *, int)); -void ahb_enqueue __P((struct ahb_softc *, struct scsipi_xfer *, int)); -struct scsipi_xfer *ahb_dequeue __P((struct ahb_softc *)); integrate void ahb_reset_ecb __P((struct ahb_softc *, struct ahb_ecb *)); integrate int ahb_init_ecb __P((struct ahb_softc *, struct ahb_ecb *)); @@ -241,7 +238,7 @@ ahbattach(parent, self, aux) panic("ahbattach: ahb_find failed!"); TAILQ_INIT(&sc->sc_free_ecb); - LIST_INIT(&sc->sc_queue); + TAILQ_INIT(&sc->sc_queue); if (ahb_init(sc) != 0) { /* Error during initialization! */ @@ -293,47 +290,6 @@ ahbattach(parent, self, aux) config_found(self, &sc->sc_link, scsiprint); } -/* - * Insert a scsipi_xfer into the software queue. We overload xs->free_list - * to avoid having to allocate additional resources (since we're used - * only during resource shortages anyhow. - */ -void -ahb_enqueue(sc, xs, infront) - struct ahb_softc *sc; - struct scsipi_xfer *xs; - int infront; -{ - - if (infront || sc->sc_queue.lh_first == NULL) { - if (sc->sc_queue.lh_first == NULL) - sc->sc_queuelast = xs; - LIST_INSERT_HEAD(&sc->sc_queue, xs, free_list); - return; - } - - LIST_INSERT_AFTER(sc->sc_queuelast, xs, free_list); - sc->sc_queuelast = xs; -} - -/* - * Pull a scsipi_xfer off the front of the software queue. - */ -struct scsipi_xfer * -ahb_dequeue(sc) - struct ahb_softc *sc; -{ - struct scsipi_xfer *xs; - - xs = sc->sc_queue.lh_first; - LIST_REMOVE(xs, free_list); - - if (sc->sc_queue.lh_first == NULL) - sc->sc_queuelast = NULL; - - return (xs); -} - /* * Function to send a command out through a mailbox */ @@ -716,7 +672,7 @@ done: * NOTE: ahb_scsi_cmd() relies on our calling it with * the first entry in the queue. */ - if ((xs = sc->sc_queue.lh_first) != NULL) + if ((xs = TAILQ_FIRST(&sc->sc_queue)) != NULL) (void) ahb_scsi_cmd(xs); } @@ -907,8 +863,8 @@ ahb_scsi_cmd(xs) * If we're running the queue from ahb_done(), we've been * called with the first queue entry as our argument. */ - if (xs == sc->sc_queue.lh_first) { - xs = ahb_dequeue(sc); + if (xs == TAILQ_FIRST(&sc->sc_queue)) { + TAILQ_REMOVE(&sc->sc_queue, xs, adapter_q); fromqueue = 1; goto get_ecb; } @@ -919,7 +875,7 @@ ahb_scsi_cmd(xs) /* * If there are jobs in the queue, run them first. */ - if (sc->sc_queue.lh_first != NULL) { + if (TAILQ_FIRST(&sc->sc_queue) != NULL) { /* * If we can't queue, we have to abort, since * we have to preserve order. @@ -933,8 +889,9 @@ ahb_scsi_cmd(xs) /* * Swap with the first queue entry. */ - ahb_enqueue(sc, xs, 0); - xs = ahb_dequeue(sc); + TAILQ_INSERT_TAIL(&sc->sc_queue, xs, adapter_q); + xs = TAILQ_FIRST(&sc->sc_queue); + TAILQ_REMOVE(&sc->sc_queue, xs, adapter_q); fromqueue = 1; } @@ -959,7 +916,10 @@ ahb_scsi_cmd(xs) * Stuff ourselves into the queue, in front * if we came off in the first place. */ - ahb_enqueue(sc, xs, fromqueue); + if (fromqueue) + TAILQ_INSERT_HEAD(&sc->sc_queue, xs, adapter_q); + else + TAILQ_INSERT_TAIL(&sc->sc_queue, xs, adapter_q); splx(s); return (SUCCESSFULLY_QUEUED); } diff --git a/sys/dev/ic/adv.c b/sys/dev/ic/adv.c index 13d4a3dfb37f..e74ffc98fc9a 100644 --- a/sys/dev/ic/adv.c +++ b/sys/dev/ic/adv.c @@ -1,4 +1,4 @@ -/* $NetBSD: adv.c,v 1.8 1998/12/05 19:43:49 mjacob Exp $ */ +/* $NetBSD: adv.c,v 1.9 1998/12/09 08:47:17 thorpej Exp $ */ /* * Generic driver for the Advanced Systems Inc. Narrow SCSI controllers @@ -73,9 +73,6 @@ /******************************************************************************/ -static void adv_enqueue __P((ASC_SOFTC *, struct scsipi_xfer *, int)); -static struct scsipi_xfer *adv_dequeue __P((ASC_SOFTC *)); - static int adv_alloc_ccbs __P((ASC_SOFTC *)); static int adv_create_ccbs __P((ASC_SOFTC *, ADV_CCB *, int)); static void adv_free_ccb __P((ASC_SOFTC *, ADV_CCB *)); @@ -118,48 +115,6 @@ struct scsipi_device adv_dev = /******************************************************************************/ -/* - * Insert a scsipi_xfer into the software queue. We overload xs->free_list - * to avoid having to allocate additional resources (since we're used - * only during resource shortages anyhow. - */ -static void -adv_enqueue(sc, xs, infront) - ASC_SOFTC *sc; - struct scsipi_xfer *xs; - int infront; -{ - - if (infront || sc->sc_queue.lh_first == NULL) { - if (sc->sc_queue.lh_first == NULL) - sc->sc_queuelast = xs; - LIST_INSERT_HEAD(&sc->sc_queue, xs, free_list); - return; - } - LIST_INSERT_AFTER(sc->sc_queuelast, xs, free_list); - sc->sc_queuelast = xs; -} - - -/* - * Pull a scsipi_xfer off the front of the software queue. - */ -static struct scsipi_xfer * -adv_dequeue(sc) - ASC_SOFTC *sc; -{ - struct scsipi_xfer *xs; - - xs = sc->sc_queue.lh_first; - LIST_REMOVE(xs, free_list); - - if (sc->sc_queue.lh_first == NULL) - sc->sc_queuelast = NULL; - - return (xs); -} - - /******************************************************************************/ /* Control Blocks routines */ /******************************************************************************/ @@ -583,7 +538,7 @@ adv_attach(sc) TAILQ_INIT(&sc->sc_free_ccb); TAILQ_INIT(&sc->sc_waiting_ccb); - LIST_INIT(&sc->sc_queue); + TAILQ_INIT(&sc->sc_queue); /* @@ -642,8 +597,8 @@ adv_scsi_cmd(xs) * If we're running the queue from adv_done(), we've been * called with the first queue entry as our argument. */ - if (xs == sc->sc_queue.lh_first) { - xs = adv_dequeue(sc); + if (xs == TAILQ_FIRST(&sc->sc_queue)) { + TAILQ_REMOVE(&sc->sc_queue, xs, adapter_q); fromqueue = 1; } else { @@ -653,7 +608,7 @@ adv_scsi_cmd(xs) /* * If there are jobs in the queue, run them first. */ - if (sc->sc_queue.lh_first != NULL) { + if (TAILQ_FIRST(&sc->sc_queue) != NULL) { /* * If we can't queue, we have to abort, since * we have to preserve order. @@ -666,8 +621,9 @@ adv_scsi_cmd(xs) /* * Swap with the first queue entry. */ - adv_enqueue(sc, xs, 0); - xs = adv_dequeue(sc); + TAILQ_INSERT_TAIL(&sc->sc_queue, xs, adapter_q); + xs = TAILQ_FIRST(&sc->sc_queue); + TAILQ_REMOVE(&sc->sc_queue, xs, adapter_q); fromqueue = 1; } } @@ -693,7 +649,10 @@ adv_scsi_cmd(xs) * Stuff ourselves into the queue, in front * if we came off in the first place. */ - adv_enqueue(sc, xs, fromqueue); + if (fromqueue) + TAILQ_INSERT_HEAD(&sc->sc_queue, xs, adapter_q); + else + TAILQ_INSERT_TAIL(&sc->sc_queue, xs, adapter_q); splx(s); return (SUCCESSFULLY_QUEUED); } @@ -856,7 +815,7 @@ adv_intr(arg) * NOTE: adv_scsi_cmd() relies on our calling it with * the first entry in the queue. */ - if ((xs = sc->sc_queue.lh_first) != NULL) + if ((xs = TAILQ_FIRST(&sc->sc_queue)) != NULL) (void) adv_scsi_cmd(xs); return (1); diff --git a/sys/dev/ic/advlib.h b/sys/dev/ic/advlib.h index 8e0e1db1442c..75dc298796d5 100644 --- a/sys/dev/ic/advlib.h +++ b/sys/dev/ic/advlib.h @@ -1,4 +1,4 @@ -/* $NetBSD: advlib.h,v 1.6 1998/11/19 21:52:58 thorpej Exp $ */ +/* $NetBSD: advlib.h,v 1.7 1998/12/09 08:47:17 thorpej Exp $ */ /* * Definitions for low level routines and data structures @@ -843,8 +843,7 @@ typedef struct asc_softc struct scsipi_link sc_link; /* prototype for devs */ struct scsipi_adapter sc_adapter; - LIST_HEAD(, scsipi_xfer) sc_queue; - struct scsipi_xfer *sc_queuelast; + TAILQ_HEAD(, scsipi_xfer) sc_queue; u_int8_t *overrun_buf; diff --git a/sys/dev/ic/adw.c b/sys/dev/ic/adw.c index 527d1941df27..9c6f6815ecbf 100644 --- a/sys/dev/ic/adw.c +++ b/sys/dev/ic/adw.c @@ -1,4 +1,4 @@ -/* $NetBSD: adw.c,v 1.5 1998/12/05 19:43:49 mjacob Exp $ */ +/* $NetBSD: adw.c,v 1.6 1998/12/09 08:47:18 thorpej Exp $ */ /* * Generic driver for the Advanced Systems Inc. SCSI controllers @@ -70,9 +70,6 @@ /******************************************************************************/ -static void adw_enqueue __P((ADW_SOFTC *, struct scsipi_xfer *, int)); -static struct scsipi_xfer *adw_dequeue __P((ADW_SOFTC *)); - static int adw_alloc_ccbs __P((ADW_SOFTC *)); static int adw_create_ccbs __P((ADW_SOFTC *, ADW_CCB *, int)); static void adw_free_ccb __P((ADW_SOFTC *, ADW_CCB *)); @@ -110,52 +107,6 @@ struct scsipi_device adw_dev = #define ADW_WATCH_TIMEOUT 10000 /* time to wait for watchdog (mSec) */ -/******************************************************************************/ -/* scsipi_xfer queue routines */ -/******************************************************************************/ - -/* - * Insert a scsipi_xfer into the software queue. We overload xs->free_list - * to avoid having to allocate additional resources (since we're used - * only during resource shortages anyhow. - */ -static void -adw_enqueue(sc, xs, infront) - ADW_SOFTC *sc; - struct scsipi_xfer *xs; - int infront; -{ - - if (infront || sc->sc_queue.lh_first == NULL) { - if (sc->sc_queue.lh_first == NULL) - sc->sc_queuelast = xs; - LIST_INSERT_HEAD(&sc->sc_queue, xs, free_list); - return; - } - LIST_INSERT_AFTER(sc->sc_queuelast, xs, free_list); - sc->sc_queuelast = xs; -} - - -/* - * Pull a scsipi_xfer off the front of the software queue. - */ -static struct scsipi_xfer * -adw_dequeue(sc) - ADW_SOFTC *sc; -{ - struct scsipi_xfer *xs; - - xs = sc->sc_queue.lh_first; - LIST_REMOVE(xs, free_list); - - if (sc->sc_queue.lh_first == NULL) - sc->sc_queuelast = NULL; - - return (xs); -} - - /******************************************************************************/ /* Control Blocks routines */ /******************************************************************************/ @@ -474,7 +425,7 @@ adw_attach(sc) TAILQ_INIT(&sc->sc_free_ccb); TAILQ_INIT(&sc->sc_waiting_ccb); - LIST_INIT(&sc->sc_queue); + TAILQ_INIT(&sc->sc_queue); /* @@ -531,8 +482,8 @@ adw_scsi_cmd(xs) * If we're running the queue from adw_done(), we've been * called with the first queue entry as our argument. */ - if (xs == sc->sc_queue.lh_first) { - xs = adw_dequeue(sc); + if (xs == TAILQ_FIRST(&sc->sc_queue)) { + TAILQ_REMOVE(&sc->sc_queue, xs, adapter_q); fromqueue = 1; } else { @@ -542,7 +493,7 @@ adw_scsi_cmd(xs) /* * If there are jobs in the queue, run them first. */ - if (sc->sc_queue.lh_first != NULL) { + if (TAILQ_FIRST(&sc->sc_queue) != NULL) { /* * If we can't queue, we have to abort, since * we have to preserve order. @@ -555,8 +506,9 @@ adw_scsi_cmd(xs) /* * Swap with the first queue entry. */ - adw_enqueue(sc, xs, 0); - xs = adw_dequeue(sc); + TAILQ_INSERT_TAIL(&sc->sc_queue, xs, adapter_q); + xs = TAILQ_FIRST(&sc->sc_queue); + TAILQ_REMOVE(&sc->sc_queue, xs, adapter_q); fromqueue = 1; } } @@ -581,7 +533,10 @@ adw_scsi_cmd(xs) * Stuff ourselves into the queue, in front * if we came off in the first place. */ - adw_enqueue(sc, xs, fromqueue); + if (fromqueue) + TAILQ_INSERT_HEAD(&sc->sc_queue, xs, adapter_q); + else + TAILQ_INSERT_TAIL(&sc->sc_queue, xs, adapter_q); splx(s); return (SUCCESSFULLY_QUEUED); } @@ -794,7 +749,7 @@ adw_intr(arg) * NOTE: adw_scsi_cmd() relies on our calling it with * the first entry in the queue. */ - if ((xs = sc->sc_queue.lh_first) != NULL) + if ((xs = TAILQ_FIRST(&sc->sc_queue)) != NULL) (void) adw_scsi_cmd(xs); return (1); diff --git a/sys/dev/ic/adwlib.h b/sys/dev/ic/adwlib.h index 5eb2e2df8379..671cf193e3aa 100644 --- a/sys/dev/ic/adwlib.h +++ b/sys/dev/ic/adwlib.h @@ -1,4 +1,4 @@ -/* $NetBSD: adwlib.h,v 1.2 1998/11/19 21:52:59 thorpej Exp $ */ +/* $NetBSD: adwlib.h,v 1.3 1998/12/09 08:47:18 thorpej Exp $ */ /* * Definitions for low level routines and data structures @@ -697,8 +697,7 @@ typedef struct adw_softc { struct scsipi_link sc_link; /* prototype for devs */ struct scsipi_adapter sc_adapter; - LIST_HEAD(, scsipi_xfer) sc_queue; - struct scsipi_xfer *sc_queuelast; + TAILQ_HEAD(, scsipi_xfer) sc_queue; u_int32_t sc_flags; /* see below sc_flags values */ diff --git a/sys/dev/ic/aha.c b/sys/dev/ic/aha.c index f74f90652c7f..32536856e9ce 100644 --- a/sys/dev/ic/aha.c +++ b/sys/dev/ic/aha.c @@ -1,4 +1,4 @@ -/* $NetBSD: aha.c,v 1.21 1998/12/05 19:43:49 mjacob Exp $ */ +/* $NetBSD: aha.c,v 1.22 1998/12/09 08:47:18 thorpej Exp $ */ #include "opt_ddb.h" @@ -112,8 +112,6 @@ int aha_scsi_cmd __P((struct scsipi_xfer *)); int aha_poll __P((struct aha_softc *, struct scsipi_xfer *, int)); void aha_timeout __P((void *arg)); int aha_create_ccbs __P((struct aha_softc *, struct aha_ccb *, int)); -void aha_enqueue __P((struct aha_softc *, struct scsipi_xfer *, int)); -struct scsipi_xfer *aha_dequeue __P((struct aha_softc *)); /* the below structure is so we have a default dev struct for out link struct */ struct scsipi_device aha_dev = { @@ -126,47 +124,6 @@ struct scsipi_device aha_dev = { #define AHA_RESET_TIMEOUT 2000 /* time to wait for reset (mSec) */ #define AHA_ABORT_TIMEOUT 2000 /* time to wait for abort (mSec) */ -/* - * Insert a scsipi_xfer into the software queue. We overload xs->free_list - * to avoid having to allocate additional resources (since we're used - * only during resource shortages anyhow. - */ -void -aha_enqueue(sc, xs, infront) - struct aha_softc *sc; - struct scsipi_xfer *xs; - int infront; -{ - - if (infront || sc->sc_queue.lh_first == NULL) { - if (sc->sc_queue.lh_first == NULL) - sc->sc_queuelast = xs; - LIST_INSERT_HEAD(&sc->sc_queue, xs, free_list); - return; - } - - LIST_INSERT_AFTER(sc->sc_queuelast, xs, free_list); - sc->sc_queuelast = xs; -} - -/* - * Pull a scsipi_xfer off the front of the software queue. - */ -struct scsipi_xfer * -aha_dequeue(sc) - struct aha_softc *sc; -{ - struct scsipi_xfer *xs; - - xs = sc->sc_queue.lh_first; - LIST_REMOVE(xs, free_list); - - if (sc->sc_queue.lh_first == NULL) - sc->sc_queuelast = NULL; - - return (xs); -} - /* * aha_cmd(iot, ioh, sc, icnt, ibuf, ocnt, obuf) * @@ -307,7 +264,7 @@ aha_attach(sc, apd) TAILQ_INIT(&sc->sc_free_ccb); TAILQ_INIT(&sc->sc_waiting_ccb); - LIST_INIT(&sc->sc_queue); + TAILQ_INIT(&sc->sc_queue); /* * Fill in the adapter. @@ -837,7 +794,7 @@ aha_done(sc, ccb) * NOTE: aha_scsi_cmd() relies on our calling it with * the first entry in the queue. */ - if ((xs = sc->sc_queue.lh_first) != NULL) + if ((xs = TAILQ_FIRST(&sc->sc_queue)) != NULL) (void) aha_scsi_cmd(xs); } @@ -1231,8 +1188,8 @@ aha_scsi_cmd(xs) * If we're running the queue from aha_done(), we've been * called with the first queue entry as our argument. */ - if (xs == sc->sc_queue.lh_first) { - xs = aha_dequeue(sc); + if (xs == TAILQ_FIRST(&sc->sc_queue)) { + TAILQ_REMOVE(&sc->sc_queue, xs, adapter_q); fromqueue = 1; goto get_ccb; } @@ -1243,7 +1200,7 @@ aha_scsi_cmd(xs) /* * If there are jobs in the queue, run them first. */ - if (sc->sc_queue.lh_first != NULL) { + if (TAILQ_FIRST(&sc->sc_queue) != NULL) { /* * If we can't queue, we have to abort, since * we have to preserve order. @@ -1257,8 +1214,9 @@ aha_scsi_cmd(xs) /* * Swap with the first queue entry. */ - aha_enqueue(sc, xs, 0); - xs = aha_dequeue(sc); + TAILQ_INSERT_TAIL(&sc->sc_queue, xs, adapter_q); + xs = TAILQ_FIRST(&sc->sc_queue); + TAILQ_REMOVE(&sc->sc_queue, xs, adapter_q); fromqueue = 1; } @@ -1283,7 +1241,10 @@ aha_scsi_cmd(xs) * Stuff ourselves into the queue, in front * if we came off in the first place. */ - aha_enqueue(sc, xs, fromqueue); + if (fromqueue) + TAILQ_INSERT_HEAD(&sc->sc_queue, xs, adapter_q); + else + TAILQ_INSERT_TAIL(&sc->sc_queue, xs, adapter_q); splx(s); return (SUCCESSFULLY_QUEUED); } diff --git a/sys/dev/ic/ahavar.h b/sys/dev/ic/ahavar.h index ccfb8942a4ac..9dce90abb762 100644 --- a/sys/dev/ic/ahavar.h +++ b/sys/dev/ic/ahavar.h @@ -1,4 +1,4 @@ -/* $NetBSD: ahavar.h,v 1.9 1998/11/19 21:52:59 thorpej Exp $ */ +/* $NetBSD: ahavar.h,v 1.10 1998/12/09 08:47:18 thorpej Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -88,8 +88,7 @@ struct aha_softc { struct scsipi_link sc_link; /* prototype for devs */ struct scsipi_adapter sc_adapter; - LIST_HEAD(, scsipi_xfer) sc_queue; - struct scsipi_xfer *sc_queuelast; + TAILQ_HEAD(, scsipi_xfer) sc_queue; char sc_model[18], sc_firmware[4]; diff --git a/sys/dev/ic/aic7xxx.c b/sys/dev/ic/aic7xxx.c index 51d2fa303913..ea54194c1b38 100644 --- a/sys/dev/ic/aic7xxx.c +++ b/sys/dev/ic/aic7xxx.c @@ -1,4 +1,4 @@ -/* $NetBSD: aic7xxx.c,v 1.33 1998/12/05 19:43:50 mjacob Exp $ */ +/* $NetBSD: aic7xxx.c,v 1.34 1998/12/09 08:47:18 thorpej Exp $ */ /* * Generic driver for the aic7xxx based adaptec SCSI controllers @@ -348,12 +348,6 @@ static void ahc_construct_sdtr __P((struct ahc_data *ahc, int start_byte, static void ahc_construct_wdtr __P((struct ahc_data *ahc, int start_byte, u_int8_t bus_width)); -#if defined(__NetBSD__) /* XXX */ -static void ahc_xxx_enqueue __P((struct ahc_data *ahc, - struct scsipi_xfer *xs, int infront)); -static struct scsipi_xfer *ahc_xxx_dequeue __P((struct ahc_data *ahc)); -#endif - #if defined(__FreeBSD__) char *ahc_name(ahc) @@ -650,7 +644,7 @@ ahc_attach(ahc) /* * Initialize the software queue. */ - LIST_INIT(&ahc->sc_xxxq); + TAILQ_INIT(&ahc->sc_q); #endif #ifdef AHC_BROKEN_CACHE @@ -2116,8 +2110,8 @@ ahc_done(ahc, scb) * NOTE: ahc_scsi_cmd() relies on our calling it with * the first entry in the queue. */ - if (ahc->sc_xxxq.lh_first != NULL) - (void) ahc_scsi_cmd(ahc->sc_xxxq.lh_first); + if ((xs = TAILQ_FIRST(&ahc->sc_q)) != NULL) + (void) ahc_scsi_cmd(xs); #endif /* __NetBSD__ */ } @@ -2506,51 +2500,6 @@ ahcminphys(bp) #endif } -#if defined(__NetBSD__) /* XXX */ -/* - * Insert a scsipi_xfer into the software queue. We overload xs->free_list - * to to ensure we don't run into a queue resource shortage, and keep - * a pointer to the last entry around to make insertion O(C). - */ -static void -ahc_xxx_enqueue(ahc, xs, infront) - struct ahc_data *ahc; - struct scsipi_xfer *xs; - int infront; -{ - - if (infront || ahc->sc_xxxq.lh_first == NULL) { - if (ahc->sc_xxxq.lh_first == NULL) - ahc->sc_xxxqlast = xs; - LIST_INSERT_HEAD(&ahc->sc_xxxq, xs, free_list); - return; - } - - LIST_INSERT_AFTER(ahc->sc_xxxqlast, xs, free_list); - ahc->sc_xxxqlast = xs; -} - -/* - * Pull a scsipi_xfer off the front of the software queue. When we - * pull the last one off, we need to clear the pointer to the last - * entry. - */ -static struct scsipi_xfer * -ahc_xxx_dequeue(ahc) - struct ahc_data *ahc; -{ - struct scsipi_xfer *xs; - - xs = ahc->sc_xxxq.lh_first; - LIST_REMOVE(xs, free_list); - - if (ahc->sc_xxxq.lh_first == NULL) - ahc->sc_xxxqlast = NULL; - - return (xs); -} -#endif - /* * start a scsi operation given the command and * the data address, target, and lun all of which @@ -2597,8 +2546,8 @@ ahc_scsi_cmd(xs) * Pull it off; if we can't run the job, it will get placed * back at the front. */ - if (xs == ahc->sc_xxxq.lh_first) { - xs = ahc_xxx_dequeue(ahc); + if (xs == TAILQ_FIRST(&ahc->sc_q)) { + TAILQ_REMOVE(&ahc->sc_q, xs, adapter_q); fromqueue = 1; goto get_scb; } @@ -2610,7 +2559,7 @@ ahc_scsi_cmd(xs) * Handle situations where there's already entries in the * queue. */ - if (ahc->sc_xxxq.lh_first != NULL) { + if (TAILQ_FIRST(&ahc->sc_q) != NULL) { /* * If we can't queue, we have to abort, since * we have to preserve order. @@ -2624,8 +2573,9 @@ ahc_scsi_cmd(xs) /* * Swap with the first queue entry. */ - ahc_xxx_enqueue(ahc, xs, 0); - xs = ahc_xxx_dequeue(ahc); + TAILQ_INSERT_TAIL(&ahc->sc_q, xs, adapter_q); + xs = TAILQ_FIRST(&ahc->sc_q); + TAILQ_REMOVE(&ahc->sc_q, xs, adapter_q); fromqueue = 1; } @@ -2661,7 +2611,10 @@ ahc_scsi_cmd(xs) * back in the front, otherwise tack ourselves onto * the end. */ - ahc_xxx_enqueue(ahc, xs, fromqueue); + if (fromqueue) + TAILQ_INSERT_HEAD(&ahc->sc_q, xs, adapter_q); + else + TAILQ_INSERT_TAIL(&ahc->sc_q, xs, adapter_q); splx(s); return (SUCCESSFULLY_QUEUED); diff --git a/sys/dev/ic/aic7xxxvar.h b/sys/dev/ic/aic7xxxvar.h index df3aa6fe2065..5731f7fd8c8c 100644 --- a/sys/dev/ic/aic7xxxvar.h +++ b/sys/dev/ic/aic7xxxvar.h @@ -1,4 +1,4 @@ -/* $NetBSD: aic7xxxvar.h,v 1.18 1998/11/19 21:53:00 thorpej Exp $ */ +/* $NetBSD: aic7xxxvar.h,v 1.19 1998/12/09 08:47:19 thorpej Exp $ */ /* * Interface to the generic driver for the aic7xxx based adaptec @@ -236,8 +236,7 @@ struct ahc_data { int sc_dmaflags; bus_dmamap_t sc_dmamap_control; /* Maps the control blocks */ - LIST_HEAD(, scsipi_xfer) sc_xxxq; /* XXX software request queue */ - struct scsipi_xfer *sc_xxxqlast; /* last entry in queue */ + TAILQ_HEAD(, scsipi_xfer) sc_q; /* XXX software request queue */ #endif ahc_type type; ahc_flag flags; diff --git a/sys/dev/ic/bha.c b/sys/dev/ic/bha.c index a855471f6013..d796c4ec2258 100644 --- a/sys/dev/ic/bha.c +++ b/sys/dev/ic/bha.c @@ -1,4 +1,4 @@ -/* $NetBSD: bha.c,v 1.28 1998/12/05 19:43:51 mjacob Exp $ */ +/* $NetBSD: bha.c,v 1.29 1998/12/09 08:47:19 thorpej Exp $ */ #include "opt_ddb.h" #undef BHADIAG @@ -110,8 +110,6 @@ int bha_scsi_cmd __P((struct scsipi_xfer *)); int bha_poll __P((struct bha_softc *, struct scsipi_xfer *, int)); void bha_timeout __P((void *arg)); int bha_create_ccbs __P((struct bha_softc *, struct bha_ccb *, int)); -void bha_enqueue __P((struct bha_softc *, struct scsipi_xfer *, int)); -struct scsipi_xfer *bha_dequeue __P((struct bha_softc *)); /* the below structure is so we have a default dev struct for out link struct */ struct scsipi_device bha_dev = { @@ -124,47 +122,6 @@ struct scsipi_device bha_dev = { #define BHA_RESET_TIMEOUT 2000 /* time to wait for reset (mSec) */ #define BHA_ABORT_TIMEOUT 2000 /* time to wait for abort (mSec) */ -/* - * Insert a scsipi_xfer into the software queue. We overload xs->free_list - * to avoid having to allocate additional resources (since we're used - * only during resource shortages anyhow. - */ -void -bha_enqueue(sc, xs, infront) - struct bha_softc *sc; - struct scsipi_xfer *xs; - int infront; -{ - - if (infront || sc->sc_queue.lh_first == NULL) { - if (sc->sc_queue.lh_first == NULL) - sc->sc_queuelast = xs; - LIST_INSERT_HEAD(&sc->sc_queue, xs, free_list); - return; - } - - LIST_INSERT_AFTER(sc->sc_queuelast, xs, free_list); - sc->sc_queuelast = xs; -} - -/* - * Pull a scsipi_xfer off the front of the software queue. - */ -struct scsipi_xfer * -bha_dequeue(sc) - struct bha_softc *sc; -{ - struct scsipi_xfer *xs; - - xs = sc->sc_queue.lh_first; - LIST_REMOVE(xs, free_list); - - if (sc->sc_queue.lh_first == NULL) - sc->sc_queuelast = NULL; - - return (xs); -} - /* * bha_cmd(iot, ioh, sc, icnt, ibuf, ocnt, obuf) * @@ -332,7 +289,7 @@ bha_attach(sc, bpd) TAILQ_INIT(&sc->sc_free_ccb); TAILQ_INIT(&sc->sc_waiting_ccb); - LIST_INIT(&sc->sc_queue); + TAILQ_INIT(&sc->sc_queue); bha_inquire_setup_information(sc); @@ -849,7 +806,7 @@ bha_done(sc, ccb) * NOTE: bha_scsi_cmd() relies on our calling it with * the first entry in the queue. */ - if ((xs = sc->sc_queue.lh_first) != NULL) + if ((xs = TAILQ_FIRST(&sc->sc_queue)) != NULL) (void) bha_scsi_cmd(xs); } @@ -1343,8 +1300,8 @@ bha_scsi_cmd(xs) * If we're running the queue from bha_done(), we've been * called with the first queue entry as our argument. */ - if (xs == sc->sc_queue.lh_first) { - xs = bha_dequeue(sc); + if (xs == TAILQ_FIRST(&sc->sc_queue)) { + TAILQ_REMOVE(&sc->sc_queue, xs, adapter_q); fromqueue = 1; goto get_ccb; } @@ -1355,7 +1312,7 @@ bha_scsi_cmd(xs) /* * If there are jobs in the queue, run them first. */ - if (sc->sc_queue.lh_first != NULL) { + if (TAILQ_FIRST(&sc->sc_queue) != NULL) { /* * If we can't queue, we have to abort, since * we have to preserve order. @@ -1369,8 +1326,9 @@ bha_scsi_cmd(xs) /* * Swap with the first queue entry. */ - bha_enqueue(sc, xs, 0); - xs = bha_dequeue(sc); + TAILQ_INSERT_TAIL(&sc->sc_queue, xs, adapter_q); + xs = TAILQ_FIRST(&sc->sc_queue); + TAILQ_REMOVE(&sc->sc_queue, xs, adapter_q); fromqueue = 1; } @@ -1395,7 +1353,10 @@ bha_scsi_cmd(xs) * Stuff ourselves into the queue, in front * if we came off in the first place. */ - bha_enqueue(sc, xs, fromqueue); + if (fromqueue) + TAILQ_INSERT_HEAD(&sc->sc_queue, xs, adapter_q); + else + TAILQ_INSERT_TAIL(&sc->sc_queue, xs, adapter_q); splx(s); return (SUCCESSFULLY_QUEUED); } diff --git a/sys/dev/ic/bhavar.h b/sys/dev/ic/bhavar.h index 228f9fbf55b4..a20a915163d5 100644 --- a/sys/dev/ic/bhavar.h +++ b/sys/dev/ic/bhavar.h @@ -1,4 +1,4 @@ -/* $NetBSD: bhavar.h,v 1.12 1998/11/19 21:53:00 thorpej Exp $ */ +/* $NetBSD: bhavar.h,v 1.13 1998/12/09 08:47:19 thorpej Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -89,8 +89,7 @@ struct bha_softc { struct scsipi_link sc_link; /* prototype for devs */ struct scsipi_adapter sc_adapter; - LIST_HEAD(, scsipi_xfer) sc_queue; - struct scsipi_xfer *sc_queuelast; + TAILQ_HEAD(, scsipi_xfer) sc_queue; char sc_model[7], sc_firmware[6]; diff --git a/sys/dev/ic/uha.c b/sys/dev/ic/uha.c index 2f554036b564..554944529aa5 100644 --- a/sys/dev/ic/uha.c +++ b/sys/dev/ic/uha.c @@ -1,4 +1,4 @@ -/* $NetBSD: uha.c,v 1.20 1998/12/05 19:43:54 mjacob Exp $ */ +/* $NetBSD: uha.c,v 1.21 1998/12/09 08:47:20 thorpej Exp $ */ #undef UHADEBUG #ifdef DDB @@ -101,8 +101,6 @@ struct uha_mscp *uha_get_mscp __P((struct uha_softc *, int)); void uhaminphys __P((struct buf *)); int uha_scsi_cmd __P((struct scsipi_xfer *)); int uha_create_mscps __P((struct uha_softc *, struct uha_mscp *, int)); -void uha_enqueue __P((struct uha_softc *, struct scsipi_xfer *, int)); -struct scsipi_xfer *uha_dequeue __P((struct uha_softc *)); /* the below structure is so we have a default dev struct for out link struct */ struct scsipi_device uha_dev = { @@ -114,47 +112,6 @@ struct scsipi_device uha_dev = { #define UHA_ABORT_TIMEOUT 2000 /* time to wait for abort (mSec) */ -/* - * Insert a scsipi_xfer into the software queue. We overload xs->free_list - * to avoid having to allocate additional resources (since we're used - * only during resource shortages anyhow. - */ -void -uha_enqueue(sc, xs, infront) - struct uha_softc *sc; - struct scsipi_xfer *xs; - int infront; -{ - - if (infront || sc->sc_queue.lh_first == NULL) { - if (sc->sc_queue.lh_first == NULL) - sc->sc_queuelast = xs; - LIST_INSERT_HEAD(&sc->sc_queue, xs, free_list); - return; - } - - LIST_INSERT_AFTER(sc->sc_queuelast, xs, free_list); - sc->sc_queuelast = xs; -} - -/* - * Pull a scsipi_xfer off the front of the software queue. - */ -struct scsipi_xfer * -uha_dequeue(sc) - struct uha_softc *sc; -{ - struct scsipi_xfer *xs; - - xs = sc->sc_queue.lh_first; - LIST_REMOVE(xs, free_list); - - if (sc->sc_queue.lh_first == NULL) - sc->sc_queuelast = NULL; - - return (xs); -} - /* * Attach all the sub-devices we can find */ @@ -167,7 +124,7 @@ uha_attach(sc, upd) int i, error, rseg; TAILQ_INIT(&sc->sc_free_mscp); - LIST_INIT(&sc->sc_queue); + TAILQ_INIT(&sc->sc_queue); (sc->init)(sc); @@ -479,7 +436,7 @@ uha_done(sc, mscp) * NOTE: uha_scsi_cmd() relies on our calling it with * the first entry in the queue. */ - if ((xs = sc->sc_queue.lh_first) != NULL) + if ((xs = TAILQ_FIRST(&sc->sc_queue)) != NULL) (void) uha_scsi_cmd(xs); } @@ -517,8 +474,8 @@ uha_scsi_cmd(xs) * If we're running the queue from bha_done(), we've been * called with the first queue entry as our argument. */ - if (xs == sc->sc_queue.lh_first) { - xs = uha_dequeue(sc); + if (xs == TAILQ_FIRST(&sc->sc_queue)) { + TAILQ_REMOVE(&sc->sc_queue, xs, adapter_q); fromqueue = 1; goto get_mscp; } @@ -529,7 +486,7 @@ uha_scsi_cmd(xs) /* * If there are jobs in the queue, run them first. */ - if (sc->sc_queue.lh_first != NULL) { + if (TAILQ_FIRST(&sc->sc_queue) != NULL) { /* * If we can't queue, we have to abort, since * we have to preserve order. @@ -543,8 +500,9 @@ uha_scsi_cmd(xs) /* * Swap with the first queue entry. */ - uha_enqueue(sc, xs, 0); - xs = uha_dequeue(sc); + TAILQ_INSERT_TAIL(&sc->sc_queue, xs, adapter_q); + xs = TAILQ_FIRST(&sc->sc_queue); + TAILQ_REMOVE(&sc->sc_queue, xs, adapter_q); fromqueue = 1; } @@ -569,7 +527,10 @@ uha_scsi_cmd(xs) * Stuff ourselves into the queue, in front * if we came off in the first place. */ - uha_enqueue(sc, xs, fromqueue); + if (fromqueue) + TAILQ_INSERT_HEAD(&sc->sc_queue, xs, adapter_q); + else + TAILQ_INSERT_TAIL(&sc->sc_queue, xs, adapter_q); splx(s); return (SUCCESSFULLY_QUEUED); } diff --git a/sys/dev/ic/uhavar.h b/sys/dev/ic/uhavar.h index 935c3a3678e9..6d6d4b17bd0b 100644 --- a/sys/dev/ic/uhavar.h +++ b/sys/dev/ic/uhavar.h @@ -1,4 +1,4 @@ -/* $NetBSD: uhavar.h,v 1.10 1998/11/19 21:53:00 thorpej Exp $ */ +/* $NetBSD: uhavar.h,v 1.11 1998/12/09 08:47:20 thorpej Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -67,8 +67,7 @@ struct uha_softc { struct scsipi_link sc_link; struct scsipi_adapter sc_adapter; - LIST_HEAD(, scsipi_xfer) sc_queue; - struct scsipi_xfer *sc_queuelast; + TAILQ_HEAD(, scsipi_xfer) sc_queue; }; /* diff --git a/sys/dev/isa/wds.c b/sys/dev/isa/wds.c index a54347b48938..23b40cd37d9e 100644 --- a/sys/dev/isa/wds.c +++ b/sys/dev/isa/wds.c @@ -1,4 +1,4 @@ -/* $NetBSD: wds.c,v 1.37 1998/12/05 19:43:55 mjacob Exp $ */ +/* $NetBSD: wds.c,v 1.38 1998/12/09 08:37:50 thorpej Exp $ */ #include "opt_ddb.h" @@ -165,8 +165,7 @@ struct wds_softc { struct scsipi_link sc_link; /* prototype for subdevs */ struct scsipi_adapter sc_adapter; - LIST_HEAD(, scsipi_xfer) sc_queue; - struct scsipi_xfer *sc_queuelast; + TAILQ_HEAD(, scsipi_xfer) sc_queue; int sc_revision; int sc_maxsegs; @@ -204,8 +203,6 @@ int wds_poll __P((struct wds_softc *, struct scsipi_xfer *, int)); int wds_ipoll __P((struct wds_softc *, struct wds_scb *, int)); void wds_timeout __P((void *)); int wds_create_scbs __P((struct wds_softc *, void *, size_t)); -void wds_enqueue __P((struct wds_softc *, struct scsipi_xfer *, int)); -struct scsipi_xfer *wds_dequeue __P((struct wds_softc *)); /* the below structure is so we have a default dev struct for our link struct */ struct scsipi_device wds_dev = { @@ -224,47 +221,6 @@ struct cfattach wds_ca = { #define WDS_ABORT_TIMEOUT 2000 /* time to wait for abort (mSec) */ -/* - * Insert a scsipi_xfer into the software queue. We overload xs->free_list - * to avoid having to allocate additional resources (since we're used - * only during resource shortages anyhow. - */ -void -wds_enqueue(sc, xs, infront) - struct wds_softc *sc; - struct scsipi_xfer *xs; - int infront; -{ - - if (infront || sc->sc_queue.lh_first == NULL) { - if (sc->sc_queue.lh_first == NULL) - sc->sc_queuelast = xs; - LIST_INSERT_HEAD(&sc->sc_queue, xs, free_list); - return; - } - - LIST_INSERT_AFTER(sc->sc_queuelast, xs, free_list); - sc->sc_queuelast = xs; -} - -/* - * Pull a scsipi_xfer off the front of the software queue. - */ -struct scsipi_xfer * -wds_dequeue(sc) - struct wds_softc *sc; -{ - struct scsipi_xfer *xs; - - xs = sc->sc_queue.lh_first; - LIST_REMOVE(xs, free_list); - - if (sc->sc_queue.lh_first == NULL) - sc->sc_queuelast = NULL; - - return (xs); -} - integrate void wds_wait(iot, ioh, port, mask, val) bus_space_tag_t iot; @@ -420,7 +376,7 @@ wds_attach(sc, wpd) TAILQ_INIT(&sc->sc_free_scb); TAILQ_INIT(&sc->sc_waiting_scb); - LIST_INIT(&sc->sc_queue); + TAILQ_INIT(&sc->sc_queue); wds_init(sc, 0); wds_inquire_setup_information(sc); @@ -1001,7 +957,7 @@ wds_done(sc, scb, stat) * NOTE: wds_scsi_cmd() relies on our calling it with * the first entry in the queue. */ - if ((xs = sc->sc_queue.lh_first) != NULL) + if ((xs = TAILQ_FIRST(&sc->sc_queue)) != NULL) (void) wds_scsi_cmd(xs); } @@ -1235,8 +1191,8 @@ wds_scsi_cmd(xs) * If we're running the queue from wds_done(), we've been * called with the first queue entry as our argument. */ - if (xs == sc->sc_queue.lh_first) { - xs = wds_dequeue(sc); + if (xs == TAILQ_FIRST(&sc->sc_queue)) { + TAILQ_REMOVE(&sc->sc_queue, xs, adapter_q); fromqueue = 1; goto get_scb; } @@ -1247,7 +1203,7 @@ wds_scsi_cmd(xs) /* * If there are jobs in the queue, run them first. */ - if (sc->sc_queue.lh_first != NULL) { + if (TAILQ_FIRST(&sc->sc_queue) != NULL) { /* * If we can't queue, we have to abort, since * we have to preserve order. @@ -1261,8 +1217,9 @@ wds_scsi_cmd(xs) /* * Swap with the first queue entry. */ - wds_enqueue(sc, xs, 0); - xs = wds_dequeue(sc); + TAILQ_INSERT_TAIL(&sc->sc_queue, xs, adapter_q); + xs = TAILQ_FIRST(&sc->sc_queue); + TAILQ_REMOVE(&sc->sc_queue, xs, adapter_q); fromqueue = 1; } @@ -1282,7 +1239,10 @@ wds_scsi_cmd(xs) * Stuff ourselves into the queue, in front * if we came off in the first place. */ - wds_enqueue(sc, xs, fromqueue); + if (fromqueue) + TAILQ_INSERT_HEAD(&sc->sc_queue, xs, adapter_q); + else + TAILQ_INSERT_TAIL(&sc->sc_queue, xs, adapter_q); splx(s); return (SUCCESSFULLY_QUEUED); }