Split device_t/softc and other related cosmetic changes. trunk
authorcube <cube@NetBSD.org>
Tue, 04 Mar 2008 15:33:06 +0000
branchtrunk
changeset 167569 8048f279c7d6
parent 167568 831d7b31c0b7
child 167570 5fbb3f2b5644
Split device_t/softc and other related cosmetic changes.
sys/arch/x86/pci/pchb.c
sys/arch/x86/pci/pchb_rnd.c
sys/arch/x86/pci/pchbvar.h
--- a/sys/arch/x86/pci/pchb.c	Tue Mar 04 15:24:02 2008 +0000
+++ b/sys/arch/x86/pci/pchb.c	Tue Mar 04 15:33:06 2008 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: pchb.c,v 1.8 2008/02/29 06:27:15 dyoung Exp $ */
+/*	$NetBSD: pchb.c,v 1.9 2008/03/04 15:33:06 cube Exp $ */
 
 /*-
  * Copyright (c) 1996, 1998, 2000 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pchb.c,v 1.8 2008/02/29 06:27:15 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pchb.c,v 1.9 2008/03/04 15:33:06 cube Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -78,18 +78,18 @@
 #define I82424_BCTL_PCIMEM_BURSTEN	0x01
 #define I82424_BCTL_PCI_BURSTEN		0x02
 
-int	pchbmatch(struct device *, struct cfdata *, void *);
-void	pchbattach(struct device *, struct device *, void *);
+int	pchbmatch(device_t, cfdata_t, void *);
+void	pchbattach(device_t, device_t, void *);
 int	pchbdetach(device_t, int);
 
 static bool	pchb_resume(device_t PMF_FN_ARGS);
 static bool	pchb_suspend(device_t PMF_FN_ARGS);
 
-CFATTACH_DECL(pchb, sizeof(struct pchb_softc),
+CFATTACH_DECL_NEW(pchb, sizeof(struct pchb_softc),
     pchbmatch, pchbattach, pchbdetach, NULL);
 
 int
-pchbmatch(struct device *parent, struct cfdata *match, void *aux)
+pchbmatch(device_t parent, cfdata_t match, void *aux)
 {
 	struct pci_attach_args *pa = aux;
 
@@ -101,11 +101,9 @@
 }
 
 void
-pchbattach(struct device *parent, struct device *self, void *aux)
+pchbattach(device_t parent, device_t self, void *aux)
 {
-#if NRND > 0
-	struct pchb_softc *sc = (void *) self;
-#endif
+	struct pchb_softc *sc = device_private(self);
 	struct pci_attach_args *pa = aux;
 	char devinfo[256];
 	struct pcibus_attach_args pba;
@@ -122,13 +120,15 @@
 	has_agp = 0;
 	attachflags = pa->pa_flags;
 
+	sc->sc_dev = self;
+
 	/*
 	 * Print out a description, and configure certain chipsets which
 	 * have auxiliary PCI buses.
 	 */
 
 	pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo, sizeof(devinfo));
