Source-Changes-HG archive

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

[src/trunk]: src/sys Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_...



details:   https://anonhg.NetBSD.org/src/rev/a0d6acd9f7c2
branches:  trunk
changeset: 773312:a0d6acd9f7c2
user:      drochner <drochner%NetBSD.org@localhost>
date:      Mon Jan 30 19:41:18 2012 +0000

description:
Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.

diffstat:

 sys/arch/x86/pci/pchb.c     |  11 +++--------
 sys/arch/x86/pci/pcib.c     |  11 +++--------
 sys/dev/pci/ahcisata_pci.c  |   9 +++------
 sys/dev/pci/amdpm.c         |  10 +++-------
 sys/dev/pci/auixp.c         |  13 ++++---------
 sys/dev/pci/autri.c         |   9 +++------
 sys/dev/pci/btvmei.c        |  11 +++--------
 sys/dev/pci/chipsfb.c       |   9 +++------
 sys/dev/pci/cmpci.c         |  10 +++-------
 sys/dev/pci/coram.c         |   9 +++------
 sys/dev/pci/cs4280.c        |  10 +++-------
 sys/dev/pci/cs4281.c        |  10 +++-------
 sys/dev/pci/cxdtv.c         |  11 +++--------
 sys/dev/pci/ehci_pci.c      |  11 +++--------
 sys/dev/pci/emuxki.c        |  10 ++++------
 sys/dev/pci/esa.c           |  10 ++++------
 sys/dev/pci/esm.c           |  11 +++--------
 sys/dev/pci/fwohci_pci.c    |  11 +++--------
 sys/dev/pci/genfb_pci.c     |   9 +++------
 sys/dev/pci/gtp.c           |  11 +++--------
 sys/dev/pci/hifn7751.c      |   8 +++-----
 sys/dev/pci/ichsmb.c        |  10 +++-------
 sys/dev/pci/if_an_pci.c     |  10 +++-------
 sys/dev/pci/if_cas.c        |   8 +++-----
 sys/dev/pci/if_dge.c        |   9 ++++-----
 sys/dev/pci/if_epic_pci.c   |   9 +++------
 sys/dev/pci/if_et.c         |   9 +++------
 sys/dev/pci/if_fxp_pci.c    |  14 +++++---------
 sys/dev/pci/if_gem_pci.c    |   9 +++------
 sys/dev/pci/if_ipw.c        |  11 ++++-------
 sys/dev/pci/if_iwi.c        |  11 ++++-------
 sys/dev/pci/if_iwn.c        |  10 +++-------
 sys/dev/pci/if_mtd_pci.c    |   8 +++-----
 sys/dev/pci/if_nfe.c        |   8 +++-----
 sys/dev/pci/if_ral_pci.c    |  11 ++++-------
 sys/dev/pci/if_re_pci.c     |   7 +++----
 sys/dev/pci/if_rtk_pci.c    |   8 +++-----
 sys/dev/pci/if_stge.c       |   6 +++---
 sys/dev/pci/if_vge.c        |   7 +++----
 sys/dev/pci/if_vr.c         |  10 +++-------
 sys/dev/pci/if_vte.c        |   9 +++------
 sys/dev/pci/if_wi_pci.c     |  12 +++---------
 sys/dev/pci/if_wm.c         |   7 +++----
 sys/dev/pci/if_wpi.c        |  11 ++++-------
 sys/dev/pci/igsfb_pci.c     |   8 +++-----
 sys/dev/pci/iha_pci.c       |   9 +++------
 sys/dev/pci/jmide.c         |   9 +++------
 sys/dev/pci/joy_pci.c       |   8 +++-----
 sys/dev/pci/machfb.c        |  10 +++-------
 sys/dev/pci/mpt_pci.c       |  10 +++-------
 sys/dev/pci/mvsata_pci.c    |   9 +++------
 sys/dev/pci/nca_pci.c       |  10 +++-------
 sys/dev/pci/nfsmb.c         |  10 +++-------
 sys/dev/pci/ohci_pci.c      |  10 +++-------
 sys/dev/pci/pccbb.c         |  14 ++++----------
 sys/dev/pci/pciide_common.c |  29 ++++++++++++++---------------
 sys/dev/pci/pcscp.c         |   8 +++-----
 sys/dev/pci/piixpm.c        |  11 +++--------
 sys/dev/pci/pm2fb.c         |   8 +++-----
 sys/dev/pci/r128fb.c        |   8 +++-----
 sys/dev/pci/radeonfb.c      |  10 +++-------
 sys/dev/pci/radeonfbvar.h   |   4 +---
 sys/dev/pci/sdhc_pci.c      |  10 +++-------
 sys/dev/pci/siisata_pci.c   |   9 +++------
 sys/dev/pci/sisfb.c         |   6 ++----
 sys/dev/pci/twa.c           |   7 +++----
 sys/dev/pci/ubsec.c         |   8 +++-----
 sys/dev/pci/uhci_pci.c      |  11 +++--------
 sys/dev/pci/vga_pci.c       |  10 +++-------
 sys/dev/pci/voodoofb.c      |   8 +++-----
 sys/dev/pci/voyager.c       |   8 +++-----
 sys/dev/pci/wcfb.c          |   9 +++------
 sys/dev/pci/yds.c           |   9 ++++-----
 73 files changed, 239 insertions(+), 469 deletions(-)

