Module Name:    src
Committed By:   matt
Date:           Tue Jan 12 18:21:17 UTC 2010

Modified Files:
        src/sys/arch/sbmips/sbmips [matt-nb5-mips64]: cpu.c rtc.c zbbus.c

Log Message:
Change some devices to use CFATTACH_DECL_NEW/device_t/cfdata_t/device_*


To generate a diff of this commit:
cvs rdiff -u -r1.18.16.1 -r1.18.16.2 src/sys/arch/sbmips/sbmips/cpu.c
cvs rdiff -u -r1.16.38.1 -r1.16.38.2 src/sys/arch/sbmips/sbmips/rtc.c
cvs rdiff -u -r1.11 -r1.11.96.1 src/sys/arch/sbmips/sbmips/zbbus.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/sbmips/sbmips/cpu.c
diff -u src/sys/arch/sbmips/sbmips/cpu.c:1.18.16.1 src/sys/arch/sbmips/sbmips/cpu.c:1.18.16.2
--- src/sys/arch/sbmips/sbmips/cpu.c:1.18.16.1	Mon Nov 23 18:28:47 2009
+++ src/sys/arch/sbmips/sbmips/cpu.c	Tue Jan 12 18:21:17 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.c,v 1.18.16.1 2009/11/23 18:28:47 matt Exp $ */
+/* $NetBSD: cpu.c,v 1.18.16.2 2010/01/12 18:21:17 matt Exp $ */
 
 /*
  * Copyright 2000, 2001
@@ -33,7 +33,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.18.16.1 2009/11/23 18:28:47 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.18.16.2 2010/01/12 18:21:17 matt Exp $");
 
 #include "opt_multiprocessor.h"
 
@@ -55,16 +55,16 @@
 
 #define	READ_REG(rp)		(mips3_ld((volatile uint64_t *)(rp)))
 
-static int	cpu_match(struct device *, struct cfdata *, void *);
-static void	cpu_attach(struct device *, struct device *, void *);
+static int	cpu_match(device_t, cfdata_t, void *);
+static void	cpu_attach(device_t, device_t, void *);
 
-CFATTACH_DECL(cpu, sizeof(struct device),
+CFATTACH_DECL_NEW(cpu, 0,
     cpu_match, cpu_attach, NULL, NULL);
 
 static int found = 0;
 
 static int
-cpu_match(struct device *parent, struct cfdata *match, void *aux)
+cpu_match(device_t parent, cfdata_t match, void *aux)
 {
 	struct zbbus_attach_args *zap = aux;
 	int part;
@@ -81,8 +81,10 @@
 }
 
 static void
-cpu_attach(struct device *parent, struct device *self, void *aux)
+cpu_attach(device_t parent, device_t self, void *aux)
 {
+	struct cpu_info * const ci = curcpu();
+	const char * const xname = device_xname(self);
 	int plldiv;
 	uint32_t config;
 
@@ -110,36 +112,36 @@
 	 */
 	plldiv = G_SYS_PLL_DIV(READ_REG(MIPS_PHYS_TO_KSEG1(A_SCD_SYSTEM_CFG)));
 	if (plldiv == 0) {
-		printf("PLL_DIV of zero found, assuming 6 (300MHz)\n");
+		aprint_normal(": PLL_DIV of zero found, assuming 6 (300MHz)\n");
 		plldiv = 6;
 
-		printf("%s", self->dv_xname);
+		aprint_normal("%s", xname);
 	}
 
-	curcpu()->ci_cpu_freq = 50000000 * plldiv;
+	ci->ci_cpu_freq = 50000000 * plldiv;
 	/* Compute the delay divisor. */
-	curcpu()->ci_divisor_delay = (curcpu()->ci_cpu_freq + 500000) / 1000000;
+	ci->ci_divisor_delay = (ci->ci_cpu_freq + 500000) / 1000000;
 	/* Compute clock cycles per hz */
-	curcpu()->ci_cycles_per_hz = (curcpu()->ci_cpu_freq + hz / 2 ) / hz;
+	ci->ci_cycles_per_hz = (ci->ci_cpu_freq + hz / 2 ) / hz;
 
-	printf(": %lu.%02luMHz (hz cycles = %lu, delay divisor = %lu)\n",
-	    curcpu()->ci_cpu_freq / 1000000,
-	    (curcpu()->ci_cpu_freq % 1000000) / 10000,
-	    curcpu()->ci_cycles_per_hz, curcpu()->ci_divisor_delay);
+	aprint_normal(": %lu.%02luMHz (hz cycles = %lu, delay divisor = %lu)\n",
+	    ci->ci_cpu_freq / 1000000,
+	    (ci->ci_cpu_freq % 1000000) / 10000,
+	    ci->ci_cycles_per_hz, ci->ci_divisor_delay);
 
 	/*
 	 * If we're the primary CPU, no more work to do; we're already
 	 * running!
 	 */
 	if (found == 1) {
-		printf("%s: ", self->dv_xname);
+		aprint_normal("%s: ", xname);
 		cpu_identify();
 	} else {
 #if defined(MULTIPROCESSOR)
 # error!
 #else
 		printf("%s: processor off-line; multiprocessor support "
-		    "not present in kernel\n", /* sc->sc_dev. */self->dv_xname);
+		    "not present in kernel\n", xname);
 #endif
 	}
 }

