use a submatch function for drive attachment, and pass locators

just for sanity
This commit is contained in:
drochner 2004-09-01 20:57:58 +00:00
parent ab6077db18
commit 0b2a837787
3 changed files with 29 additions and 20 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: ed_mca.c,v 1.23 2004/08/13 04:10:49 thorpej Exp $ */
/* $NetBSD: ed_mca.c,v 1.24 2004/09/01 20:57:58 drochner Exp $ */
/*
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@ -38,10 +38,9 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ed_mca.c,v 1.23 2004/08/13 04:10:49 thorpej Exp $");
__KERNEL_RCSID(0, "$NetBSD: ed_mca.c,v 1.24 2004/09/01 20:57:58 drochner Exp $");
#include "rnd.h"
#include "locators.h"
#include <sys/param.h>
#include <sys/systm.h>
@ -131,13 +130,6 @@ ed_mca_probe(parent, cf, aux)
struct ed_attach_args *eda = (struct ed_attach_args *) aux;
int found = 1;
/*
* Check we match hardwired config.
*/
if (cf->edccf_unit != EDCCF_DRIVE_DEFAULT &&
cf->edccf_unit != eda->edc_drive)
return (0);
/*
* Get Device Configuration (09).
*/

View File

@ -1,4 +1,4 @@
/* $NetBSD: edc_mca.c,v 1.24 2004/08/30 18:28:33 drochner Exp $ */
/* $NetBSD: edc_mca.c,v 1.25 2004/09/01 20:57:58 drochner Exp $ */
/*
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@ -50,7 +50,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: edc_mca.c,v 1.24 2004/08/30 18:28:33 drochner Exp $");
__KERNEL_RCSID(0, "$NetBSD: edc_mca.c,v 1.25 2004/09/01 20:57:58 drochner Exp $");
#include "rnd.h"
@ -82,6 +82,8 @@ __KERNEL_RCSID(0, "$NetBSD: edc_mca.c,v 1.24 2004/08/30 18:28:33 drochner Exp $"
#include <dev/mca/edvar.h>
#include <dev/mca/edcvar.h>
#include "locators.h"
#define EDC_ATTN_MAXTRIES 10000 /* How many times check for unbusy */
#define EDC_MAX_CMD_RES_LEN 8
@ -147,6 +149,18 @@ edc_mca_probe(parent, match, aux)
}
}
static int
edcsubmatch(struct device *parent, struct cfdata *cf,
const locdesc_t *ldesc, void *aux)
{
if (cf->cf_loc[EDCCF_DRIVE] != EDCCF_DRIVE_DEFAULT &&
cf->cf_loc[EDCCF_DRIVE] != ldesc->locs[EDCCF_DRIVE])
return (0);
return (config_match(parent, cf, aux));
}
void
edc_mca_attach(parent, self, aux)
struct device *parent, *self;
@ -159,6 +173,8 @@ edc_mca_attach(parent, self, aux)
int irq, drq, iobase;
const char *typestr;
int devno, error;
int help[2];
locdesc_t *ldesc = (void *)help; /* XXX */
pos2 = mca_conf_read(ma->ma_mc, ma->ma_slot, 2);
pos3 = mca_conf_read(ma->ma_mc, ma->ma_slot, 3);
@ -287,13 +303,13 @@ edc_mca_attach(parent, self, aux)
/* "SOFT" reset */
edc_do_attn(sc, ATN_RESET_ATTACHMENT, DASD_DEVNO_CONTROLLER,0);
}
/*
* Since interrupts are disabled, it's necessary
* to detect the interrupt request and call edc_intr()
* explicitly. See also edc_run_cmd().
*/
while(bus_space_read_1(sc->sc_iot, sc->sc_ioh, BSR) & BSR_BUSY) {
while (bus_space_read_1(sc->sc_iot, sc->sc_ioh, BSR) & BSR_BUSY) {
if (bus_space_read_1(sc->sc_iot, sc->sc_ioh, BSR) & BSR_INTR)
edc_intr(sc);
@ -304,10 +320,13 @@ edc_mca_attach(parent, self, aux)
sc->sc_flags |= DASD_QUIET;
/* check for attached disks */
for(devno=0; devno < sc->sc_maxdevs; devno++) {
for (devno = 0; devno < sc->sc_maxdevs; devno++) {
eda.edc_drive = devno;
ldesc->len = 1;
ldesc->locs[EDCCF_DRIVE] = devno;
sc->sc_ed[devno] =
(void *) config_found(self, &eda, NULL);
(void *) config_found_sm_loc(self, "edc", ldesc, &eda,
NULL, edcsubmatch);
/* If initialization did not succeed, NULL the pointer. */
if (sc->sc_ed[devno]
@ -322,7 +341,7 @@ edc_mca_attach(parent, self, aux)
* Check if there are any disks attached. If not, disestablish
* the interrupt.
*/
for(devno=0; devno < sc->sc_maxdevs; devno++) {
for (devno = 0; devno < sc->sc_maxdevs; devno++) {
if (sc->sc_ed[devno])
break;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: edcvar.h,v 1.4 2001/11/24 12:46:15 jdolecek Exp $ */
/* $NetBSD: edcvar.h,v 1.5 2004/09/01 20:57:58 drochner Exp $ */
/*
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@ -37,8 +37,6 @@ struct ed_attach_args {
int edc_drive;
};
#define edccf_unit cf_loc[EDCCF_DRIVE]
int edc_run_cmd __P((struct edc_mca_softc *, int,
int, u_int16_t [], int, int));
void edc_add_disk __P((struct edc_mca_softc *, struct ed_softc *));