Module Name:    src
Committed By:   kiyohara
Date:           Tue Jan  3 07:36:02 UTC 2012

Modified Files:
        src/sys/arch/mips/alchemy/dev: augpio.c aupci.c aupcmcia.c aupsc.c
            aupscvar.h aurtc.c ausmbus_psc.c auspi.c if_aumac.c

Log Message:
Use device_t instead of 'struct device *'.
Call aprint_* in auto-config time.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/mips/alchemy/dev/augpio.c \
    src/sys/arch/mips/alchemy/dev/aupsc.c \
    src/sys/arch/mips/alchemy/dev/auspi.c
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/mips/alchemy/dev/aupci.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/mips/alchemy/dev/aupcmcia.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/mips/alchemy/dev/aupscvar.h
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/mips/alchemy/dev/aurtc.c
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/mips/alchemy/dev/ausmbus_psc.c
cvs rdiff -u -r1.32 -r1.33 src/sys/arch/mips/alchemy/dev/if_aumac.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/mips/alchemy/dev/augpio.c
diff -u src/sys/arch/mips/alchemy/dev/augpio.c:1.6 src/sys/arch/mips/alchemy/dev/augpio.c:1.7
--- src/sys/arch/mips/alchemy/dev/augpio.c:1.6	Fri Jul  1 18:39:29 2011
+++ src/sys/arch/mips/alchemy/dev/augpio.c	Tue Jan  3 07:36:02 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: augpio.c,v 1.6 2011/07/01 18:39:29 dyoung Exp $ */
+/* $NetBSD: augpio.c,v 1.7 2012/01/03 07:36:02 kiyohara Exp $ */
 
 /*-
  * Copyright (c) 2006 Itronix Inc.
@@ -32,7 +32,7 @@
  */ 
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: augpio.c,v 1.6 2011/07/01 18:39:29 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: augpio.c,v 1.7 2012/01/03 07:36:02 kiyohara Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -53,7 +53,7 @@ __KERNEL_RCSID(0, "$NetBSD: augpio.c,v 1
 #include <mips/alchemy/dev/augpiovar.h>
 
 struct augpio_softc {
-	struct device			sc_dev;
+	device_t			sc_dev;
 	struct gpio_chipset_tag		sc_gc;
 	gpio_pin_t			sc_pins[AUGPIO_NPINS];
 	int				sc_npins;
@@ -63,10 +63,10 @@ struct augpio_softc {
 	int				(*sc_getctl)(void *, int);
 };
 
-static int augpio_match(struct device *, struct cfdata *, void *);
-static void augpio_attach(struct device *, struct device *, void *);
+static int augpio_match(device_t, struct cfdata *, void *);
+static void augpio_attach(device_t, device_t, void *);
 
-CFATTACH_DECL(augpio, sizeof(struct augpio_softc),
+CFATTACH_DECL_NEW(augpio, sizeof(struct augpio_softc),
     augpio_match, augpio_attach, NULL, NULL);
 
 #define	GETREG(x)	\
@@ -80,7 +80,7 @@ CFATTACH_DECL(augpio, sizeof(struct augp
 #define	PUTGPIO2(x,v)	PUTREG(GPIO2_BASE + (x), (v))
 
 int
-augpio_match(struct device *parent, struct cfdata *match, void *aux)
+augpio_match(device_t parent, struct cfdata *match, void *aux)
 {
 	struct aubus_attach_args *aa = (struct aubus_attach_args *)aux;
 
@@ -91,14 +91,15 @@ augpio_match(struct device *parent, stru
 }
 
 void
-augpio_attach(struct device *parent, struct device *self, void *aux)
+augpio_attach(device_t parent, device_t self, void *aux)
 {
 	int	pin;
 
-	struct augpio_softc *sc = (struct augpio_softc *)self;
+	struct augpio_softc *sc = device_private(self);
 	struct aubus_attach_args *aa = aux;
 	struct gpiobus_attach_args gba;
 
+	sc->sc_dev = self;
 	sc->sc_bst = aa->aa_st;
 	sc->sc_npins = aa->aa_addrs[1];
 	sc->sc_gc.gp_cookie = sc;
@@ -128,7 +129,7 @@ augpio_attach(struct device *parent, str
 		sc->sc_name = "secondary block";
 
 	} else {
-		printf(": unidentified block\n");
+		aprint_error(": unidentified block\n");
 		return;
 	}
 
@@ -145,8 +146,9 @@ augpio_attach(struct device *parent, str
 	gba.gba_pins = sc->sc_pins;
 	gba.gba_npins = sc->sc_npins;
 
-	printf(": Alchemy GPIO, %s\n", sc->sc_name);
-	config_found_ia(&sc->sc_dev, "gpiobus", &gba, gpiobus_print);
+	aprint_normal(": Alchemy GPIO, %s\n", sc->sc_name);
+	aprint_naive("\n");
+	config_found_ia(self, "gpiobus", &gba, gpiobus_print);
 }
 
 int
Index: src/sys/arch/mips/alchemy/dev/aupsc.c
diff -u src/sys/arch/mips/alchemy/dev/aupsc.c:1.6 src/sys/arch/mips/alchemy/dev/aupsc.c:1.7
--- src/sys/arch/mips/alchemy/dev/aupsc.c:1.6	Fri Jul  1 18:39:29 2011
+++ src/sys/arch/mips/alchemy/dev/aupsc.c	Tue Jan  3 07:36:02 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: aupsc.c,v 1.6 2011/07/01 18:39:29 dyoung Exp $ */
+/* $NetBSD: aupsc.c,v 1.7 2012/01/03 07:36:02 kiyohara Exp $ */
 
 /*-
  * Copyright (c) 2006 Shigeyuki Fukushima.
@@ -33,7 +33,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: aupsc.c,v 1.6 2011/07/01 18:39:29 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: aupsc.c,v 1.7 2012/01/03 07:36:02 kiyohara Exp $");
 
 #include "locators.h"
 
@@ -52,7 +52,7 @@ __KERNEL_RCSID(0, "$NetBSD: aupsc.c,v 1.
 #include <mips/alchemy/dev/ausmbus_pscreg.h>
 
 struct aupsc_softc {
-	struct device		sc_dev;
+	device_t		sc_dev;
 	bus_space_tag_t		sc_bust;
 	bus_space_handle_t	sc_bush;
 	int			sc_pscsel;
@@ -71,10 +71,9 @@ const struct aupsc_proto {
 	{ NULL, AUPSC_SEL_DISABLE }
 };
 
-static int	aupsc_match(struct device *, struct cfdata *, void *);
-static void	aupsc_attach(struct device *, struct device *, void *);
-static int	aupsc_submatch(struct device *, struct cfdata *, const int *,
-				void *);
+static int	aupsc_match(device_t, struct cfdata *, void *);
+static void	aupsc_attach(device_t, device_t, void *);
+static int	aupsc_submatch(device_t, struct cfdata *, const int *, void *);
 static int	aupsc_print(void *, const char *);
 
 static void	aupsc_enable(void *, int);
@@ -82,11 +81,11 @@ static void	aupsc_disable(void *);
 static void	aupsc_suspend(void *);
 
 
-CFATTACH_DECL(aupsc, sizeof(struct aupsc_softc),
+CFATTACH_DECL_NEW(aupsc, sizeof(struct aupsc_softc),
 	aupsc_match, aupsc_attach, NULL, NULL);
 
 static int
-aupsc_match(struct device *parent, struct cfdata *cf, void *aux)
+aupsc_match(device_t parent, struct cfdata *cf, void *aux)
 {
 	struct aubus_attach_args *aa = (struct aubus_attach_args *)aux;
 
@@ -97,19 +96,20 @@ aupsc_match(struct device *parent, struc
 }
 
 static void
-aupsc_attach(struct device *parent, struct device *self, void *aux)
+aupsc_attach(device_t parent, device_t self, void *aux)
 {
 	int i;
 	uint32_t rv;
-	struct aupsc_softc *sc = (struct aupsc_softc *)self;
+	struct aupsc_softc *sc = device_private(self);
 	struct aubus_attach_args *aa = (struct aubus_attach_args *)aux;
 	struct aupsc_attach_args pa;
 	struct aupsc_controller ctrl;
 
+	sc->sc_dev = self;
 	sc->sc_bust = aa->aa_st;
 	if (bus_space_map(sc->sc_bust, aa->aa_addr,
 			AUPSC_SIZE, 0, &sc->sc_bush) != 0) {
-		aprint_normal(": unable to map device registers\n");
+		aprint_error(": unable to map device registers\n");
 		return;
 	}
 
@@ -122,6 +122,7 @@ aupsc_attach(struct device *parent, stru
 		AUPSC_CTRL, AUPSC_CTRL_ENA(AUPSC_CTRL_DISABLE));
 
 	aprint_normal(": Alchemy PSC\n");
+	aprint_naive("\n");
 
 	ctrl.psc_bust = sc->sc_bust;
 	ctrl.psc_bush = sc->sc_bush;
@@ -154,8 +155,7 @@ aupsc_attach(struct device *parent, stru
 }
 
 static int
-aupsc_submatch(struct device *parent, struct cfdata *cf,
-	const int *ldesc, void *aux)
+aupsc_submatch(device_t parent, struct cfdata *cf, const int *ldesc, void *aux)
 {
 
 	return config_match(parent, cf, aux);
@@ -202,13 +202,13 @@ aupsc_enable(void *arg, int proto)
 		break;
 	default:
 		printf("%s: aupsc_enable: unsupported protocol.\n",
-			sc->sc_dev.dv_xname);
+			device_xname(sc->sc_dev));
 		return;
 	}
 
 	if (*(sc->sc_ctrl.psc_sel) != AUPSC_SEL_DISABLE) {
 		printf("%s: aupsc_enable: please disable first.\n",
-			sc->sc_dev.dv_xname);
+			device_xname(sc->sc_dev));
 		return;
 	}
 
Index: src/sys/arch/mips/alchemy/dev/auspi.c
diff -u src/sys/arch/mips/alchemy/dev/auspi.c:1.6 src/sys/arch/mips/alchemy/dev/auspi.c:1.7
--- src/sys/arch/mips/alchemy/dev/auspi.c:1.6	Sun Jul 10 23:13:23 2011
+++ src/sys/arch/mips/alchemy/dev/auspi.c	Tue Jan  3 07:36:02 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: auspi.c,v 1.6 2011/07/10 23:13:23 matt Exp $ */
+/* $NetBSD: auspi.c,v 1.7 2012/01/03 07:36:02 kiyohara Exp $ */
 
 /*-
  * Copyright (c) 2006 Urbana-Champaign Independent Media Center.
@@ -42,7 +42,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: auspi.c,v 1.6 2011/07/10 23:13:23 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: auspi.c,v 1.7 2012/01/03 07:36:02 kiyohara Exp $");
 
 #include "locators.h"
 
@@ -66,7 +66,7 @@ __KERNEL_RCSID(0, "$NetBSD: auspi.c,v 1.
 #include <dev/spi/spivar.h>
 
 struct auspi_softc {
-	struct device		sc_dev;
+	device_t		sc_dev;
 	struct aupsc_controller	sc_psc;		/* parent controller ops */
 	struct spi_controller	sc_spi;		/* SPI implementation ops */
 	struct auspi_machdep	sc_md;		/* board-specific support */
@@ -86,11 +86,11 @@ struct auspi_softc {
 
 #define	STATIC
 
-STATIC int auspi_match(struct device *, struct cfdata *, void *);
-STATIC void auspi_attach(struct device *, struct device *, void *);
+STATIC int auspi_match(device_t, struct cfdata *, void *);
+STATIC void auspi_attach(device_t, device_t, void *);
 STATIC int auspi_intr(void *);
 
-CFATTACH_DECL(auspi, sizeof(struct auspi_softc),
+CFATTACH_DECL_NEW(auspi, sizeof(struct auspi_softc),
     auspi_match, auspi_attach, NULL, NULL);
 
 /* SPI service routines */
@@ -109,7 +109,7 @@ STATIC void auspi_sched(struct auspi_sof
 	bus_space_write_4(sc->sc_psc.psc_bust, sc->sc_psc.psc_bush, x, v)
 
 int
-auspi_match(struct device *parent, struct cfdata *cf, void *aux)
+auspi_match(device_t parent, struct cfdata *cf, void *aux)
 {
 	struct aupsc_attach_args *aa = aux;
 
@@ -120,13 +120,15 @@ auspi_match(struct device *parent, struc
 }
 
 void
-auspi_attach(struct device *parent, struct device *self, void *aux)
+auspi_attach(device_t parent, device_t self, void *aux)
 {
 	struct auspi_softc *sc = device_private(self);
 	struct aupsc_attach_args *aa = aux;
 	struct spibus_attach_args sba;
 	const struct auspi_machdep *md;
 
+	sc->sc_dev = self;
+
 	if ((md = auspi_machdep(aa->aupsc_addr)) != NULL) {
 		sc->sc_md = *md;
 	}

Index: src/sys/arch/mips/alchemy/dev/aupci.c
diff -u src/sys/arch/mips/alchemy/dev/aupci.c:1.11 src/sys/arch/mips/alchemy/dev/aupci.c:1.12
--- src/sys/arch/mips/alchemy/dev/aupci.c:1.11	Fri Jul  1 18:39:29 2011
+++ src/sys/arch/mips/alchemy/dev/aupci.c	Tue Jan  3 07:36:02 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: aupci.c,v 1.11 2011/07/01 18:39:29 dyoung Exp $ */
+/* $NetBSD: aupci.c,v 1.12 2012/01/03 07:36:02 kiyohara Exp $ */
 
 /*-
  * Copyright (c) 2006 Itronix Inc.
@@ -35,7 +35,7 @@
 #include "pci.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: aupci.c,v 1.11 2011/07/01 18:39:29 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: aupci.c,v 1.12 2012/01/03 07:36:02 kiyohara Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -69,7 +69,7 @@ __KERNEL_RCSID(0, "$NetBSD: aupci.c,v 1.
 #include <mips/alchemy/dev/aupcivar.h>
 
 struct aupci_softc {
-	struct device			sc_dev;
+	device_t			sc_dev;
 	struct mips_pci_chipset		sc_pc;
 	struct mips_bus_space		sc_mem_space;
 	struct mips_bus_space		sc_io_space;
@@ -89,12 +89,11 @@ struct aupci_softc {
 	/* XXX: dma tag */
 };
 
-int		aupcimatch(struct device *, struct cfdata *, void *);
-void		aupciattach(struct device *, struct device *, void *);
+int		aupcimatch(device_t, struct cfdata *, void *);
+void		aupciattach(device_t, device_t, void *);
 
 #if NPCI > 0
-static void aupci_attach_hook(struct device *, struct device *,
-    struct pcibus_attach_args *);
+static void aupci_attach_hook(device_t, device_t, struct pcibus_attach_args *);
 static int aupci_bus_maxdevs(void *, int);
 static pcitag_t aupci_make_tag(void *, int, int, int);
 static void aupci_decompose_tag(void *, pcitag_t, int *, int *, int *);
@@ -116,7 +115,7 @@ static struct extent	*mem_ex = NULL;
 
 #endif	/* NPCI > 0 */
 
-CFATTACH_DECL(aupci, sizeof(struct aupci_softc),
+CFATTACH_DECL_NEW(aupci, sizeof(struct aupci_softc),
     aupcimatch, aupciattach, NULL, NULL);
 
 int aupci_found = 0;
@@ -132,7 +131,7 @@ int aupci_found = 0;
 #endif
 
 int
-aupcimatch(struct device *parent, struct cfdata *match, void *aux)
+aupcimatch(device_t parent, struct cfdata *match, void *aux)
 {
 	struct aubus_attach_args *aa = (struct aubus_attach_args *)aux;
 
@@ -146,9 +145,9 @@ aupcimatch(struct device *parent, struct
 }
 
 void
-aupciattach(struct device *parent, struct device *self, void *aux)
+aupciattach(device_t parent, device_t self, void *aux)
 {
-	struct aupci_softc		*sc = (struct aupci_softc *)self;
+	struct aupci_softc		*sc = device_private(self);
 	struct aubus_attach_args	*aa = (struct aubus_attach_args *)aux;
 	uint32_t			cfg;
 #if NPCI > 0
@@ -159,11 +158,11 @@ aupciattach(struct device *parent, struc
 	
 	aupci_found = 1;
 
+	sc->sc_dev = self;
 	sc->sc_bust = aa->aa_st;
 	if (bus_space_map(sc->sc_bust, aa->aa_addrs[0], 512, 0,
 		&sc->sc_bush) != 0) {
-		printf("\n%s: unable to map PCI registers\n",
-		    sc->sc_dev.dv_xname);
+		aprint_error(": unable to map PCI registers\n");
 		return;
 	}
 
@@ -204,13 +203,9 @@ aupciattach(struct device *parent, struc
 
 	cfg = bus_space_read_4(sc->sc_bust, sc->sc_bush, AUPCI_COMMAND_STATUS);
 
-	printf(": Alchemy Host-PCI Bridge");
-	if (cfg & PCI_STATUS_66MHZ_SUPPORT)
-		printf(", 66MHz");
-	else
-		printf(", 33MHz");
-
-	printf("\n");
+	aprint_normal(": Alchemy Host-PCI Bridge, %sMHz\n",
+	    (cfg & PCI_STATUS_66MHZ_SUPPORT) ? "66" : "33");
+	aprint_naive("\n");
 
 #if NPCI > 0
 	/*
@@ -292,7 +287,7 @@ aupciattach(struct device *parent, struc
 #if NPCI > 0
 
 void
-aupci_attach_hook(struct device *parent, struct device *self,
+aupci_attach_hook(device_t parent, device_t self,
     struct pcibus_attach_args *pba)
 {
 }

Index: src/sys/arch/mips/alchemy/dev/aupcmcia.c
diff -u src/sys/arch/mips/alchemy/dev/aupcmcia.c:1.7 src/sys/arch/mips/alchemy/dev/aupcmcia.c:1.8
--- src/sys/arch/mips/alchemy/dev/aupcmcia.c:1.7	Tue Jul 26 22:52:49 2011
+++ src/sys/arch/mips/alchemy/dev/aupcmcia.c	Tue Jan  3 07:36:02 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: aupcmcia.c,v 1.7 2011/07/26 22:52:49 dyoung Exp $ */
+/* $NetBSD: aupcmcia.c,v 1.8 2012/01/03 07:36:02 kiyohara Exp $ */
 
 /*-
  * Copyright (c) 2006 Itronix Inc.
@@ -35,7 +35,7 @@
 /* #include "pci.h" */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: aupcmcia.c,v 1.7 2011/07/26 22:52:49 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: aupcmcia.c,v 1.8 2012/01/03 07:36:02 kiyohara Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -107,8 +107,8 @@ static void aupcm_slot_enable(pcmcia_chi
 static void aupcm_slot_disable(pcmcia_chipset_handle_t);
 static void aupcm_slot_settype(pcmcia_chipset_handle_t, int);
 
-static int aupcm_match(struct device *, struct cfdata *, void *);
-static void aupcm_attach(struct device *, struct device *, void *);
+static int aupcm_match(device_t, struct cfdata *, void *);
+static void aupcm_attach(device_t, device_t, void *);
 
 static void aupcm_event_thread(void *);
 static int aupcm_card_intr(void *);
@@ -133,12 +133,12 @@ struct aupcm_slot {
 	struct mips_bus_space	as_memt;
 	void			*as_wins[AUPCMCIA_NWINS];
 
-	struct device		*as_pcmcia;
+	device_t		as_pcmcia;
 };
 
 /* this structure needs to be exposed... */
 struct aupcm_softc {
-	struct device		sc_dev;
+	device_t		sc_dev;
 	pcmcia_chipset_tag_t	sc_pct;
 
 	void			(*sc_slot_enable)(int);
@@ -175,11 +175,11 @@ static struct pcmcia_chip_functions aupc
 
 static	struct mips_bus_space	aupcm_memt;
 
-CFATTACH_DECL(aupcmcia, sizeof (struct aupcm_softc),
+CFATTACH_DECL_NEW(aupcmcia, sizeof (struct aupcm_softc),
     aupcm_match, aupcm_attach, NULL, NULL);
 
 int
-aupcm_match(struct device *parent, struct cfdata *cf, void *aux)
+aupcm_match(device_t parent, struct cfdata *cf, void *aux)
 {
 	struct aubus_attach_args	*aa = aux;
 	static int			found = 0;
@@ -196,14 +196,16 @@ aupcm_match(struct device *parent, struc
 }
 
 void
-aupcm_attach(struct device *parent, struct device *self, void *aux)
+aupcm_attach(device_t parent, device_t self, void *aux)
 {
 	/* struct aubus_attach_args	*aa = aux; */
-	struct aupcm_softc		*sc = (struct aupcm_softc *)self;
+	struct aupcm_softc		*sc = device_private(self);
 	static int			done = 0;
 	int				slot;
 	struct aupcmcia_machdep		*md;
 
+	sc->sc_dev = self;
+
 	/* initialize bus space */
 	if (done) {
 		/* there can be only one. */
@@ -221,8 +223,7 @@ aupcm_attach(struct device *parent, stru
 	    AU_HIMEM_SPACE_LITTLE_ENDIAN);
 
 	if ((md = aupcmcia_machdep()) == NULL) {
-		printf("\n%s:unable to get machdep structure\n",
-		    sc->sc_dev.dv_xname);
+		aprint_error(": unable to get machdep structure\n");
 		return;
 	}
 
@@ -231,7 +232,8 @@ aupcm_attach(struct device *parent, stru
 	sc->sc_slot_disable = md->am_slot_disable;
 	sc->sc_slot_status = md->am_slot_status;
 
-	printf(": Alchemy PCMCIA, %d slots\n", sc->sc_nslots);
+	aprint_normal(": Alchemy PCMCIA, %d slots\n", sc->sc_nslots);
+	aprint_naive("\n");
 
 	sc->sc_pct = (pcmcia_chipset_tag_t)&aupcm_functions;
 
@@ -268,7 +270,7 @@ aupcm_attach(struct device *parent, stru
 		paa.pct = sc->sc_pct;
 		paa.pch = (pcmcia_chipset_handle_t)sp;
 
-		sp->as_pcmcia = config_found(&sc->sc_dev, &paa, aupcm_print);
+		sp->as_pcmcia = config_found(self, &paa, aupcm_print);
 
 		/* if no pcmcia, make sure slot is powered down */
 		if (sp->as_pcmcia == NULL) {
@@ -287,9 +289,9 @@ aupcm_attach(struct device *parent, stru
 	 * for now.  Start by initializing it now.
 	 */
 	if (kthread_create(PRI_NONE, 0, NULL, aupcm_event_thread, sc,
-	    &sc->sc_thread, "%s", sc->sc_dev.dv_xname) != 0)
+	    &sc->sc_thread, "%s", device_xname(sc->sc_dev)) != 0)
 		panic("%s: unable to create event kthread",
-		    sc->sc_dev.dv_xname);
+		    device_xname(sc->sc_dev));
 }
 
 int

Index: src/sys/arch/mips/alchemy/dev/aupscvar.h
diff -u src/sys/arch/mips/alchemy/dev/aupscvar.h:1.3 src/sys/arch/mips/alchemy/dev/aupscvar.h:1.4
--- src/sys/arch/mips/alchemy/dev/aupscvar.h:1.3	Mon Oct  2 07:32:16 2006
+++ src/sys/arch/mips/alchemy/dev/aupscvar.h	Tue Jan  3 07:36:02 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: aupscvar.h,v 1.3 2006/10/02 07:32:16 gdamore Exp $ */
+/* $NetBSD: aupscvar.h,v 1.4 2012/01/03 07:36:02 kiyohara Exp $ */
 
 /*-
  * Copyright (c) 2006 Shigeyuki Fukushima.
@@ -52,7 +52,7 @@ struct aupsc_attach_args {
 };
 
 struct aupsc_protocol_device {
-	struct device		sc_dev;
+	device_t		sc_dev;
 	struct aupsc_controller	sc_ctrl;
 };
 

Index: src/sys/arch/mips/alchemy/dev/aurtc.c
diff -u src/sys/arch/mips/alchemy/dev/aurtc.c:1.13 src/sys/arch/mips/alchemy/dev/aurtc.c:1.14
--- src/sys/arch/mips/alchemy/dev/aurtc.c:1.13	Fri Jul  1 18:39:29 2011
+++ src/sys/arch/mips/alchemy/dev/aurtc.c	Tue Jan  3 07:36:02 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: aurtc.c,v 1.13 2011/07/01 18:39:29 dyoung Exp $ */
+/* $NetBSD: aurtc.c,v 1.14 2012/01/03 07:36:02 kiyohara Exp $ */
 
 /*-
  * Copyright (c) 2006 Itronix Inc.
@@ -68,7 +68,7 @@
 
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: aurtc.c,v 1.13 2011/07/01 18:39:29 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: aurtc.c,v 1.14 2012/01/03 07:36:02 kiyohara Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -89,22 +89,22 @@ __KERNEL_RCSID(0, "$NetBSD: aurtc.c,v 1.
 #define	PUTREG(x,v)	(REGVAL(x) = (v))
 
 struct aurtc_softc {
-	struct device		sc_dev;
+	device_t		sc_dev;
 	struct todr_chip_handle	sc_tch;
 	void			*sc_shutdownhook;
 };
 
-static int	aurtc_match(struct device *, struct cfdata *, void *);
-static void	aurtc_attach(struct device *, struct device *, void *);
+static int	aurtc_match(device_t, struct cfdata *, void *);
+static void	aurtc_attach(device_t, device_t, void *);
 static int	aurtc_gettime(todr_chip_handle_t, struct timeval *);
 static int	aurtc_settime(todr_chip_handle_t, struct timeval *);
 static void	aurtc_shutdown(void *);
 
-CFATTACH_DECL(aurtc, sizeof (struct aurtc_softc),
+CFATTACH_DECL_NEW(aurtc, sizeof (struct aurtc_softc),
     aurtc_match, aurtc_attach, NULL, NULL);
 
 int
-aurtc_match(struct device *parent, struct cfdata *match, void *aux)
+aurtc_match(device_t parent, struct cfdata *match, void *aux)
 {
 	struct aubus_attach_args *aa = aux;
 
@@ -115,12 +115,13 @@ aurtc_match(struct device *parent, struc
 }
 
 void
-aurtc_attach(struct device *parent, struct device *self, void *aux)
+aurtc_attach(device_t parent, device_t self, void *aux)
 {
-	struct aurtc_softc *sc = (struct aurtc_softc *)self;
+	struct aurtc_softc *sc = device_private(self);
 
 	printf(": Au1X00 programmable clock\n");
 	
+	sc->sc_dev = self;
 	sc->sc_tch.cookie = sc;
 	sc->sc_tch.bus_cookie = NULL;
 	sc->sc_tch.todr_gettime = aurtc_gettime;

Index: src/sys/arch/mips/alchemy/dev/ausmbus_psc.c
diff -u src/sys/arch/mips/alchemy/dev/ausmbus_psc.c:1.10 src/sys/arch/mips/alchemy/dev/ausmbus_psc.c:1.11
--- src/sys/arch/mips/alchemy/dev/ausmbus_psc.c:1.10	Fri Jul  1 18:39:29 2011
+++ src/sys/arch/mips/alchemy/dev/ausmbus_psc.c	Tue Jan  3 07:36:02 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: ausmbus_psc.c,v 1.10 2011/07/01 18:39:29 dyoung Exp $ */
+/* $NetBSD: ausmbus_psc.c,v 1.11 2012/01/03 07:36:02 kiyohara Exp $ */
 
 /*-
  * Copyright (c) 2006 Shigeyuki Fukushima.
@@ -33,7 +33,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ausmbus_psc.c,v 1.10 2011/07/01 18:39:29 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ausmbus_psc.c,v 1.11 2012/01/03 07:36:02 kiyohara Exp $");
 
 #include "locators.h"
 
@@ -53,7 +53,7 @@ __KERNEL_RCSID(0, "$NetBSD: ausmbus_psc.
 #include <dev/i2c/i2c_bitbang.h>
 
 struct ausmbus_softc {
-	struct device			sc_dev;
+	device_t			sc_dev;
 
 	/* protocol comoon fields */
 	struct aupsc_controller		sc_ctrl;
@@ -71,10 +71,10 @@ struct ausmbus_softc {
 		val); \
 	delay(100);
 
-static int	ausmbus_match(struct device *, struct cfdata *, void *);
-static void	ausmbus_attach(struct device *, struct device *, void *);
+static int	ausmbus_match(device_t, struct cfdata *, void *);
+static void	ausmbus_attach(device_t, device_t, void *);
 
-CFATTACH_DECL(ausmbus, sizeof(struct ausmbus_softc),
+CFATTACH_DECL_NEW(ausmbus, sizeof(struct ausmbus_softc),
 	ausmbus_match, ausmbus_attach, NULL, NULL);
 
 /* fuctions for i2c_controller */
@@ -101,7 +101,7 @@ static int	ausmbus_write_byte(void *arg,
 
 
 static int
-ausmbus_match(struct device *parent, struct cfdata *cf, void *aux)
+ausmbus_match(device_t parent, struct cfdata *cf, void *aux)
 {
 	struct aupsc_attach_args *aa = (struct aupsc_attach_args *)aux;
 
@@ -112,14 +112,16 @@ ausmbus_match(struct device *parent, str
 }
 
 static void
-ausmbus_attach(struct device *parent, struct device *self, void *aux)
+ausmbus_attach(device_t parent, device_t self, void *aux)
 {
-	struct ausmbus_softc *sc = (struct ausmbus_softc *)self;
+	struct ausmbus_softc *sc = device_private(self);
 	struct aupsc_attach_args *aa = (struct aupsc_attach_args *)aux;
 	struct i2cbus_attach_args iba;
 
 	aprint_normal(": Alchemy PSC SMBus protocol\n");
 
+	sc->sc_dev = self;
+
 	/* Initialize PSC */
 	sc->sc_ctrl = aa->aupsc_ctrl;
 
@@ -136,7 +138,7 @@ ausmbus_attach(struct device *parent, st
 	sc->sc_smbus_timeout = 10;
 
 	iba.iba_tag = &sc->sc_i2c;
-	(void) config_found_ia(&sc->sc_dev, "i2cbus", &iba, iicbus_print);
+	(void) config_found_ia(self, "i2cbus", &iba, iicbus_print);
 }
 
 static int

Index: src/sys/arch/mips/alchemy/dev/if_aumac.c
diff -u src/sys/arch/mips/alchemy/dev/if_aumac.c:1.32 src/sys/arch/mips/alchemy/dev/if_aumac.c:1.33
--- src/sys/arch/mips/alchemy/dev/if_aumac.c:1.32	Sat Nov 19 22:51:20 2011
+++ src/sys/arch/mips/alchemy/dev/if_aumac.c	Tue Jan  3 07:36:02 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: if_aumac.c,v 1.32 2011/11/19 22:51:20 tls Exp $ */
+/* $NetBSD: if_aumac.c,v 1.33 2012/01/03 07:36:02 kiyohara Exp $ */
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -46,7 +46,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_aumac.c,v 1.32 2011/11/19 22:51:20 tls Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_aumac.c,v 1.33 2012/01/03 07:36:02 kiyohara Exp $");
 
 #include "rnd.h"
 
@@ -117,7 +117,7 @@ struct aumac_buf {
  * Software state per device.
  */
 struct aumac_softc {
-	struct device sc_dev;		/* generic device information */
+	device_t sc_dev;		/* generic device information */
 	bus_space_tag_t sc_st;		/* bus space tag */
 	bus_space_handle_t sc_mac_sh;	/* MAC space handle */
 	bus_space_handle_t sc_macen_sh;	/* MAC enable space handle */
@@ -191,21 +191,21 @@ static int	aumac_intr(void *);
 static int	aumac_txintr(struct aumac_softc *);
 static int	aumac_rxintr(struct aumac_softc *);
 
-static int	aumac_mii_readreg(struct device *, int, int);
-static void	aumac_mii_writereg(struct device *, int, int, int);
-static void	aumac_mii_statchg(struct device *);
+static int	aumac_mii_readreg(device_t, int, int);
+static void	aumac_mii_writereg(device_t, int, int, int);
+static void	aumac_mii_statchg(device_t);
 static int	aumac_mii_wait(struct aumac_softc *, const char *);
 
-static int	aumac_match(struct device *, struct cfdata *, void *);
-static void	aumac_attach(struct device *, struct device *, void *);
+static int	aumac_match(device_t, struct cfdata *, void *);
+static void	aumac_attach(device_t, device_t, void *);
 
 int	aumac_copy_small = 0;
 
-CFATTACH_DECL(aumac, sizeof(struct aumac_softc),
+CFATTACH_DECL_NEW(aumac, sizeof(struct aumac_softc),
     aumac_match, aumac_attach, NULL, NULL);
 
 static int
-aumac_match(struct device *parent, struct cfdata *cf, void *aux)
+aumac_match(device_t parent, struct cfdata *cf, void *aux)
 {
 	struct aubus_attach_args *aa = aux;
 
@@ -216,11 +216,11 @@ aumac_match(struct device *parent, struc
 }
 
 static void
-aumac_attach(struct device *parent, struct device *self, void *aux)
+aumac_attach(device_t parent, device_t self, void *aux)
 {
 	const uint8_t *enaddr;
 	prop_data_t ea;
-	struct aumac_softc *sc = (void *) self;
+	struct aumac_softc *sc = device_private(self);
 	struct aubus_attach_args *aa = aux;
 	struct ifnet *ifp = &sc->sc_ethercom.ec_if;
 	struct pglist pglist;
@@ -230,41 +230,38 @@ aumac_attach(struct device *parent, stru
 
 	callout_init(&sc->sc_tick_ch, 0);
 
-	printf(": Au1X00 10/100 Ethernet\n");
+	aprint_normal(": Au1X00 10/100 Ethernet\n");
+	aprint_naive("\n");
 
+	sc->sc_dev = self;
 	sc->sc_st = aa->aa_st;
 
 	/* Get the MAC address. */
-	ea = prop_dictionary_get(device_properties(&sc->sc_dev), "mac-address");
+	ea = prop_dictionary_get(device_properties(self), "mac-address");
 	if (ea == NULL) {
-		printf("%s: unable to get mac-addr property\n",
-		    sc->sc_dev.dv_xname);
+		aprint_error_dev(self, "unable to get mac-addr property\n");
 		return;
 	}
 	KASSERT(prop_object_type(ea) == PROP_TYPE_DATA);
 	KASSERT(prop_data_size(ea) == ETHER_ADDR_LEN);
 	enaddr = prop_data_data_nocopy(ea);
 
-	printf("%s: Ethernet address %s\n", sc->sc_dev.dv_xname,
-	    ether_sprintf(enaddr));
+	aprint_normal_dev(self, "Ethernet address %s\n", ether_sprintf(enaddr));
 
 	/* Map the device. */
 	if (bus_space_map(sc->sc_st, aa->aa_addrs[AA_MAC_BASE],
 	    MACx_SIZE, 0, &sc->sc_mac_sh) != 0) {
-		printf("%s: unable to map MAC registers\n",
-		    sc->sc_dev.dv_xname);
+		aprint_error_dev(self, "unable to map MAC registers\n");
 		return;
 	}
 	if (bus_space_map(sc->sc_st, aa->aa_addrs[AA_MAC_ENABLE],
 	    MACENx_SIZE, 0, &sc->sc_macen_sh) != 0) {
-		printf("%s: unable to map MACEN registers\n",
-		    sc->sc_dev.dv_xname);
+		aprint_error_dev(self, "unable to map MACEN registers\n");
 		return;
 	}
 	if (bus_space_map(sc->sc_st, aa->aa_addrs[AA_MAC_DMA_BASE],
 	    MACx_DMA_SIZE, 0, &sc->sc_dma_sh) != 0) {
-		printf("%s: unable to map MACDMA registers\n",
-		    sc->sc_dev.dv_xname);
+		aprint_error_dev(self, "unable to map MACDMA registers\n");
 		return;
 	}
 
@@ -275,8 +272,8 @@ aumac_attach(struct device *parent, stru
 	sc->sc_ih = au_intr_establish(aa->aa_irq[0], 1, IPL_NET, IST_LEVEL,
 	    aumac_intr, sc);
 	if (sc->sc_ih == NULL) {
-		printf("%s: unable to register interrupt handler\n",
-		    sc->sc_dev.dv_xname);
+		aprint_error_dev(self,
+		    "unable to register interrupt handler\n");
 		return;
 	}
 
@@ -321,7 +318,7 @@ aumac_attach(struct device *parent, stru
 	ifmedia_init(&sc->sc_mii.mii_media, 0, ether_mediachange,
 	    ether_mediastatus);
 
-	mii_attach(&sc->sc_dev, &sc->sc_mii, 0xffffffff, MII_PHY_ANY,
+	mii_attach(self, &sc->sc_mii, 0xffffffff, MII_PHY_ANY,
 	    MII_OFFSET_ANY, 0);
 
 	if (LIST_FIRST(&sc->sc_mii.mii_phys) == NULL) {
@@ -330,7 +327,7 @@ aumac_attach(struct device *parent, stru
 	} else
 		ifmedia_set(&sc->sc_mii.mii_media, IFM_ETHER|IFM_AUTO);
 
-	strcpy(ifp->if_xname, sc->sc_dev.dv_xname);
+	strcpy(ifp->if_xname, device_xname(self));
 	ifp->if_softc = sc;
 	ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
 	ifp->if_ioctl = aumac_ioctl;
@@ -345,26 +342,25 @@ aumac_attach(struct device *parent, stru
 	ether_ifattach(ifp, enaddr);
 
 #if NRND > 0
-	rnd_attach_source(&sc->rnd_source, sc->sc_dev.dv_xname,
-	    RND_TYPE_NET, 0);
+	rnd_attach_source(&sc->rnd_source, device_xname(self), RND_TYPE_NET, 0);
 #endif
 
 #ifdef AUMAC_EVENT_COUNTERS
 	evcnt_attach_dynamic(&sc->sc_ev_txstall, EVCNT_TYPE_MISC,
-	    NULL, sc->sc_dev.dv_xname, "txstall");
+	    NULL, device_xname(self), "txstall");
 	evcnt_attach_dynamic(&sc->sc_ev_rxstall, EVCNT_TYPE_MISC,
-	    NULL, sc->sc_dev.dv_xname, "rxstall");
+	    NULL, device_xname(self), "rxstall");
 	evcnt_attach_dynamic(&sc->sc_ev_txintr, EVCNT_TYPE_MISC,
-	    NULL, sc->sc_dev.dv_xname, "txintr");
+	    NULL, device_xname(self), "txintr");
 	evcnt_attach_dynamic(&sc->sc_ev_rxintr, EVCNT_TYPE_MISC,
-	    NULL, sc->sc_dev.dv_xname, "rxintr");
+	    NULL, device_xname(self), "rxintr");
 #endif
 
 	/* Make sure the interface is shutdown during reboot. */
 	sc->sc_sdhook = shutdownhook_establish(aumac_shutdown, sc);
 	if (sc->sc_sdhook == NULL)
-		printf("%s: WARNING: unable to establish shutdown hook\n",
-		    sc->sc_dev.dv_xname);
+		aprint_error_dev(self,
+		    "WARNING: unable to establish shutdown hook\n");
 	return;
 }
 
@@ -475,7 +471,7 @@ aumac_watchdog(struct ifnet *ifp)
 {
 	struct aumac_softc *sc = ifp->if_softc;
 
-	printf("%s: device timeout\n", sc->sc_dev.dv_xname);
+	printf("%s: device timeout\n", device_xname(sc->sc_dev));
 	(void) aumac_init(ifp);
 
 	/* Try to get more packets going. */
@@ -631,7 +627,7 @@ aumac_rxintr(struct aumac_softc *sc)
 #define PRINTERR(str)							\
 	do {								\
 		error++;						\
-		printf("%s: %s\n", sc->sc_dev.dv_xname, str);		\
+		printf("%s: %s\n", device_xname(sc->sc_dev), str);	\
 	} while (0)
 
 		if (stat & RX_STAT_ERRS) {
@@ -702,14 +698,14 @@ aumac_rxintr(struct aumac_softc *sc)
 		MGETHDR(m, M_DONTWAIT, MT_DATA);
 		if (m == NULL) {
 			printf("%s: unable to allocate Rx mbuf\n",
-			    sc->sc_dev.dv_xname);
+			    device_xname(sc->sc_dev));
 			goto dropit;
 		}
 		if (len > MHLEN - 2) {
 			MCLGET(m, M_DONTWAIT);
 			if ((m->m_flags & M_EXT) == 0) {
 				printf("%s: unable to allocate Rx cluster\n",
-				    sc->sc_dev.dv_xname);
+				    device_xname(sc->sc_dev));
 				m_freem(m);
 				goto dropit;
 			}
@@ -822,7 +818,7 @@ aumac_init(struct ifnet *ifp)
 
 out:
 	if (error)
-		printf("%s: interface not running\n", sc->sc_dev.dv_xname);
+		printf("%s: interface not running\n", device_xname(sc->sc_dev));
 	return (error);
 }
 
@@ -990,7 +986,7 @@ aumac_mii_wait(struct aumac_softc *sc, c
 		delay(10);
 	}
 
-	printf("%s: MII failed to %s\n", sc->sc_dev.dv_xname, msg);
+	printf("%s: MII failed to %s\n", device_xname(sc->sc_dev), msg);
 	return (1);
 }
 
@@ -1000,9 +996,9 @@ aumac_mii_wait(struct aumac_softc *sc, c
  *	Read a PHY register on the MII.
  */
 static int
-aumac_mii_readreg(struct device *self, int phy, int reg)
+aumac_mii_readreg(device_t self, int phy, int reg)
 {
-	struct aumac_softc *sc = (void *) self;
+	struct aumac_softc *sc = device_private(self);
 
 	if (aumac_mii_wait(sc, "become ready"))
 		return (0);
@@ -1023,9 +1019,9 @@ aumac_mii_readreg(struct device *self, i
  *	Write a PHY register on the MII.
  */
 static void
-aumac_mii_writereg(struct device *self, int phy, int reg, int val)
+aumac_mii_writereg(device_t self, int phy, int reg, int val)
 {
-	struct aumac_softc *sc = (void *) self;
+	struct aumac_softc *sc = device_private(self);
 
 	if (aumac_mii_wait(sc, "become ready"))
 		return;
@@ -1043,9 +1039,9 @@ aumac_mii_writereg(struct device *self, 
  *	Callback from MII layer when media changes.
  */
 static void
-aumac_mii_statchg(struct device *self)
+aumac_mii_statchg(device_t self)
 {
-	struct aumac_softc *sc = (void *) self;
+	struct aumac_softc *sc = device_private(self);
 
 	if ((sc->sc_mii.mii_media_active & IFM_FDX) != 0)
 		sc->sc_control |= CONTROL_F;

Reply via email to