diffs (truncated from 2652 to 300 lines):

diff -r 6efe9c69b493 -r a0d6acd9f7c2 sys/arch/x86/pci/pchb.c
--- a/sys/arch/x86/pci/pchb.c   Mon Jan 30 19:38:45 2012 +0000
+++ b/sys/arch/x86/pci/pchb.c   Mon Jan 30 19:41:18 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pchb.c,v 1.32 2011/08/20 20:01:08 jakllsch Exp $ */
+/*     $NetBSD: pchb.c,v 1.33 2012/01/30 19:41:18 drochner Exp $ */
 
 /*-
  * Copyright (c) 1996, 1998, 2000 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pchb.c,v 1.32 2011/08/20 20:01:08 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pchb.c,v 1.33 2012/01/30 19:41:18 drochner Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -155,7 +155,6 @@
 {
        struct pchb_softc *sc = device_private(self);
        const struct pci_attach_args *pa = aux;
-       char devinfo[256];
        struct pcibus_attach_args pba;
        struct agpbus_attach_args apa;
        pcireg_t bcreg;
@@ -163,8 +162,6 @@
        pcitag_t tag;
        int doattach, attachflags, has_agp;
 
-       aprint_naive("\n");
-
        doattach = 0;
        has_agp = 0;
        attachflags = pa->pa_flags;
@@ -177,9 +174,7 @@
         * have auxiliary PCI buses.
         */
 
-       pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo, sizeof(devinfo));
-       aprint_normal(": %s (rev. 0x%02x)\n", devinfo,
-           PCI_REVISION(pa->pa_class));
+       pci_aprint_devinfo(pa, NULL);
 
        switch (PCI_VENDOR(pa->pa_id)) {
        /*
diff -r 6efe9c69b493 -r a0d6acd9f7c2 sys/arch/x86/pci/pcib.c
--- a/sys/arch/x86/pci/pcib.c   Mon Jan 30 19:38:45 2012 +0000
+++ b/sys/arch/x86/pci/pcib.c   Mon Jan 30 19:41:18 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pcib.c,v 1.13 2011/07/01 18:22:08 dyoung Exp $ */
+/*     $NetBSD: pcib.c,v 1.14 2012/01/30 19:41:18 drochner Exp $       */
 
 /*-
  * Copyright (c) 1996, 1998 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pcib.c,v 1.13 2011/07/01 18:22:08 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pcib.c,v 1.14 2012/01/30 19:41:18 drochner Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -185,17 +185,12 @@
 {
        struct pcib_softc *sc = device_private(self);
        struct pci_attach_args *pa = aux;
-       char devinfo[256];
-
-       aprint_naive("\n");
 
        /*
         * Just print out a description and defer configuration
         * until all PCI devices have been attached.
         */
-       pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo, sizeof(devinfo));
-       aprint_normal(": %s (rev. 0x%02x)\n", devinfo,
-           PCI_REVISION(pa->pa_class));
+       pci_aprint_devinfo(pa, NULL);
 
        sc->sc_pc = pa->pa_pc;
        sc->sc_tag = pa->pa_tag;
