Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-1-5]: src/sys/dev/pci Pull up revision 1.12 (requested by ad):
details: https://anonhg.NetBSD.org/src/rev/161d019afacd
branches: netbsd-1-5
changeset: 492652:161d019afacd
user: he <he%NetBSD.org@localhost>
date: Tue Jan 29 23:31:48 2002 +0000
description:
Pull up revision 1.12 (requested by ad):
Some fixes:
o Always validate return value read from outbound FIFO
o Copy access method into to softc to avoid double dereference
o Remove static on functions
Fixes PR#14453.
diffstat:
sys/dev/pci/cac_pci.c | 59 +++++++++++++++++++++++++++-----------------------
1 files changed, 32 insertions(+), 27 deletions(-)
diffs (160 lines):
diff -r 6c6e6a831d3e -r 161d019afacd sys/dev/pci/cac_pci.c
--- a/sys/dev/pci/cac_pci.c Tue Jan 29 23:31:32 2002 +0000
+++ b/sys/dev/pci/cac_pci.c Tue Jan 29 23:31:48 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cac_pci.c,v 1.4.2.1 2001/10/25 18:01:54 he Exp $ */
+/* $NetBSD: cac_pci.c,v 1.4.2.2 2002/01/29 23:31:48 he Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -55,21 +55,21 @@
#include <dev/ic/cacreg.h>
#include <dev/ic/cacvar.h>
-static void cac_pci_attach(struct device *, struct device *, void *);
-static struct cac_pci_type *cac_pci_findtype(struct pci_attach_args *);
-static int cac_pci_match(struct device *, struct cfdata *, void *);
+void cac_pci_attach(struct device *, struct device *, void *);
+const struct cac_pci_type *cac_pci_findtype(struct pci_attach_args *);
+int cac_pci_match(struct device *, struct cfdata *, void *);
-static struct cac_ccb *cac_pci_l0_completed(struct cac_softc *);
-static int cac_pci_l0_fifo_full(struct cac_softc *);
-static void cac_pci_l0_intr_enable(struct cac_softc *, int);
-static int cac_pci_l0_intr_pending(struct cac_softc *);
-static void cac_pci_l0_submit(struct cac_softc *, struct cac_ccb *);
+struct cac_ccb *cac_pci_l0_completed(struct cac_softc *);
+int cac_pci_l0_fifo_full(struct cac_softc *);
+void cac_pci_l0_intr_enable(struct cac_softc *, int);
+int cac_pci_l0_intr_pending(struct cac_softc *);
+void cac_pci_l0_submit(struct cac_softc *, struct cac_ccb *);
struct cfattach cac_pci_ca = {
sizeof(struct cac_softc), cac_pci_match, cac_pci_attach
};
-static struct cac_linkage cac_pci_l0 = {
+static const struct cac_linkage cac_pci_l0 = {
cac_pci_l0_completed,
cac_pci_l0_fifo_full,
cac_pci_l0_intr_enable,
@@ -82,9 +82,9 @@
struct cac_pci_type {
int ct_subsysid;
int ct_flags;
- struct cac_linkage *ct_linkage;
- char *ct_typestr;
-} static cac_pci_type[] = {
+ const struct cac_linkage *ct_linkage;
+ const char *ct_typestr;
+} static const cac_pci_type[] = {
{ 0x40300e11, 0, &cac_l0, "SMART-2/P" },
{ 0x40310e11, 0, &cac_l0, "SMART-2SL" },
{ 0x40320e11, 0, &cac_l0, "Smart Array 3200" },
@@ -100,17 +100,17 @@
struct cac_pci_product {
u_short cp_vendor;
u_short cp_product;
-} static cac_pci_product[] = {
+} static const cac_pci_product[] = {
{ PCI_VENDOR_COMPAQ, PCI_PRODUCT_COMPAQ_SMART2P },
{ PCI_VENDOR_DEC, PCI_PRODUCT_DEC_CPQ42XX },
{ PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_1510 },
};
-static struct cac_pci_type *
+const struct cac_pci_type *
cac_pci_findtype(struct pci_attach_args *pa)
{
- struct cac_pci_type *ct;
- struct cac_pci_product *cp;
+ const struct cac_pci_type *ct;
+ const struct cac_pci_product *cp;
pcireg_t subsysid;
int i;
@@ -141,18 +141,18 @@
return (ct);
}
-static int
+int
cac_pci_match(struct device *parent, struct cfdata *match, void *aux)
{
return (cac_pci_findtype(aux) != NULL);
}
-static void
+void
cac_pci_attach(struct device *parent, struct device *self, void *aux)
{
struct pci_attach_args *pa;
- struct cac_pci_type *ct;
+ const struct cac_pci_type *ct;
struct cac_softc *sc;
pci_chipset_tag_t pc;
pci_intr_handle_t ih;
@@ -225,11 +225,11 @@
printf(": Compaq %s\n", ct->ct_typestr);
/* Now attach to the bus-independent code. */
- sc->sc_cl = ct->ct_linkage;
+ memcpy(&sc->sc_cl, ct->ct_linkage, sizeof(sc->sc_cl));
cac_init(sc, intrstr, (ct->ct_flags & CT_STARTFW) != 0);
}
-static void
+void
cac_pci_l0_submit(struct cac_softc *sc, struct cac_ccb *ccb)
{
@@ -238,16 +238,21 @@
cac_outl(sc, CAC_42REG_CMD_FIFO, ccb->ccb_paddr);
}
-static struct cac_ccb *
+struct cac_ccb *
cac_pci_l0_completed(struct cac_softc *sc)
{
struct cac_ccb *ccb;
u_int32_t off;
if ((off = cac_inl(sc, CAC_42REG_DONE_FIFO)) == 0xffffffffU)
- return (0);
+ return (NULL);
cac_outl(sc, CAC_42REG_DONE_FIFO, 0);
+
+ if ((off & 3) != 0)
+ printf("%s: failed command list returned: %lx\n",
+ sc->sc_dv.dv_xname, (long)off);
+
off = (off & ~3) - sc->sc_ccbs_paddr;
ccb = (struct cac_ccb *)(sc->sc_ccbs + off);
@@ -257,21 +262,21 @@
return (ccb);
}
-static int
+int
cac_pci_l0_intr_pending(struct cac_softc *sc)
{
return ((cac_inl(sc, CAC_42REG_STATUS) & CAC_42_EXTINT) != 0);
}
-static void
+void
cac_pci_l0_intr_enable(struct cac_softc *sc, int state)
{
cac_outl(sc, CAC_42REG_INTR_MASK, (state ? 0 : 8)); /* XXX */
}
-static int
+int
cac_pci_l0_fifo_full(struct cac_softc *sc)
{
Home |
Main Index |
Thread Index |
Old Index