-	aprint_normal("%s: %s (rev. 0x%02x)\n", self->dv_xname, devinfo,
+	aprint_normal_dev(self, "%s (rev. 0x%02x)\n", devinfo,
 	    PCI_REVISION(pa->pa_class));
 
 	switch (PCI_VENDOR(pa->pa_id)) {
@@ -161,9 +161,10 @@
 			   buses. */
 			break;
 		default:
-			aprint_error("%s: unknown ServerWorks chip ID "
-			    "0x%04x; trying to attach PCI buses behind it\n",
-			    self->dv_xname, PCI_PRODUCT(pa->pa_id));
+			aprint_error_dev(self,
+			    "unknown ServerWorks chip ID 0x%04x; trying "
+			    "to attach PCI buses behind it\n",
+			    PCI_PRODUCT(pa->pa_id));
 			/* FALLTHROUGH */
 		case PCI_PRODUCT_SERVERWORKS_CNB20_LE_AGP:
 		case PCI_PRODUCT_SERVERWORKS_CNB30_LE_PCI:
@@ -237,17 +238,16 @@
 			pbnum = PCISET_PCI_BUS_NUMBER(bcreg);
 			switch (bdnum & PCISET_BRIDGETYPE_MASK) {
 			default:
-				aprint_error("%s: bdnum=%x (reserved)\n",
-				       self->dv_xname, bdnum);
+				aprint_error_dev(self, "bdnum=%x (reserved)\n",
+				       bdnum);
 				break;
 			case PCISET_TYPE_COMPAT:
-				aprint_verbose(
-				    "%s: Compatibility PB (bus %d)\n",
-				    self->dv_xname, pbnum);
+				aprint_verbose_dev(self,
+				    "Compatibility PB (bus %d)\n", pbnum);
 				break;
 			case PCISET_TYPE_AUX:
-				aprint_verbose("%s: Auxiliary PB (bus %d)\n",
-				       self->dv_xname, pbnum);
+				aprint_verbose_dev(self,
+				    "Auxiliary PB (bus %d)\n",pbnum);
 				/*
 				 * This host bridge has a second PCI bus.
 				 * Configure it.
@@ -263,9 +263,8 @@
 				bcreg &= ~I82424_BCTL_CPUPCI_POSTEN;
 				pci_conf_write(pa->pa_pc, pa->pa_tag,
 					       I82424_CPU_BCTL_REG, bcreg);
-				aprint_verbose(
-				    "%s: disabled CPU-PCI write posting\n",
-				    self->dv_xname);
+				aprint_verbose_dev(self,
+				    "disabled CPU-PCI write posting\n");
 			}
 			break;
 		case PCI_PRODUCT_INTEL_82451NX_PXB:
--- a/sys/arch/x86/pci/pchb_rnd.c	Tue Mar 04 15:24:02 2008 +0000
+++ b/sys/arch/x86/pci/pchb_rnd.c	Tue Mar 04 15:33:06 2008 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: pchb_rnd.c,v 1.7 2008/01/03 04:50:19 dyoung Exp $	*/
+/*	$NetBSD: pchb_rnd.c,v 1.8 2008/03/04 15:33:06 cube Exp $	*/
 
 /*
  * Copyright (c) 2000 Michael Shalayeff
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pchb_rnd.c,v 1.7 2008/01/03 04:50:19 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pchb_rnd.c,v 1.8 2008/03/04 15:33:06 cube Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -165,7 +165,7 @@
 		}
 		if (i == PCHB_RNG_RETRIES) {
 			bus_space_unmap(sc->sc_st, sc->sc_sh, I82802_IOSIZE);
-			aprint_verbose_dev(&sc->sc_dev,
+			aprint_verbose_dev(sc->sc_dev,
 			    "timeout reading test samples, RNG disabled.\n");
 			return;
 		}
@@ -175,7 +175,7 @@
 
 	if (count_ff == PCHB_RNG_MIN_SAMPLES) {
 		bus_space_unmap(sc->sc_st, sc->sc_sh, I82802_IOSIZE);
-		aprint_verbose_dev(&sc->sc_dev,
+		aprint_verbose_dev(sc->sc_dev,
 		    "returns constant 0xff stream, RNG disabled.\n");
 		return;
 	}
@@ -189,11 +189,11 @@
 	 *	http://csrc.nist.gov/fips/fips1401.htm
 	 */
 
-	aprint_normal_dev(&sc->sc_dev, "random number generator enabled\n");
+	aprint_normal_dev(sc->sc_dev, "random number generator enabled\n");
 
 	callout_init(&sc->sc_rnd_ch, 0);
 	/* pch is polled for entropy, so no estimate is available. */
-	rnd_attach_source(&sc->sc_rnd_source, sc->sc_dev.dv_xname,
+	rnd_attach_source(&sc->sc_rnd_source, device_xname(sc->sc_dev),
 	    RND_TYPE_RNG, RND_FLAG_NO_ESTIMATE);
 	sc->sc_rnd_i = sizeof(sc->sc_rnd_ax);
 	pchb_rnd_callout(sc);
--- a/sys/arch/x86/pci/pchbvar.h	Tue Mar 04 15:24:02 2008 +0000
+++ b/sys/arch/x86/pci/pchbvar.h	Tue Mar 04 15:33:06 2008 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: pchbvar.h,v 1.3 2008/01/03 04:50:19 dyoung Exp $	*/
+/*	$NetBSD: pchbvar.h,v 1.4 2008/03/04 15:33:06 cube Exp $	*/
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -43,7 +43,7 @@
 #include <sys/rnd.h>
 
 struct pchb_softc {
-	struct device sc_dev;
+	device_t sc_dev;
 
 	pci_chipset_tag_t sc_pc;
 	pcitag_t sc_tag;