diff -r 6efe9c69b493 -r a0d6acd9f7c2 sys/dev/pci/ahcisata_pci.c
--- a/sys/dev/pci/ahcisata_pci.c        Mon Jan 30 19:38:45 2012 +0000
+++ b/sys/dev/pci/ahcisata_pci.c        Mon Jan 30 19:41:18 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ahcisata_pci.c,v 1.26 2011/08/06 14:56:33 jakllsch Exp $       */
+/*     $NetBSD: ahcisata_pci.c,v 1.27 2012/01/30 19:41:18 drochner Exp $       */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ahcisata_pci.c,v 1.26 2011/08/06 14:56:33 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ahcisata_pci.c,v 1.27 2012/01/30 19:41:18 drochner Exp $");
 
 #include <sys/types.h>
 #include <sys/malloc.h>
@@ -171,7 +171,6 @@
        struct pci_attach_args *pa = aux;
        struct ahci_pci_softc *psc = device_private(self);
        struct ahci_softc *sc = &psc->ah_sc;
-       char devinfo[256];
        const char *intrstr;
        bool ahci_cap_64bit;
        bool ahci_bad_64bit;
@@ -188,9 +187,7 @@
        psc->sc_pc = pa->pa_pc;
        psc->sc_pcitag = pa->pa_tag;
 
-       pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo, sizeof(devinfo));
-       aprint_naive(": AHCI disk controller\n");
-       aprint_normal(": %s\n", devinfo);
+       pci_aprint_devinfo(pa, "AHCI disk controller");
        
        if (pci_intr_map(pa, &intrhandle) != 0) {
                aprint_error_dev(self, "couldn't map interrupt\n");
diff -r 6efe9c69b493 -r a0d6acd9f7c2 sys/dev/pci/amdpm.c
--- a/sys/dev/pci/amdpm.c       Mon Jan 30 19:38:45 2012 +0000
+++ b/sys/dev/pci/amdpm.c       Mon Jan 30 19:41:18 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: amdpm.c,v 1.34 2010/02/07 20:55:46 pgoyette Exp $      */
+/*     $NetBSD: amdpm.c,v 1.35 2012/01/30 19:41:18 drochner Exp $      */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: amdpm.c,v 1.34 2010/02/07 20:55:46 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: amdpm.c,v 1.35 2012/01/30 19:41:18 drochner Exp $");
 
 #include "opt_amdpm.h"
 
@@ -87,15 +87,11 @@
 {
        struct amdpm_softc *sc = device_private(self);
        struct pci_attach_args *pa = aux;
-       char devinfo[256];
        pcireg_t confreg, pmptrreg;
        u_int32_t pmreg;
        int i;
 
-       aprint_naive("\n");
-       pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo, sizeof(devinfo));
-       aprint_normal(": %s (rev. 0x%02x)\n", devinfo,
-           PCI_REVISION(pa->pa_class));
+       pci_aprint_devinfo(pa, NULL);
 
        if (PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_NVIDIA_XBOX_SMBUS)
                sc->sc_nforce = 1;
diff -r 6efe9c69b493 -r a0d6acd9f7c2 sys/dev/pci/auixp.c
--- a/sys/dev/pci/auixp.c       Mon Jan 30 19:38:45 2012 +0000
+++ b/sys/dev/pci/auixp.c       Mon Jan 30 19:41:18 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: auixp.c,v 1.37 2011/12/02 11:58:44 jmcneill Exp $ */
+/* $NetBSD: auixp.c,v 1.38 2012/01/30 19:41:18 drochner Exp $ */
 
 /*
  * Copyright (c) 2004, 2005 Reinoud Zandijk <reinoud%netbsd.org@localhost>
@@ -50,7 +50,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: auixp.c,v 1.37 2011/12/02 11:58:44 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: auixp.c,v 1.38 2012/01/30 19:41:18 drochner Exp $");
 
 #include <sys/types.h>
 #include <sys/errno.h>
@@ -1100,8 +1100,7 @@
        const struct auixp_card_type *card;
        const char *intrstr;
        uint32_t data;
-       char devinfo[256];
-       int revision, error;
+       int error;
 
        sc = device_private(self);
        pa = (struct pci_attach_args *)aux;
@@ -1112,11 +1111,7 @@
 #endif
 
        /* print information confirming attachment */
-       aprint_naive(": Audio controller\n");
-
-       pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo, sizeof(devinfo));
-       revision = PCI_REVISION(pa->pa_class);
-       aprint_normal(": %s (rev. 0x%02x)\n", devinfo, revision);
+       pci_aprint_devinfo(pa, "Audio controller");
 
        /* set up details from our set of known `cards'/chips */
        for (card = auixp_card_types; card->pci_vendor_id; card++)
