summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorgibbs <gibbs@FreeBSD.org>1996-01-07 19:24:36 +0000
committergibbs <gibbs@FreeBSD.org>1996-01-07 19:24:36 +0000
commit21ab51c58bbd24e544c67c6882dc2d41ad4fa518 (patch)
tree09f9e9f046457eedf06c3c3b012ea6dc848c332c /sys
parent379226f0723f8ea0319a027873dbd33bf106f327 (diff)
downloadFreeBSD-src-21ab51c58bbd24e544c67c6882dc2d41ad4fa518.zip
FreeBSD-src-21ab51c58bbd24e544c67c6882dc2d41ad4fa518.tar.gz
Use the new adapter_softc field in the scsi_link structure so that
these drivers don't need to maintain an array of configured units. The bt driver still needs to because ISA interrupt handlers take a unit number. :(
Diffstat (limited to 'sys')
-rw-r--r--sys/i386/scsi/aic7xxx.c47
-rw-r--r--sys/i386/scsi/aic7xxx.h4
-rw-r--r--sys/i386/scsi/bt.c12
3 files changed, 21 insertions, 42 deletions
diff --git a/sys/i386/scsi/aic7xxx.c b/sys/i386/scsi/aic7xxx.c
index e9ba5e5..4f74956 100644
--- a/sys/i386/scsi/aic7xxx.c
+++ b/sys/i386/scsi/aic7xxx.c
@@ -24,7 +24,7 @@
*
* commenced: Sun Sep 27 18:14:01 PDT 1992
*
- * $Id: aic7xxx.c,v 1.51 1996/01/03 06:32:10 gibbs Exp $
+ * $Id: aic7xxx.c,v 1.52 1996/01/05 16:13:44 gibbs Exp $
*/
/*
* TODO:
@@ -62,8 +62,6 @@
#define MIN(a,b) ((a < b) ? a : b)
#define ALL_TARGETS -1
-struct ahc_data *ahcdata[NAHC];
-
u_long ahc_unit = 0;
static int ahc_debug = AHC_SHOWABORTS|AHC_SHOWMISC;
@@ -248,9 +246,6 @@ static int ahc_num_syncrates =
* ahc_reset should be called before now since we assume that the card
* is paused.
*
- * Sticking the ahc structure into the ahcdata array is an artifact of the
- * need to index by unit. As soon as the upper level scsi code passes
- * pointers instead of units down to us, this will go away.
*/
struct ahc_data *
ahc_alloc(unit, iobase, type, flags)
@@ -266,26 +261,16 @@ ahc_alloc(unit, iobase, type, flags)
struct ahc_data *ahc;
- if (unit >= NAHC) {
- printf("ahc: unit number (%d) too high\n", unit);
- return 0;
- }
-
/*
* Allocate a storage area for us
*/
- if (ahcdata[unit]) {
- printf("ahc%d: memory already allocated\n", unit);
- return NULL;
- }
ahc = malloc(sizeof(struct ahc_data), M_TEMP, M_NOWAIT);
if (!ahc) {
printf("ahc%d: cannot malloc!\n", unit);
return NULL;
}
bzero(ahc, sizeof(struct ahc_data));
- ahcdata[unit] = ahc;
ahc->unit = unit;
ahc->baseport = iobase;
ahc->type = type;
@@ -300,7 +285,6 @@ void
ahc_free(ahc)
struct ahc_data *ahc;
{
- ahcdata[ahc->unit] = NULL;
free(ahc, M_DEVBUF);
return;
}
@@ -405,6 +389,7 @@ ahc_attach(ahc)
*/
ahc->sc_link.adapter_unit = ahc->unit;
ahc->sc_link.adapter_targ = ahc->our_id;
+ ahc->sc_link.adapter_softc = ahc;
ahc->sc_link.adapter = &ahc_switch;
ahc->sc_link.opennings = 2;
ahc->sc_link.device = &ahc_dev;
@@ -1565,18 +1550,19 @@ static int32
ahc_scsi_cmd(xs)
struct scsi_xfer *xs;
{
- struct scb *scb = NULL;
- struct ahc_dma_seg *sg;
+ struct scb *scb;
+ struct ahc_dma_seg *sg;
int seg; /* scatter gather seg being worked on */
int thiskv;
physaddr thisphys, nextphys;
- int unit = xs->sc_link->adapter_unit;
- u_short mask = (0x01 << (xs->sc_link->target
- | ((u_long)xs->sc_link->fordriver & 0x08)));
int bytes_this_seg, bytes_this_page, datalen, flags;
- struct ahc_data *ahc = ahcdata[unit];
+ struct ahc_data *ahc;
+ u_short mask;
int s;
+ ahc = (struct ahc_data *)xs->sc_link->adapter_softc;
+ mask = (0x01 << (xs->sc_link->target
+ | ((u_long)xs->sc_link->fordriver & 0x08)));
SC_DEBUG(xs->sc_link, SDEV_DB2, ("ahc_scsi_cmd\n"));
/*
* get an scb to use. If the transfer
@@ -1585,11 +1571,11 @@ ahc_scsi_cmd(xs)
*/
flags = xs->flags;
if (flags & ITSDONE) {
- printf("ahc%d: Already done?", unit);
+ printf("ahc%d: Already done?", ahc->unit);
xs->flags &= ~ITSDONE;
}
if (!(flags & INUSE)) {
- printf("ahc%d: Not in use?", unit);
+ printf("ahc%d: Not in use?", ahc->unit);
xs->flags |= INUSE;
}
if (!(scb = ahc_get_scb(ahc, flags))) {
@@ -1691,7 +1677,7 @@ ahc_scsi_cmd(xs)
if (datalen) {
/* there's still data, must have run out of segs! */
printf("ahc_scsi_cmd%d: more than %d DMA segs\n",
- unit, AHC_NSEG);
+ ahc->unit, AHC_NSEG);
xs->error = XS_DRIVER_STUFFUP;
ahc_free_scb(ahc, scb, flags);
return (HAD_ERROR);
@@ -1707,9 +1693,6 @@ ahc_scsi_cmd(xs)
scb->datalen = 0;
}
- /*
- * Usually return SUCCESSFULLY QUEUED
- */
#ifdef AHC_DEBUG
if((ahc_debug & AHC_SHOWSCBS) && (xs->sc_link->target == DEBUGTARG))
ahc_print_scb(scb);
@@ -2024,7 +2007,6 @@ static void
ahc_timeout(void *arg1)
{
struct scb *scb = (struct scb *)arg1;
- int unit;
struct ahc_data *ahc;
int s;
@@ -2036,9 +2018,8 @@ ahc_timeout(void *arg1)
return;
}
- unit = scb->xs->sc_link->adapter_unit;
- ahc = ahcdata[unit];
- printf("ahc%d: target %d, lun %d (%s%d) timed out\n", unit
+ ahc = (struct ahc_data *)scb->xs->sc_link->adapter_softc;
+ printf("ahc%d: target %d, lun %d (%s%d) timed out\n", ahc->unit
,scb->xs->sc_link->target
,scb->xs->sc_link->lun
,scb->xs->sc_link->device->name
diff --git a/sys/i386/scsi/aic7xxx.h b/sys/i386/scsi/aic7xxx.h
index f0038a6..c5a36ec 100644
--- a/sys/i386/scsi/aic7xxx.h
+++ b/sys/i386/scsi/aic7xxx.h
@@ -20,7 +20,7 @@
* 4. Modifications may be freely made to this file if the above conditions
* are met.
*
- * $Id: aic7xxx.h,v 1.16 1995/11/05 04:50:55 gibbs Exp $
+ * $Id: aic7xxx.h,v 1.17 1996/01/03 06:32:12 gibbs Exp $
*/
#ifndef _AIC7XXX_H_
@@ -201,8 +201,6 @@ extern int ahc_debug; /* Initialized in i386/scsi/aic7xxx.c */
UNPAUSE_SEQUENCER(ahc);
-extern struct ahc_data *ahcdata[NAHC];
-
void ahc_reset __P((u_long iobase));
struct ahc_data *ahc_alloc __P((int unit, u_long io_base, ahc_type type, ahc_flag flags));
void ahc_free __P((struct ahc_data *));
diff --git a/sys/i386/scsi/bt.c b/sys/i386/scsi/bt.c
index d6b9177..ff70e8b 100644
--- a/sys/i386/scsi/bt.c
+++ b/sys/i386/scsi/bt.c
@@ -12,7 +12,7 @@
* on the understanding that TFS is not responsible for the correct
* functioning of this software in any circumstances.
*
- * $Id: bt.c,v 1.2 1995/12/13 14:32:59 bde Exp $
+ * $Id: bt.c,v 1.3 1995/12/14 14:19:16 peter Exp $
*/
/*
@@ -502,6 +502,7 @@ bt_attach(bt)
*/
bt->sc_link.adapter_unit = bt->unit;
bt->sc_link.adapter_targ = bt->bt_scsi_dev;
+ bt->sc_link.adapter_softc = bt;
bt->sc_link.adapter = &bt_switch;
bt->sc_link.device = &bt_dev;
bt->sc_link.flags = bt->bt_bounce ? SDEV_BOUNCE : 0;
@@ -1243,11 +1244,10 @@ bt_scsi_cmd(xs)
int seg; /* scatter gather seg being worked on */
int thiskv;
physaddr thisphys, nextphys;
- int unit = xs->sc_link->adapter_unit;
int bytes_this_seg, bytes_this_page, datalen, flags;
struct bt_data *bt;
- bt = btdata[unit];
+ bt = (struct bt_data *)xs->sc_link->adapter_softc;
SC_DEBUG(xs->sc_link, SDEV_DB2, ("bt_scsi_cmd\n"));
/*
@@ -1257,11 +1257,11 @@ bt_scsi_cmd(xs)
*/
flags = xs->flags;
if (flags & ITSDONE) {
- printf("bt%d: Already done?\n", unit);
+ printf("bt%d: Already done?\n", bt->unit);
xs->flags &= ~ITSDONE;
}
if (!(flags & INUSE)) {
- printf("bt%d: Not in use?\n", unit);
+ printf("bt%d: Not in use?\n", bt->unit);
xs->flags |= INUSE;
}
if (!(ccb = bt_get_ccb(bt, flags))) {
@@ -1373,7 +1373,7 @@ bt_scsi_cmd(xs)
* there's still data, must have run out of segs!
*/
printf("bt%d: bt_scsi_cmd, more than %d DMA segs\n",
- unit, BT_NSEG);
+ bt->unit, BT_NSEG);
xs->error = XS_DRIVER_STUFFUP;
bt_free_ccb(bt, ccb, flags);
return (HAD_ERROR);
OpenPOWER on IntegriCloud