Source-Changes-HG archive

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

[src/trunk]: src/sys/dev - add a routine to get the name of the card.



details:   https://anonhg.NetBSD.org/src/rev/2fdf308a66a9
branches:  trunk
changeset: 767150:2fdf308a66a9
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Jul 09 23:18:05 2011 +0000

description:
- add a routine to get the name of the card.

diffstat:

 sys/dev/cardbus/if_tlp_cardbus.c |   9 ++++-----
 sys/dev/ic/tulip.c               |  16 +++++++++++++---
 sys/dev/ic/tulipvar.h            |   5 ++---
 sys/dev/pci/if_tlp_pci.c         |  11 +++++------
 4 files changed, 24 insertions(+), 17 deletions(-)

diffs (143 lines):

diff -r bf633393dc3b -r 2fdf308a66a9 sys/dev/cardbus/if_tlp_cardbus.c
--- a/sys/dev/cardbus/if_tlp_cardbus.c  Sat Jul 09 21:46:19 2011 +0000
+++ b/sys/dev/cardbus/if_tlp_cardbus.c  Sat Jul 09 23:18:05 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_tlp_cardbus.c,v 1.67 2010/03/10 00:21:10 dyoung Exp $       */
+/*     $NetBSD: if_tlp_cardbus.c,v 1.68 2011/07/09 23:18:05 christos Exp $     */
 
 /*-
  * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_tlp_cardbus.c,v 1.67 2010/03/10 00:21:10 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_tlp_cardbus.c,v 1.68 2011/07/09 23:18:05 christos Exp $");
 
 #include "opt_inet.h"
 
@@ -187,8 +187,7 @@
 {
        const struct tulip_cardbus_product *tcp;
 
-       for (tcp = tlp_cardbus_products;
-            tlp_chip_names[tcp->tcp_chip] != NULL;
+       for (tcp = tlp_cardbus_products; tcp->tcp_chip != TULIP_CHIP_INVALID;
             tcp++) {
                if (PCI_VENDOR(ca->ca_id) == tcp->tcp_vendor &&
                    PCI_PRODUCT(ca->ca_id) == tcp->tcp_product)
@@ -297,7 +296,7 @@
        }
 
        printf(": %s Ethernet, pass %d.%d\n",
-           tlp_chip_names[sc->sc_chip],
+           tlp_chip_name(sc->sc_chip),
            (sc->sc_rev >> 4) & 0xf, sc->sc_rev & 0xf);
 
        /*
diff -r bf633393dc3b -r 2fdf308a66a9 sys/dev/ic/tulip.c
--- a/sys/dev/ic/tulip.c        Sat Jul 09 21:46:19 2011 +0000
+++ b/sys/dev/ic/tulip.c        Sat Jul 09 23:18:05 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tulip.c,v 1.176 2010/11/13 13:52:02 uebayasi Exp $     */
+/*     $NetBSD: tulip.c,v 1.177 2011/07/09 23:18:05 christos Exp $     */
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2002 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tulip.c,v 1.176 2010/11/13 13:52:02 uebayasi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tulip.c,v 1.177 2011/07/09 23:18:05 christos Exp $");
 
 
 #include <sys/param.h>
@@ -69,7 +69,7 @@
 #include <dev/ic/tulipreg.h>
 #include <dev/ic/tulipvar.h>
 
-const char * const tlp_chip_names[] = TULIP_CHIP_NAMES;
+static const char * const tlp_chip_names[] = TULIP_CHIP_NAMES;
 
 static const struct tulip_txthresh_tab tlp_10_txthresh_tab[] =
     TLP_TXTHRESH_TAB_10;
@@ -6197,3 +6197,13 @@
                ifmedia_set(&sc->sc_mii.mii_media, IFM_ETHER|IFM_AUTO);
        }
 }
+
+const char *
+tlp_chip_name(tulip_chip_t t) {
+       if ((int)t < 0 || (int)t >= __arraycount(tlp_chip_names)) {
+               static char buf[256];
+               (void)snprintf(buf, sizeof(buf), "[unknown 0x%x]", t);
+               return buf;
+       }
+       return tlp_chip_names[t];
+}
diff -r bf633393dc3b -r 2fdf308a66a9 sys/dev/ic/tulipvar.h
--- a/sys/dev/ic/tulipvar.h     Sat Jul 09 21:46:19 2011 +0000
+++ b/sys/dev/ic/tulipvar.h     Sat Jul 09 23:18:05 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tulipvar.h,v 1.64 2009/04/17 15:22:35 cegger Exp $     */
+/*     $NetBSD: tulipvar.h,v 1.65 2011/07/09 23:18:05 christos Exp $   */
 
 /*-
  * Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc.
@@ -571,8 +571,6 @@
 #define        TULIP_SP_FIELD(x, f)    TULIP_SP_FIELD_C((x)[f * 2], (x)[f * 2 + 1])
 
 #ifdef _KERNEL
-extern const char * const tlp_chip_names[];
-
 extern const struct tulip_mediasw tlp_21040_mediasw;
 extern const struct tulip_mediasw tlp_21040_tp_mediasw;
 extern const struct tulip_mediasw tlp_21040_auibnc_mediasw;
@@ -604,6 +602,7 @@
 
 void   tlp_21140_gpio_get(struct tulip_softc *sc, struct ifmediareq *ifmr);
 int    tlp_21140_gpio_set(struct tulip_softc *sc);
+const char *tlp_chip_name(tulip_chip_t);
 
 #endif /* _KERNEL */
 
diff -r bf633393dc3b -r 2fdf308a66a9 sys/dev/pci/if_tlp_pci.c
--- a/sys/dev/pci/if_tlp_pci.c  Sat Jul 09 21:46:19 2011 +0000
+++ b/sys/dev/pci/if_tlp_pci.c  Sat Jul 09 23:18:05 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_tlp_pci.c,v 1.116 2010/01/21 16:14:39 martin Exp $  */
+/*     $NetBSD: if_tlp_pci.c,v 1.117 2011/07/09 23:18:05 christos Exp $        */
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2002 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_tlp_pci.c,v 1.116 2010/01/21 16:14:39 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_tlp_pci.c,v 1.117 2011/07/09 23:18:05 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -270,9 +270,8 @@
            PCI_SUBSYS_ID_REG)) == PCI_VENDOR_LMC)
                return NULL;
 
-       for (tpp = tlp_pci_products;
-            tlp_chip_names[tpp->tpp_chip] != NULL;
-            tpp++) {
+       for (tpp = tlp_pci_products; tpp->tpp_chip != TULIP_CHIP_INVALID;
+           tpp++) {
                if (PCI_VENDOR(pa->pa_id) == tpp->tpp_vendor &&
                    PCI_PRODUCT(pa->pa_id) == tpp->tpp_product)
                        return tpp;
@@ -461,7 +460,7 @@
        }
 
        aprint_normal(": %s Ethernet, pass %d.%d\n",
-           tlp_chip_names[sc->sc_chip],
+           tlp_chip_name(sc->sc_chip),
            (sc->sc_rev >> 4) & 0xf, sc->sc_rev & 0xf);
 
        switch (sc->sc_chip) {



Home | Main Index | Thread Index | Old Index