Module Name: src Committed By: tsutsui Date: Sun May 17 01:28:27 UTC 2009
Modified Files: src/sys/arch/sparc64/dev: sbus.c sbusvar.h Log Message: Split device_t/softc. Compile test only, but mostly similar changes with sparc/dev/sbus.c rev 1.69. XXX: it looks some functions should be merged between sparc and sparc64. To generate a diff of this commit: cvs rdiff -u -r1.83 -r1.84 src/sys/arch/sparc64/dev/sbus.c cvs rdiff -u -r1.15 -r1.16 src/sys/arch/sparc64/dev/sbusvar.h 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/sparc64/dev/sbus.c diff -u src/sys/arch/sparc64/dev/sbus.c:1.83 src/sys/arch/sparc64/dev/sbus.c:1.84 --- src/sys/arch/sparc64/dev/sbus.c:1.83 Sat Oct 18 03:31:10 2008 +++ src/sys/arch/sparc64/dev/sbus.c Sun May 17 01:28:27 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: sbus.c,v 1.83 2008/10/18 03:31:10 nakayama Exp $ */ +/* $NetBSD: sbus.c,v 1.84 2009/05/17 01:28:27 tsutsui Exp $ */ /* * Copyright (c) 1999-2002 Eduardo Horvath @@ -34,7 +34,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: sbus.c,v 1.83 2008/10/18 03:31:10 nakayama Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sbus.c,v 1.84 2009/05/17 01:28:27 tsutsui Exp $"); #include "opt_ddb.h" @@ -91,11 +91,11 @@ /* autoconfiguration driver */ -int sbus_match(struct device *, struct cfdata *, void *); -void sbus_attach(struct device *, struct device *, void *); +int sbus_match(device_t, cfdata_t, void *); +void sbus_attach(device_t, device_t, void *); -CFATTACH_DECL(sbus, sizeof(struct sbus_softc), +CFATTACH_DECL_NEW(sbus, sizeof(struct sbus_softc), sbus_match, sbus_attach, NULL, NULL); extern struct cfdriver sbus_cd; @@ -152,7 +152,7 @@ } int -sbus_match(struct device *parent, struct cfdata *cf, void *aux) +sbus_match(device_t parent, cfdata_t cf, void *aux) { struct mainbus_attach_args *ma = aux; @@ -163,7 +163,7 @@ * Attach an Sbus. */ void -sbus_attach(struct device *parent, struct device *self, void *aux) +sbus_attach(device_t parent, device_t self, void *aux) { struct sbus_softc *sc = device_private(self); struct mainbus_attach_args *ma = aux; @@ -175,6 +175,7 @@ bus_space_tag_t sbt; struct sbus_attach_args sa; + sc->sc_dev = self; sc->sc_bustag = ma->ma_bustag; sc->sc_dmatag = ma->ma_dmatag; sc->sc_ign = ma->ma_interrupts[0] & INTMAP_IGN; @@ -225,7 +226,7 @@ error = prom_getprop(node, "ranges", sizeof(struct openprom_range), &sbt->nranges, &sbt->ranges); if (error) - panic("%s: error getting ranges property", device_xname(&sc->sc_dev)); + panic("%s: error getting ranges property", device_xname(self)); /* initialize the IOMMU */ @@ -248,7 +249,7 @@ name = (char *)malloc(32, M_DEVBUF, M_NOWAIT); if (name == 0) panic("couldn't malloc iommu name"); - snprintf(name, 32, "%s dvma", device_xname(&sc->sc_dev)); + snprintf(name, 32, "%s dvma", device_xname(self)); iommu_init(name, &sc->sc_is, 0, -1); @@ -294,7 +295,7 @@ printf("sbus_attach: %s: incomplete\n", name1); continue; } - (void) config_found(&sc->sc_dev, (void *)&sa, sbus_print); + (void) config_found(self, &sa, sbus_print); sbus_destroy_attach_args(&sa); } } @@ -411,10 +412,10 @@ * its sbusdev portion. */ void -sbus_establish(register struct sbusdev *sd, register struct device *dev) +sbus_establish(struct sbusdev *sd, device_t dev) { register struct sbus_softc *sc; - register struct device *curdev; + register device_t curdev; /* * We have to look for the sbus by name, since it is not necessarily @@ -423,16 +424,16 @@ * sbus, since we might (in the future) support multiple sbus's. */ for (curdev = device_parent(dev); ; curdev = device_parent(curdev)) { - if (!curdev || !device_xname(curdev)) + if ((curdev == NULL) || (device_xname(curdev) == NULL)) panic("sbus_establish: can't find sbus parent for %s", - device_xname(sd->sd_dev) - ? device_xname(sd->sd_dev) + device_xname(dev) + ? device_xname(dev) : "<unknown>" ); if (strncmp(device_xname(curdev), "sbus", 4) == 0) break; } - sc = (struct sbus_softc *) curdev; + sc = device_private(curdev); sd->sd_dev = dev; sd->sd_bchain = sc->sc_sbdev; @@ -447,9 +448,9 @@ { register struct sbusdev *sd; struct sbus_softc *sc = device_lookup_private(&sbus_cd, sbus); - struct device *dev; + device_t dev; - printf("reset %s:", device_xname(&sc->sc_dev)); + printf("reset %s:", device_xname(sc->sc_dev)); for (sd = sc->sc_sbdev; sd != NULL; sd = sd->sd_bchain) { if (sd->sd_reset) { dev = sd->sd_dev; @@ -674,7 +675,7 @@ bus_size_t maxsegsz, bus_size_t boundary, int flags, bus_dmamap_t *dmamp) { - struct sbus_softc *sc = (struct sbus_softc *)t->_cookie; + struct sbus_softc *sc = t->_cookie; int error; error = bus_dmamap_create(t->_parent, size, nsegments, maxsegsz, Index: src/sys/arch/sparc64/dev/sbusvar.h diff -u src/sys/arch/sparc64/dev/sbusvar.h:1.15 src/sys/arch/sparc64/dev/sbusvar.h:1.16 --- src/sys/arch/sparc64/dev/sbusvar.h:1.15 Mon Apr 28 20:23:36 2008 +++ src/sys/arch/sparc64/dev/sbusvar.h Sun May 17 01:28:27 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: sbusvar.h,v 1.15 2008/04/28 20:23:36 martin Exp $ */ +/* $NetBSD: sbusvar.h,v 1.16 2009/05/17 01:28:27 tsutsui Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -95,7 +95,7 @@ /* variables per Sbus */ struct sbus_softc { - struct device sc_dev; /* base device */ + device_t sc_dev; /* base device */ bus_space_tag_t sc_bustag; bus_space_handle_t sc_bh; bus_dma_tag_t sc_dmatag;