From: deraadt Date: Thu, 14 Dec 1995 06:35:34 +0000 (+0000) Subject: from netbsd: X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=0676b38e480f5ec8866fb43c670b481dfaf3d69b;p=openbsd from netbsd: Don't use the softc at probe time on pci devices because it has not been allocated yet --- diff --git a/sys/dev/pci/aic7870.c b/sys/dev/pci/aic7870.c index b0b362b50fb..e07e00a3a33 100644 --- a/sys/dev/pci/aic7870.c +++ b/sys/dev/pci/aic7870.c @@ -19,7 +19,7 @@ * 4. Modifications may be freely made to this file if the above conditions * are met. * - * $Id: aic7870.c,v 1.1.1.1 1995/10/18 08:52:39 deraadt Exp $ + * $Id: aic7870.c,v 1.2 1995/12/14 06:35:34 deraadt Exp $ */ #include @@ -33,16 +33,17 @@ #include #include -#include +#include +#include -#define PCI_BASEADR0 PCI_MAP_REG_START -#define PCI_DEVICE_ID_ADAPTEC_2940 0x71789004ul -#define PCI_DEVICE_ID_ADAPTEC_AIC7870 0x70789004ul +#define PCI_BASEADR0 PCI_MAP_REG_START +#define PCI_VENDORID(x) ((x) & 0xFFFF) +#define PCI_CHIPID(x) (((x) >> 16) & 0xFFFF) -static int aic7870_probe(); -static void aic7870_attach(); +static int aic7870_probe __P((struct device *, void *, void *)); +static void aic7870_attach __P((struct device *, struct device *, void *)); struct cfdriver ahccd = { NULL, "ahc", aic7870_probe, aic7870_attach, DV_DULL, @@ -59,11 +60,17 @@ aic7870_probe(parent, match, aux) { struct pci_attach_args *pa = aux; - if (pa->pa_id != PCI_DEVICE_ID_ADAPTEC_2940 && - pa->pa_id != PCI_DEVICE_ID_ADAPTEC_AIC7870) - return (0); - - return (1); + if (PCI_VENDORID(pa->pa_id) != PCI_VENDOR_ADP) + return 0; + + switch (PCI_CHIPID(pa->pa_id)) { + case PCI_PRODUCT_ADP_AIC7870: + case PCI_PRODUCT_ADP_AIC2940: + case PCI_PRODUCT_ADP_AIC2940U: + return 1; + default: + return 0; + } } void @@ -75,14 +82,16 @@ aic7870_attach(parent, self, aux) struct ahc_softc *ahc = (void *)self; int iobase; - switch (pa->pa_id) { - case PCI_DEVICE_ID_ADAPTEC_2940: - ahc->type = AHC_294; - break; - case PCI_DEVICE_ID_ADAPTEC_AIC7870: + switch (PCI_CHIPID(pa->pa_id)) { + case PCI_PRODUCT_ADP_AIC7870: ahc->type = AHC_AIC7870; - break; - } + break; + + case PCI_PRODUCT_ADP_AIC2940: + case PCI_PRODUCT_ADP_AIC2940U: + ahc->type = AHC_294; + break; + } if (pci_map_io(pa->pa_tag, PCI_BASEADR0, &iobase)) return; @@ -98,4 +107,4 @@ aic7870_attach(parent, self, aux) ahcattach(ahc); ahc->sc_ih = pci_map_int(pa->pa_tag, PCI_IPL_BIO, ahcintr, ahc); -} +}