Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/pcmcia Add a pcmcia_devinfo() function (akin to pci_...



details:   https://anonhg.NetBSD.org/src/rev/edc65d00d45e
branches:  trunk
changeset: 481823:edc65d00d45e
user:      augustss <augustss%NetBSD.org@localhost>
date:      Mon Feb 07 09:35:29 2000 +0000

description:
Add a pcmcia_devinfo() function (akin to pci_devinfo).  It generates a
string suitable for printing in the attach message.

diffstat:

 sys/dev/pcmcia/pcmcia.c    |  36 +++++++++++++++++++++++-------------
 sys/dev/pcmcia/pcmciavar.h |   5 ++++-
 2 files changed, 27 insertions(+), 14 deletions(-)

diffs (77 lines):

diff -r 60e2b56d458c -r edc65d00d45e sys/dev/pcmcia/pcmcia.c
--- a/sys/dev/pcmcia/pcmcia.c   Mon Feb 07 06:15:16 2000 +0000
+++ b/sys/dev/pcmcia/pcmcia.c   Mon Feb 07 09:35:29 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pcmcia.c,v 1.17 2000/02/05 20:02:43 nathanw Exp $      */
+/*     $NetBSD: pcmcia.c,v 1.18 2000/02/07 09:35:29 augustss Exp $     */
 
 #define        PCMCIADEBUG
 
@@ -302,26 +302,36 @@
        struct pcmcia_attach_args *pa = arg;
        struct pcmcia_softc *sc = pa->pf->sc;
        struct pcmcia_card *card = &sc->card;
-       int i;
+       char devinfo[256];
 
        if (pnp) {
-               for (i = 0; i < 4; i++) {
-                       if (card->cis1_info[i] == NULL)
-                               break;
-                       if (i)
-                               printf(", ");
-                       printf("%s", card->cis1_info[i]);
-               }
-               if (i)
-                       printf(" ");
-               printf("(manufacturer 0x%x, product 0x%x)", card->manufacturer,
-                      card->product);
+               pcmcia_devinfo(card, 1, devinfo, sizeof devinfo);
+               printf("%s", devinfo);
        }
        printf(" function %d", pa->pf->number);
 
        return (UNCONF);
 }
 
+void
+pcmcia_devinfo(card, showhex, cp, cplen)
+       struct pcmcia_card *card;
+       char *cp;
+       int cplen;
+{
+       int i, n;
+
+       for (i = 0; i < 4 && card->cis1_info[i] != NULL && cplen > 0; i++) {
+               n = snprintf(cp, cplen, "%s%s", i ? ", " : "",
+                       card->cis1_info[i]);
+               cp += n;
+               cplen -= n;
+       }
+       if (showhex && cplen > 0)
+               snprintf(cp, cplen, "%s(manufacturer 0x%04x, product 0x%04x)",
+                   i ? " " : "", card->manufacturer, card->product);
+}
+
 const struct pcmcia_product *
 pcmcia_product_lookup(pa, tab, ent_size, matchfn)
        struct pcmcia_attach_args *pa;
diff -r 60e2b56d458c -r edc65d00d45e sys/dev/pcmcia/pcmciavar.h
--- a/sys/dev/pcmcia/pcmciavar.h        Mon Feb 07 06:15:16 2000 +0000
+++ b/sys/dev/pcmcia/pcmciavar.h        Mon Feb 07 09:35:29 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pcmciavar.h,v 1.10 2000/02/04 01:27:14 cgd Exp $       */
+/*     $NetBSD: pcmciavar.h,v 1.11 2000/02/07 09:35:29 augustss Exp $  */
 
 /*
  * Copyright (c) 1997 Marc Horowitz.  All rights reserved.
@@ -217,6 +217,9 @@
            const struct pcmcia_product *tab, size_t ent_size,
            pcmcia_product_match_fn matchfn));
 
+void pcmcia_devinfo __P((struct pcmcia_card *card, int showhex, char *cp, 
+                        int cplen));
+
 void   pcmcia_read_cis __P((struct pcmcia_softc *));
 void   pcmcia_check_cis_quirks __P((struct pcmcia_softc *));
 void   pcmcia_print_cis __P((struct pcmcia_softc *));



Home | Main Index | Thread Index | Old Index