for drivers that support only one instance, use a global variable to ensure
that only one instance is configured rather than requiring that its unit number be zero.
This commit is contained in:
parent
0ded74691b
commit
1da81163d5
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: mainbus.c,v 1.5 2003/07/15 02:43:42 lukem Exp $ */
|
||||
/* $NetBSD: mainbus.c,v 1.6 2004/12/13 02:31:56 chs Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995 Carnegie-Mellon University.
|
||||
|
@ -29,7 +29,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.5 2003/07/15 02:43:42 lukem Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.6 2004/12/13 02:31:56 chs Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -50,15 +50,16 @@ static int mbprint __P((void *, const char *));
|
|||
CFATTACH_DECL(mainbus, sizeof(struct mainbus_softc),
|
||||
mbmatch, mbattach, NULL, NULL);
|
||||
|
||||
static int mb_attached;
|
||||
|
||||
static int
|
||||
mbmatch(parent, cfdata, aux)
|
||||
struct device *parent;
|
||||
struct cfdata *cfdata;
|
||||
void *aux;
|
||||
{
|
||||
struct cfdata *cf = cfdata;
|
||||
|
||||
if (cf->cf_unit > 0)
|
||||
if (mb_attached)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
|
@ -73,6 +74,8 @@ mbattach(parent, self, aux)
|
|||
register struct device *mb = self;
|
||||
struct confargs nca;
|
||||
|
||||
mb_attached = 1;
|
||||
|
||||
printf("\n");
|
||||
|
||||
nca.ca_name = "cpu";
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: if_le.c,v 1.6 2003/07/15 02:43:43 lukem Exp $ */
|
||||
/* $NetBSD: if_le.c,v 1.7 2004/12/13 02:31:56 chs Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1996, 2000 The NetBSD Foundation, Inc.
|
||||
|
@ -37,7 +37,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_le.c,v 1.6 2003/07/15 02:43:43 lukem Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_le.c,v 1.7 2004/12/13 02:31:56 chs Exp $");
|
||||
|
||||
#include "opt_inet.h"
|
||||
#include "bpfilter.h"
|
||||
|
@ -94,6 +94,8 @@ static void le_attach __P((struct device *, struct device *, void *));
|
|||
CFATTACH_DECL(le, sizeof(struct le_softc),
|
||||
le_match, le_attach, NULL, NULL);
|
||||
|
||||
static int le_attached;
|
||||
|
||||
#if defined(_KERNEL_OPT)
|
||||
#include "opt_ddb.h"
|
||||
#endif
|
||||
|
@ -145,15 +147,10 @@ le_match(parent, cf, aux)
|
|||
if (strcmp(ca->ca_name, "le"))
|
||||
return 0;
|
||||
|
||||
switch(cf->cf_unit) {
|
||||
|
||||
case 0:
|
||||
addr = LANCE_PORT;
|
||||
break;
|
||||
default:
|
||||
if (le_attached)
|
||||
return 0;
|
||||
}
|
||||
|
||||
addr = LANCE_PORT;
|
||||
if (badaddr((void *)addr, 1))
|
||||
return 0;
|
||||
|
||||
|
@ -175,19 +172,11 @@ le_attach(parent, self, aux)
|
|||
bus_dma_segment_t seg;
|
||||
int rseg;
|
||||
|
||||
/*struct confargs *ca = aux;*/
|
||||
u_char *id;
|
||||
int i;
|
||||
caddr_t kvaddr;
|
||||
|
||||
switch (sc->sc_dev.dv_unit) {
|
||||
case 0:
|
||||
id = (u_char *)(ETHER_ID);
|
||||
break;
|
||||
default:
|
||||
panic("le_attach");
|
||||
}
|
||||
|
||||
id = (u_char *)ETHER_ID;
|
||||
lesc->sc_bustag = ca->ca_bustag;
|
||||
dmat = lesc->sc_dmatag = ca->ca_dmatag;
|
||||
|
||||
|
|
Loading…
Reference in New Issue