Index: src/sys/arch/sbmips/sbmips/rtc.c
diff -u src/sys/arch/sbmips/sbmips/rtc.c:1.16.38.1 src/sys/arch/sbmips/sbmips/rtc.c:1.16.38.2
--- src/sys/arch/sbmips/sbmips/rtc.c:1.16.38.1	Mon Nov 23 18:28:47 2009
+++ src/sys/arch/sbmips/sbmips/rtc.c	Tue Jan 12 18:21:17 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: rtc.c,v 1.16.38.1 2009/11/23 18:28:47 matt Exp $ */
+/* $NetBSD: rtc.c,v 1.16.38.2 2010/01/12 18:21:17 matt Exp $ */
 
 /*
  * Copyright 2002 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rtc.c,v 1.16.38.1 2009/11/23 18:28:47 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rtc.c,v 1.16.38.2 2010/01/12 18:21:17 matt Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -56,7 +56,7 @@
 #include <dev/smbus/x1241reg.h>
 
 struct rtc_softc {
-	struct device		sc_dev;
+	device_t		sc_dev;
 	int			sc_smbus_chan;
 	int			sc_smbus_addr;
 	int			sc_type;
@@ -67,13 +67,13 @@
 #define	SMB_1BYTE_ADDR	1
 #define	SMB_2BYTE_ADDR	2
 
-static int xirtc_match(struct device *, struct cfdata *, void *);
-static void xirtc_attach(struct device *, struct device *, void *);
+static int xirtc_match(device_t, cfdata_t , void *);
+static void xirtc_attach(device_t, device_t, void *);
 static int xirtc_gettime(todr_chip_handle_t, struct clock_ymdhms *);
 static int xirtc_settime(todr_chip_handle_t, struct clock_ymdhms *);
 
-static int strtc_match(struct device *, struct cfdata *, void *);
-static void strtc_attach(struct device *, struct device *, void *);
+static int strtc_match(device_t, cfdata_t , void *);
+static void strtc_attach(device_t, device_t, void *);
 static int strtc_gettime(todr_chip_handle_t, struct clock_ymdhms *);
 static int strtc_settime(todr_chip_handle_t, struct clock_ymdhms *);
 
@@ -90,10 +90,10 @@
 	time_readrtc((sc)->sc_smbus_chan, (sc)->sc_smbus_addr, (dev), (sc)->sc_type)
 
 
-CFATTACH_DECL(xirtc, sizeof(struct rtc_softc),
+CFATTACH_DECL_NEW(xirtc, sizeof(struct rtc_softc),
     xirtc_match, xirtc_attach, NULL, NULL);
 
-CFATTACH_DECL(m41t81rtc, sizeof(struct rtc_softc),
+CFATTACH_DECL_NEW(m41t81rtc, sizeof(struct rtc_softc),
     strtc_match, strtc_attach, NULL, NULL);
 
 static int rtcfound = 0;
@@ -103,7 +103,7 @@
  * Xicor X1241 RTC support.
  */
 static int
-xirtc_match(struct device *parent, struct cfdata *cf, void *aux)
+xirtc_match(device_t parent, cfdata_t cf, void *aux)
 {
 	struct smbus_attach_args *sa = aux;
 	int ret;
@@ -122,14 +122,15 @@
 }
 
 static void
-xirtc_attach(struct device *parent, struct device *self, void *aux)
+xirtc_attach(device_t parent, device_t self, void *aux)
 {
 	struct smbus_attach_args *sa = aux;
-	struct rtc_softc *sc = (void *)self;
+	struct rtc_softc *sc = device_private(self);
 
 	rtcfound = 1;
 	the_rtc = sc;
 
+	sc->sc_dev = self;
 	sc->sc_smbus_chan = sa->sa_interface;
 	sc->sc_smbus_addr = sa->sa_device;
 	sc->sc_type = SMB_2BYTE_ADDR;	/* Two-byte register addresses on the Xicor */
@@ -142,7 +143,7 @@
 
 	todr_attach(&sc->sc_ct);
 
-	printf("\n");
+	aprint_normal("\n");
 	rtc_cal_timer();	/* XXX */
 }
 
@@ -202,7 +203,7 @@
 
 	if (status & X1241REG_SR_RTCF) {
 		printf("%s: battery has failed, clock setting is not accurate\n",
-		    sc->sc_dev.dv_xname);
+		    device_xname(sc->sc_dev));
 		return (EIO);
 	}
 
