Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/pci When PCIVERBOSE is not included, pci_findvendor(...



details:   https://anonhg.NetBSD.org/src/rev/d5bdc8464557
branches:  trunk
changeset: 755061:d5bdc8464557
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Sat May 22 01:51:14 2010 +0000

description:
When PCIVERBOSE is not included, pci_findvendor() and pci_findproduct()
can return NULL.  Defend against this and print the values in hex if we
can't decode them properly.

diffstat:

 sys/dev/pci/cs4280.c |  21 ++++++++++++++++-----
 1 files changed, 16 insertions(+), 5 deletions(-)

diffs (49 lines):

diff -r 1eacb742dbd5 -r d5bdc8464557 sys/dev/pci/cs4280.c
--- a/sys/dev/pci/cs4280.c      Fri May 21 21:46:48 2010 +0000
+++ b/sys/dev/pci/cs4280.c      Sat May 22 01:51:14 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cs4280.c,v 1.57 2010/02/24 22:37:59 dyoung Exp $       */
+/*     $NetBSD: cs4280.c,v 1.58 2010/05/22 01:51:14 pgoyette Exp $     */
 
 /*
  * Copyright (c) 1999, 2000 Tatoku Ogaito.  All rights reserved.
@@ -52,7 +52,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cs4280.c,v 1.57 2010/02/24 22:37:59 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cs4280.c,v 1.58 2010/05/22 01:51:14 pgoyette Exp $");
 
 #include "midi.h"
 
@@ -242,6 +242,7 @@
        pci_chipset_tag_t pc;
        const struct cs4280_card_t *cs_card;
        char const *intrstr;
+       const char *vendor, *product;
        pcireg_t reg;
        char devinfo[256];
        uint32_t mem;
@@ -258,9 +259,19 @@
 
        cs_card = cs4280_identify_card(pa);
        if (cs_card != NULL) {
-               aprint_normal_dev(&sc->sc_dev, "%s %s\n",
-                             pci_findvendor(cs_card->id),
-                             pci_findproduct(cs_card->id));
+               vendor = pci_findvendor(cs_card->id);
+               product = pci_findproduct(cs_card->id);
+               if (vendor == NULL)
+                       aprint_normal_dev(&sc->sc_dev,
+                                         "vendor 0x%04x product 0x%04x\n",
+                                         PCI_VENDOR(cs_card->id),
+                                         PCI_PRODUCT(cs_card->id));
+               else if (product == NULL)
+                       aprint_normal_dev(&sc->sc_dev, "%s product 0x%04x\n",
+                                         vendor, PCI_PRODUCT(cs_card->id));
+               else
+                       aprint_normal_dev(&sc->sc_dev, "%s %s\n",
+                                         vendor, product);
                sc->sc_flags = cs_card->flags;
        } else {
                sc->sc_flags = CS428X_FLAG_NONE;



Home | Main Index | Thread Index | Old Index