diff -r 6efe9c69b493 -r a0d6acd9f7c2 sys/dev/pci/autri.c
--- a/sys/dev/pci/autri.c       Mon Jan 30 19:38:45 2012 +0000
+++ b/sys/dev/pci/autri.c       Mon Jan 30 19:41:18 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: autri.c,v 1.48 2011/11/24 03:35:58 mrg Exp $   */
+/*     $NetBSD: autri.c,v 1.49 2012/01/30 19:41:18 drochner Exp $      */
 
 /*
  * Copyright (c) 2001 SOMEYA Yoshihiko and KUROSAWA Takahiro.
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: autri.c,v 1.48 2011/11/24 03:35:58 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autri.c,v 1.49 2012/01/30 19:41:18 drochner Exp $");
 
 #include "midi.h"
 
@@ -520,21 +520,18 @@
        struct autri_codec_softc *codec;
        pci_intr_handle_t ih;
        char const *intrstr;
-       char devinfo[256];
        int r;
        uint32_t reg;
 
        sc = device_private(self);
        pa = (struct pci_attach_args *)aux;
        pc = pa->pa_pc;
-       aprint_naive(": Audio controller\n");
 
        sc->sc_devid = pa->pa_id;
        sc->sc_class = pa->pa_class;
 
-       pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo, sizeof(devinfo));
+       pci_aprint_devinfo(pa, "Audio controller");
        sc->sc_revision = PCI_REVISION(pa->pa_class);
-       aprint_normal(": %s (rev. 0x%02x)\n", devinfo, sc->sc_revision);
 
        /* map register to memory */
        if (pci_mapreg_map(pa, AUTRI_PCI_MEMORY_BASE,
diff -r 6efe9c69b493 -r a0d6acd9f7c2 sys/dev/pci/btvmei.c
--- a/sys/dev/pci/btvmei.c      Mon Jan 30 19:38:45 2012 +0000
+++ b/sys/dev/pci/btvmei.c      Mon Jan 30 19:41:18 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: btvmei.c,v 1.27 2012/01/27 18:53:08 para Exp $ */
+/* $NetBSD: btvmei.c,v 1.28 2012/01/30 19:41:18 drochner Exp $ */
 
 /*
  * Copyright (c) 1999
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: btvmei.c,v 1.27 2012/01/27 18:53:08 para Exp $");
+__KERNEL_RCSID(0, "$NetBSD: btvmei.c,v 1.28 2012/01/30 19:41:18 drochner Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -90,19 +90,14 @@
        struct pci_attach_args *pa = aux;
        pci_chipset_tag_t pc = pa->pa_pc;
 
-       int rev;
-
        pci_intr_handle_t ih;
        const char *intrstr;
        struct vmebus_attach_args vaa;
 
-       aprint_naive(": VME bus adapter\n");
-
        sc->sc_pc = pc;
        sc->sc_dmat = pa->pa_dmat;
 
-       rev = PCI_REVISION(pci_conf_read(pc, pa->pa_tag, PCI_CLASS_REG));
-       aprint_normal(": BIT3 PCI-VME 617 rev %d\n", rev);
+       pci_aprint_devinfo_fancy(pa, "VME bus adapter", "BIT3 PCI-VME 617", 1);
 
        /*
         * Map CSR and mapping table spaces.
diff -r 6efe9c69b493 -r a0d6acd9f7c2 sys/dev/pci/chipsfb.c
--- a/sys/dev/pci/chipsfb.c     Mon Jan 30 19:38:45 2012 +0000
+++ b/sys/dev/pci/chipsfb.c     Mon Jan 30 19:41:18 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: chipsfb.c,v 1.30 2011/07/22 14:34:38 njoly Exp $       */
+/*     $NetBSD: chipsfb.c,v 1.31 2012/01/30 19:41:18 drochner Exp $    */
 
 /*
  * Copyright (c) 2006 Michael Lorenz
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: chipsfb.c,v 1.30 2011/07/22 14:34:38 njoly Exp $");
+__KERNEL_RCSID(0, "$NetBSD: chipsfb.c,v 1.31 2012/01/30 19:41:18 drochner Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -89,7 +89,6 @@
        struct chipsfb_pci_softc *scp = device_private(self);
        struct chipsfb_softc *sc = &scp->sc_chips;
        const struct pci_attach_args *pa = aux;
-       char devinfo[256];
        pcireg_t screg;



Home | Main Index | Thread Index | Old Index