Modularize the CCB/MSCP/ACB/ECB handling a little. No functional changes.
This commit is contained in:
parent
f85c70984a
commit
393a69d6db
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: aha1742.c,v 1.50 1995/09/26 19:32:26 thorpej Exp $ */
|
||||
/* $NetBSD: aha1742.c,v 1.51 1995/10/03 20:59:06 mycroft Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994 Charles Hannum. All rights reserved.
|
||||
@ -714,15 +714,41 @@ ahb_free_ecb(ahb, ecb, flags)
|
||||
TAILQ_INSERT_HEAD(&ahb->free_ecb, ecb, chain);
|
||||
|
||||
/*
|
||||
* If there were none, wake abybody waiting for
|
||||
* one to come free, starting with queued entries
|
||||
* If there were none, wake anybody waiting for one to come free,
|
||||
* starting with queued entries.
|
||||
*/
|
||||
if (!ecb->chain.tqe_next)
|
||||
if (ecb->chain.tqe_next == 0)
|
||||
wakeup(&ahb->free_ecb);
|
||||
|
||||
splx(s);
|
||||
}
|
||||
|
||||
static inline void
|
||||
ahb_init_ecb(ahb, ecb)
|
||||
struct ahb_softc *ahb;
|
||||
struct ahb_ecb *ecb;
|
||||
{
|
||||
int hashnum;
|
||||
|
||||
bzero(ecb, sizeof(struct ahb_ecb));
|
||||
/*
|
||||
* put in the phystokv hash table
|
||||
* Never gets taken out.
|
||||
*/
|
||||
ecb->hashkey = KVTOPHYS(ecb);
|
||||
hashnum = CCB_HASH(ecb->hashkey);
|
||||
ecb->nexthash = ahb->ecbhash[hashnum];
|
||||
ahb->ecbhash[hashnum] = ecb;
|
||||
}
|
||||
|
||||
static inline void
|
||||
ahb_reset_ecb(ahb, ecb)
|
||||
struct ahb_softc *ahb;
|
||||
struct ahb_ecb *ecb;
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Get a free ecb
|
||||
*
|
||||
@ -734,9 +760,8 @@ ahb_get_ecb(ahb, flags)
|
||||
struct ahb_softc *ahb;
|
||||
int flags;
|
||||
{
|
||||
int s;
|
||||
struct ahb_ecb *ecb;
|
||||
int hashnum;
|
||||
int s;
|
||||
|
||||
s = splbio();
|
||||
|
||||
@ -753,27 +778,24 @@ ahb_get_ecb(ahb, flags)
|
||||
if (ahb->numecbs < AHB_ECB_MAX) {
|
||||
if (ecb = (struct ahb_ecb *) malloc(sizeof(struct ahb_ecb),
|
||||
M_TEMP, M_NOWAIT)) {
|
||||
bzero(ecb, sizeof(struct ahb_ecb));
|
||||
ahb_init_ecb(ahb, ecb);
|
||||
ahb->numecbs++;
|
||||
/*
|
||||
* put in the phystokv hash table
|
||||
* Never gets taken out.
|
||||
*/
|
||||
ecb->hashkey = KVTOPHYS(ecb);
|
||||
hashnum = ECB_HASH(ecb->hashkey);
|
||||
ecb->nexthash = ahb->ecbhash[hashnum];
|
||||
ahb->ecbhash[hashnum] = ecb;
|
||||
} else {
|
||||
printf("%s: can't malloc ecb\n",
|
||||
ahb->sc_dev.dv_xname);
|
||||
goto out;
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
if ((flags & SCSI_NOSLEEP) == 0)
|
||||
tsleep(&ahb->free_ecb, PRIBIO, "ahbecb", 0);
|
||||
}
|
||||
if ((flags & SCSI_NOSLEEP) != 0)
|
||||
goto out;
|
||||
tsleep(&ahb->free_ecb, PRIBIO, "ahbecb", 0);
|
||||
}
|
||||
|
||||
ahb_reset_ecb(ahb, ecb);
|
||||
ecb->flags = ECB_ACTIVE;
|
||||
|
||||
out:
|
||||
splx(s);
|
||||
return ecb;
|
||||
}
|
||||
@ -937,7 +959,6 @@ ahb_scsi_cmd(xs)
|
||||
xs->error = XS_DRIVER_STUFFUP;
|
||||
return TRY_AGAIN_LATER;
|
||||
}
|
||||
ecb->flags = ECB_ACTIVE;
|
||||
ecb->xs = xs;
|
||||
|
||||
/*
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: aic6360.c,v 1.35 1995/09/26 19:31:19 thorpej Exp $ */
|
||||
/* $NetBSD: aic6360.c,v 1.36 1995/10/03 20:59:03 mycroft Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995 Charles Hannum. All rights reserved.
|
||||
@ -900,6 +900,11 @@ aic_free_acb(sc, acb, flags)
|
||||
|
||||
acb->flags = ACB_FREE;
|
||||
TAILQ_INSERT_HEAD(&sc->free_list, acb, chain);
|
||||
|
||||
/*
|
||||
* If there were none, wake anybody waiting for one to come free,
|
||||
* starting with queued entries.
|
||||
*/
|
||||
if (acb->chain.tqe_next == 0)
|
||||
wakeup(&sc->free_list);
|
||||
|
||||
@ -911,10 +916,9 @@ aic_get_acb(sc, flags)
|
||||
struct aic_softc *sc;
|
||||
int flags;
|
||||
{
|
||||
int s;
|
||||
struct aic_acb *acb;
|
||||
int s;
|
||||
|
||||
/* Get a aic command block */
|
||||
s = splbio();
|
||||
|
||||
while ((acb = sc->free_list.tqh_first) == NULL &&
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: aha1542.c,v 1.52 1995/09/26 22:56:54 thorpej Exp $ */
|
||||
/* $NetBSD: aha1542.c,v 1.53 1995/10/03 20:58:56 mycroft Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994 Charles Hannum. All rights reserved.
|
||||
@ -734,12 +734,38 @@ aha_free_ccb(aha, ccb, flags)
|
||||
* If there were none, wake anybody waiting for one to come free,
|
||||
* starting with queued entries.
|
||||
*/
|
||||
if (!ccb->chain.tqe_next)
|
||||
if (ccb->chain.tqe_next == 0)
|
||||
wakeup(&aha->free_ccb);
|
||||
|
||||
splx(s);
|
||||
}
|
||||
|
||||
static inline void
|
||||
aha_init_ccb(aha, ccb)
|
||||
struct aha_softc *aha;
|
||||
struct aha_ccb *ccb;
|
||||
{
|
||||
int hashnum;
|
||||
|
||||
bzero(ccb, sizeof(struct aha_ccb));
|
||||
/*
|
||||
* put in the phystokv hash table
|
||||
* Never gets taken out.
|
||||
*/
|
||||
ccb->hashkey = KVTOPHYS(ccb);
|
||||
hashnum = CCB_HASH(ccb->hashkey);
|
||||
ccb->nexthash = aha->ccbhash[hashnum];
|
||||
aha->ccbhash[hashnum] = ccb;
|
||||
}
|
||||
|
||||
static inline void
|
||||
aha_reset_ccb(aha, ccb)
|
||||
struct aha_softc *aha;
|
||||
struct aha_ccb *ccb;
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Get a free ccb
|
||||
*/
|
||||
@ -748,9 +774,8 @@ aha_get_ccb(aha, flags)
|
||||
struct aha_softc *aha;
|
||||
int flags;
|
||||
{
|
||||
int s;
|
||||
struct aha_ccb *ccb;
|
||||
int hashnum;
|
||||
int s;
|
||||
|
||||
s = splbio();
|
||||
|
||||
@ -767,29 +792,26 @@ aha_get_ccb(aha, flags)
|
||||
if (aha->numccbs < AHA_CCB_MAX) {
|
||||
if (ccb = (struct aha_ccb *) malloc(sizeof(struct aha_ccb),
|
||||
M_TEMP, M_NOWAIT)) {
|
||||
bzero(ccb, sizeof(struct aha_ccb));
|
||||
aha_init_ccb(aha, ccb);
|
||||
aha->numccbs++;
|
||||
/*
|
||||
* put in the phystokv hash table
|
||||
* Never gets taken out.
|
||||
*/
|
||||
ccb->hashkey = KVTOPHYS(ccb);
|
||||
hashnum = CCB_HASH(ccb->hashkey);
|
||||
ccb->nexthash = aha->ccbhash[hashnum];
|
||||
aha->ccbhash[hashnum] = ccb;
|
||||
} else {
|
||||
printf("%s: can't malloc ccb\n",
|
||||
aha->sc_dev.dv_xname);
|
||||
goto out;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if ((flags & SCSI_NOSLEEP) != 0)
|
||||
break;
|
||||
goto out;
|
||||
tsleep(&aha->free_ccb, PRIBIO, "ahaccb", 0);
|
||||
}
|
||||
|
||||
aha_reset_ccb(aha, ccb);
|
||||
ccb->flags = CCB_ACTIVE;
|
||||
|
||||
out:
|
||||
splx(s);
|
||||
return ccb;
|
||||
return (ccb);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1157,7 +1179,6 @@ aha_scsi_cmd(xs)
|
||||
xs->error = XS_DRIVER_STUFFUP;
|
||||
return TRY_AGAIN_LATER;
|
||||
}
|
||||
ccb->flags = CCB_ACTIVE;
|
||||
ccb->xs = xs;
|
||||
|
||||
/*
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: aic6360.c,v 1.35 1995/09/26 19:31:19 thorpej Exp $ */
|
||||
/* $NetBSD: aic6360.c,v 1.36 1995/10/03 20:59:03 mycroft Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995 Charles Hannum. All rights reserved.
|
||||
@ -900,6 +900,11 @@ aic_free_acb(sc, acb, flags)
|
||||
|
||||
acb->flags = ACB_FREE;
|
||||
TAILQ_INSERT_HEAD(&sc->free_list, acb, chain);
|
||||
|
||||
/*
|
||||
* If there were none, wake anybody waiting for one to come free,
|
||||
* starting with queued entries.
|
||||
*/
|
||||
if (acb->chain.tqe_next == 0)
|
||||
wakeup(&sc->free_list);
|
||||
|
||||
@ -911,10 +916,9 @@ aic_get_acb(sc, flags)
|
||||
struct aic_softc *sc;
|
||||
int flags;
|
||||
{
|
||||
int s;
|
||||
struct aic_acb *acb;
|
||||
int s;
|
||||
|
||||
/* Get a aic command block */
|
||||
s = splbio();
|
||||
|
||||
while ((acb = sc->free_list.tqh_first) == NULL &&
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: bt742a.c,v 1.48 1995/09/26 19:31:22 thorpej Exp $ */
|
||||
/* $NetBSD: bt742a.c,v 1.49 1995/10/03 20:58:58 mycroft Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994 Charles Hannum. All rights reserved.
|
||||
@ -761,12 +761,38 @@ bt_free_ccb(bt, ccb, flags)
|
||||
* If there were none, wake anybody waiting for one to come free,
|
||||
* starting with queued entries.
|
||||
*/
|
||||
if (!ccb->chain.tqe_next)
|
||||
if (ccb->chain.tqe_next == 0)
|
||||
wakeup(&bt->free_ccb);
|
||||
|
||||
splx(s);
|
||||
}
|
||||
|
||||
static inline void
|
||||
bt_init_ccb(bt, ccb)
|
||||
struct bt_softc *bt;
|
||||
struct bt_ccb *ccb;
|
||||
{
|
||||
int hashnum;
|
||||
|
||||
bzero(ccb, sizeof(struct bt_ccb));
|
||||
/*
|
||||
* put in the phystokv hash table
|
||||
* Never gets taken out.
|
||||
*/
|
||||
ccb->hashkey = KVTOPHYS(ccb);
|
||||
hashnum = CCB_HASH(ccb->hashkey);
|
||||
ccb->nexthash = bt->ccbhash[hashnum];
|
||||
bt->ccbhash[hashnum] = ccb;
|
||||
}
|
||||
|
||||
static inline void
|
||||
bt_reset_ccb(bt, ccb)
|
||||
struct bt_softc *bt;
|
||||
struct bt_ccb *ccb;
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Get a free ccb
|
||||
*
|
||||
@ -778,9 +804,8 @@ bt_get_ccb(bt, flags)
|
||||
struct bt_softc *bt;
|
||||
int flags;
|
||||
{
|
||||
int s;
|
||||
struct bt_ccb *ccb;
|
||||
int hashnum;
|
||||
int s;
|
||||
|
||||
s = splbio();
|
||||
|
||||
@ -797,27 +822,24 @@ bt_get_ccb(bt, flags)
|
||||
if (bt->numccbs < BT_CCB_MAX) {
|
||||
if (ccb = (struct bt_ccb *) malloc(sizeof(struct bt_ccb),
|
||||
M_TEMP, M_NOWAIT)) {
|
||||
bzero(ccb, sizeof(struct bt_ccb));
|
||||
bt_init_ccb(bt, ccb);
|
||||
bt->numccbs++;
|
||||
/*
|
||||
* put in the phystokv hash table
|
||||
* Never gets taken out.
|
||||
*/
|
||||
ccb->hashkey = KVTOPHYS(ccb);
|
||||
hashnum = CCB_HASH(ccb->hashkey);
|
||||
ccb->nexthash = bt->ccbhash[hashnum];
|
||||
bt->ccbhash[hashnum] = ccb;
|
||||
} else {
|
||||
printf("%s: can't malloc ccb\n",
|
||||
bt->sc_dev.dv_xname);
|
||||
goto out;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if ((flags & SCSI_NOSLEEP) != 0)
|
||||
break;
|
||||
goto out;
|
||||
tsleep(&bt->free_ccb, PRIBIO, "btccb", 0);
|
||||
}
|
||||
|
||||
bt_reset_ccb(bt, ccb);
|
||||
ccb->flags = CCB_ACTIVE;
|
||||
|
||||
out:
|
||||
splx(s);
|
||||
return ccb;
|
||||
}
|
||||
@ -1180,7 +1202,6 @@ bt_scsi_cmd(xs)
|
||||
xs->error = XS_DRIVER_STUFFUP;
|
||||
return TRY_AGAIN_LATER;
|
||||
}
|
||||
ccb->flags = CCB_ACTIVE;
|
||||
ccb->xs = xs;
|
||||
|
||||
/*
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ultra14f.c,v 1.55 1995/09/26 19:31:24 thorpej Exp $ */
|
||||
/* $NetBSD: ultra14f.c,v 1.56 1995/10/03 20:59:01 mycroft Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994 Charles Hannum. All rights reserved.
|
||||
@ -798,15 +798,41 @@ uha_free_mscp(uha, mscp, flags)
|
||||
TAILQ_INSERT_HEAD(&uha->free_mscp, mscp, chain);
|
||||
|
||||
/*
|
||||
* If there were none, wake abybody waiting for
|
||||
* one to come free, starting with queued entries
|
||||
* If there were none, wake anybody waiting for one to come free,
|
||||
* starting with queued entries.
|
||||
*/
|
||||
if (!mscp->chain.tqe_next)
|
||||
if (mscp->chain.tqe_next == 0)
|
||||
wakeup(&uha->free_mscp);
|
||||
|
||||
splx(s);
|
||||
}
|
||||
|
||||
static inline void
|
||||
uha_init_mscp(uha, mscp)
|
||||
struct uha_softc *uha;
|
||||
struct uha_mscp *mscp;
|
||||
{
|
||||
int hashnum;
|
||||
|
||||
bzero(mscp, sizeof(struct uha_mscp));
|
||||
/*
|
||||
* put in the phystokv hash table
|
||||
* Never gets taken out.
|
||||
*/
|
||||
mscp->hashkey = KVTOPHYS(mscp);
|
||||
hashnum = CCB_HASH(mscp->hashkey);
|
||||
mscp->nexthash = uha->mscphash[hashnum];
|
||||
uha->mscphash[hashnum] = mscp;
|
||||
}
|
||||
|
||||
static inline void
|
||||
uha_reset_mscp(uha, mscp)
|
||||
struct uha_softc *uha;
|
||||
struct uha_mscp *mscp;
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Get a free mscp
|
||||
*
|
||||
@ -818,9 +844,8 @@ uha_get_mscp(uha, flags)
|
||||
struct uha_softc *uha;
|
||||
int flags;
|
||||
{
|
||||
int s;
|
||||
struct uha_mscp *mscp;
|
||||
int hashnum;
|
||||
int s;
|
||||
|
||||
s = splbio();
|
||||
|
||||
@ -837,27 +862,24 @@ uha_get_mscp(uha, flags)
|
||||
if (uha->nummscps < UHA_MSCP_MAX) {
|
||||
if (mscp = (struct uha_mscp *) malloc(sizeof(struct uha_mscp),
|
||||
M_TEMP, M_NOWAIT)) {
|
||||
bzero(mscp, sizeof(struct uha_mscp));
|
||||
uha_init_mscp(uha, mscp);
|
||||
uha->nummscps++;
|
||||
/*
|
||||
* put in the phystokv hash table
|
||||
* Never gets taken out.
|
||||
*/
|
||||
mscp->hashkey = KVTOPHYS(mscp);
|
||||
hashnum = MSCP_HASH(mscp->hashkey);
|
||||
mscp->nexthash = uha->mscphash[hashnum];
|
||||
uha->mscphash[hashnum] = mscp;
|
||||
} else {
|
||||
printf("%s: can't malloc mscp\n",
|
||||
uha->sc_dev.dv_xname);
|
||||
goto out;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if ((flags & SCSI_NOSLEEP) != 0)
|
||||
break;
|
||||
goto out;
|
||||
tsleep(&uha->free_mscp, PRIBIO, "uhamsc", 0);
|
||||
}
|
||||
|
||||
uha_reset_mscp(uha, mscp);
|
||||
mscp->flags = MSCP_ACTIVE;
|
||||
|
||||
out:
|
||||
splx(s);
|
||||
return mscp;
|
||||
}
|
||||
@ -1144,7 +1166,6 @@ uha_scsi_cmd(xs)
|
||||
xs->error = XS_DRIVER_STUFFUP;
|
||||
return TRY_AGAIN_LATER;
|
||||
}
|
||||
mscp->flags = MSCP_ACTIVE;
|
||||
mscp->xs = xs;
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user