@@ -213,7 +214,7 @@
  * ST M41T81 RTC support.
  */
 static int
-strtc_match(struct device *parent, struct cfdata *cf, void *aux)
+strtc_match(device_t parent, cfdata_t cf, void *aux)
 {
 	struct smbus_attach_args *sa = aux;
 	int ret;
@@ -232,14 +233,15 @@
 }
 
 static void
-strtc_attach(struct device *parent, struct device *self, void *aux)
+strtc_attach(device_t parent, device_t self, void *aux)
 {
 	struct smbus_attach_args *sa = aux;
-	struct rtc_softc *sc = (void *)self;
+	struct rtc_softc *sc = device_private(self);
 
 	rtcfound = 1;
 	the_rtc = sc;
 
+	sc->sc_dev = self;
 	sc->sc_smbus_chan = sa->sa_interface;
 	sc->sc_smbus_addr = sa->sa_device;
 	sc->sc_type = SMB_1BYTE_ADDR;	/* One-byte register addresses on the ST */
@@ -251,7 +253,7 @@
 
 	todr_attach(&sc->sc_ct);
 
-	printf("\n");
+	aprint_normal("\n");
 	rtc_cal_timer();	/* XXX */
 }
 
@@ -324,7 +326,7 @@
 	}
 return;	/* XXX XXX */
 
-	printf("%s: calibrating CPU clock", the_rtc->sc_dev.dv_xname);
+	printf("%s: calibrating CPU clock", device_xname(the_rtc->sc_dev));
 
 	/*
 	 * Run the loop an extra time to wait for the second to tick over
@@ -373,7 +375,7 @@
 	curcpu()->ci_cycles_per_hz = curcpu()->ci_cpu_freq / hz;
 
 	printf("%s: timer calibration: %lu cycles/sec [(%u, %u)]\n",
-	    the_rtc->sc_dev.dv_xname, curcpu()->ci_cpu_freq,
+	    device_xname(the_rtc->sc_dev), curcpu()->ci_cpu_freq,
 	    ctrdiff[1], ctrdiff[2]);
 }
 #undef RTC_SECONDS

Index: src/sys/arch/sbmips/sbmips/zbbus.c
diff -u src/sys/arch/sbmips/sbmips/zbbus.c:1.11 src/sys/arch/sbmips/sbmips/zbbus.c:1.11.96.1
--- src/sys/arch/sbmips/sbmips/zbbus.c:1.11	Sun Dec 11 12:18:51 2005
+++ src/sys/arch/sbmips/sbmips/zbbus.c	Tue Jan 12 18:21:17 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: zbbus.c,v 1.11 2005/12/11 12:18:51 christos Exp $ */
+/* $NetBSD: zbbus.c,v 1.11.96.1 2010/01/12 18:21:17 matt Exp $ */
 
 /*
  * Copyright 2000, 2001
@@ -33,7 +33,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: zbbus.c,v 1.11 2005/12/11 12:18:51 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: zbbus.c,v 1.11.96.1 2010/01/12 18:21:17 matt Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -43,15 +43,14 @@
 
 #include "locators.h"
 
-static int	zbbus_match(struct device *, struct cfdata *, void *);
-static void	zbbus_attach(struct device *, struct device *, void *);
+static int	zbbus_match(device_t, cfdata_t, void *);
+static void	zbbus_attach(device_t, device_t, void *);
 
-CFATTACH_DECL(zbbus, sizeof(struct device),
+CFATTACH_DECL_NEW(zbbus, 0,
     zbbus_match, zbbus_attach, NULL, NULL);
 
 static int	zbbus_print(void *, const char *);
-static int	zbbus_submatch(struct device *, struct cfdata *,
-			       const int *, void *);
+static int	zbbus_submatch(device_t, cfdata_t, const int *, void *);
 static const char *zbbus_entity_type_name(enum zbbus_entity_type type);
 
 static int	zbbus_attached;
@@ -67,7 +66,7 @@
     sizeof sb1250_zbbus_devs / sizeof sb1250_zbbus_devs[0];
 
 static int
-zbbus_match(struct device *parent, struct cfdata *match, void *aux)
+zbbus_match(device_t parent, cfdata_t match, void *aux)
 {
 
 	if (zbbus_attached)
@@ -76,7 +75,7 @@
 }
 
 static void
-zbbus_attach(struct device *parent, struct device *self, void *aux)
+zbbus_attach(device_t parent, device_t self, void *aux)
 {
 	struct zbbus_attach_args za;
 	int i;
@@ -109,8 +108,7 @@
 }
 
 static int
-zbbus_submatch(struct device *parent, struct cfdata *cf,
-	       const int *ldesc, void *aux)
+zbbus_submatch(device_t parent, cfdata_t cf, const int *ldesc, void *aux)
 {
 	struct zbbus_attach_args *zap = aux;
 

Reply via email to