From 036ca983e1abf97288db3a17aaa05b95b89f664a Mon Sep 17 00:00:00 2001 From: matt Date: Fri, 17 Jun 2011 19:03:00 +0000 Subject: [PATCH] struct device * -> device_t struct cfdata * -> cfdata_t split device/softc (CFATTACH_DECL_NEW) use device_accessors and device_private constify --- sys/arch/powerpc/booke/booke_autoconf.c | 6 +- sys/arch/powerpc/booke/dev/pq3etsec.c | 11 +- sys/arch/powerpc/ibm4xx/dev/comopbvar.h | 4 +- sys/arch/powerpc/ibm4xx/dev/ecc_plb.c | 35 ++-- sys/arch/powerpc/ibm4xx/dev/exb.c | 10 +- sys/arch/powerpc/ibm4xx/dev/gpiic_opb.c | 43 ++--- sys/arch/powerpc/ibm4xx/dev/gpio_opb.c | 154 +++++++++--------- sys/arch/powerpc/ibm4xx/dev/if_emac.c | 27 +-- sys/arch/powerpc/ibm4xx/dev/wdog.c | 39 +++-- sys/arch/powerpc/ibm4xx/ibm4xx_autoconf.c | 10 +- sys/arch/powerpc/ibm4xx/pci/pchb.c | 8 +- sys/arch/powerpc/ibm4xx/pci/pci_machdep.c | 6 +- sys/arch/powerpc/include/ibm4xx/cpu.h | 6 +- sys/arch/powerpc/include/ibm4xx/pci_machdep.h | 4 +- sys/arch/powerpc/include/isa_machdep.h | 7 +- sys/arch/powerpc/oea/cpu_subr.c | 63 +++---- sys/arch/powerpc/oea/ofw_autoconf.c | 10 +- sys/arch/powerpc/pci/pchb.c | 26 +-- sys/arch/powerpc/pci/pci_machdep_common.c | 10 +- sys/arch/powerpc/pci/pcib.c | 9 +- sys/arch/powerpc/pci/pciconf_indirect.c | 6 +- sys/arch/powerpc/pci/pciconf_ofmethod.c | 6 +- sys/arch/powerpc/powerpc/powerpc_machdep.c | 10 +- sys/arch/powerpc/powerpc/rtas.c | 20 +-- 24 files changed, 262 insertions(+), 268 deletions(-) diff --git a/sys/arch/powerpc/booke/booke_autoconf.c b/sys/arch/powerpc/booke/booke_autoconf.c index be4ef1ab7dde..71f21ceb2356 100644 --- a/sys/arch/powerpc/booke/booke_autoconf.c +++ b/sys/arch/powerpc/booke/booke_autoconf.c @@ -1,4 +1,4 @@ -/* $NetBSD: booke_autoconf.c,v 1.2 2011/01/18 01:02:52 matt Exp $ */ +/* $NetBSD: booke_autoconf.c,v 1.3 2011/06/17 19:03:03 matt Exp $ */ /*- * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc. * All rights reserved. @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: booke_autoconf.c,v 1.2 2011/01/18 01:02:52 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: booke_autoconf.c,v 1.3 2011/06/17 19:03:03 matt Exp $"); #include #include @@ -73,7 +73,7 @@ e500_device_register(device_t dev, void *aux) if (prop_dictionary_set(device_properties(dev), "mac-address", pd) == false) { printf("WARNING: unable to set mac-addr " - "property for %s\n", dev->dv_xname); + "property for %s\n", device_xname(dev)); } } return; diff --git a/sys/arch/powerpc/booke/dev/pq3etsec.c b/sys/arch/powerpc/booke/dev/pq3etsec.c index fd64d74f9a66..5b31ccc2b13a 100644 --- a/sys/arch/powerpc/booke/dev/pq3etsec.c +++ b/sys/arch/powerpc/booke/dev/pq3etsec.c @@ -1,4 +1,4 @@ -/* $NetBSD: pq3etsec.c,v 1.4 2011/06/12 05:37:54 matt Exp $ */ +/* $NetBSD: pq3etsec.c,v 1.5 2011/06/17 19:03:03 matt Exp $ */ /*- * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc. * All rights reserved. @@ -458,6 +458,7 @@ pq3etsec_attach(device_t parent, device_t self, void *aux) struct pq3etsec_softc * const sc = device_private(self); struct cpunode_attach_args * const cna = aux; struct cpunode_locators * const cnl = &cna->cna_locs; + cfdata_t cf = device_cfdata(self); int error; psc->sc_children |= cna->cna_childmask; @@ -468,15 +469,13 @@ pq3etsec_attach(device_t parent, device_t self, void *aux) /* * If we have a common MDIO bus, if all off instance 1. */ - device_t miiself = (self->dv_cfdata->cf_flags & 0x100) - ? tsec_cd.cd_devs[0] - : self; + device_t miiself = (cf->cf_flags & 0x100) ? tsec_cd.cd_devs[0] : self; /* * See if the phy is in the config file... */ - if (self->dv_cfdata->cf_flags & 0x3f) { - sc->sc_phy_addr = (self->dv_cfdata->cf_flags & 0x3f) - 1; + if (cf->cf_flags & 0x3f) { + sc->sc_phy_addr = (cf->cf_flags & 0x3f) - 1; } else { unsigned char prop_name[20]; snprintf(prop_name, sizeof(prop_name), "tsec%u-phy-addr", diff --git a/sys/arch/powerpc/ibm4xx/dev/comopbvar.h b/sys/arch/powerpc/ibm4xx/dev/comopbvar.h index c64533cd0ebe..584926b106e0 100644 --- a/sys/arch/powerpc/ibm4xx/dev/comopbvar.h +++ b/sys/arch/powerpc/ibm4xx/dev/comopbvar.h @@ -1,4 +1,4 @@ -/* $NetBSD: comopbvar.h,v 1.2 2005/12/11 12:18:42 christos Exp $ */ +/* $NetBSD: comopbvar.h,v 1.3 2011/06/17 19:03:01 matt Exp $ */ /* * Copyright (c) 2004 Shigeyuki Fukushima. @@ -37,6 +37,6 @@ #include extern void com_opb_cnattach(int, int, int, int); -extern void com_opb_device_register(struct device *, int); +extern void com_opb_device_register(device_t, int); #endif /* __IBM4XX_COMOPBVAR_H__ */ diff --git a/sys/arch/powerpc/ibm4xx/dev/ecc_plb.c b/sys/arch/powerpc/ibm4xx/dev/ecc_plb.c index 75bd14c1cc4d..9acec502e86c 100644 --- a/sys/arch/powerpc/ibm4xx/dev/ecc_plb.c +++ b/sys/arch/powerpc/ibm4xx/dev/ecc_plb.c @@ -1,4 +1,4 @@ -/* $NetBSD: ecc_plb.c,v 1.12 2010/03/18 13:47:04 kiyohara Exp $ */ +/* $NetBSD: ecc_plb.c,v 1.13 2011/06/17 19:03:01 matt Exp $ */ /* * Copyright 2001 Wasabi Systems, Inc. @@ -36,7 +36,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ecc_plb.c,v 1.12 2010/03/18 13:47:04 kiyohara Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ecc_plb.c,v 1.13 2011/06/17 19:03:01 matt Exp $"); #include "locators.h" @@ -52,26 +52,26 @@ __KERNEL_RCSID(0, "$NetBSD: ecc_plb.c,v 1.12 2010/03/18 13:47:04 kiyohara Exp $" struct ecc_plb_softc { - struct device sc_dev; - u_quad_t sc_ecc_tb; - u_quad_t sc_ecc_iv; /* Interval */ - u_int32_t sc_ecc_cnt; + device_t sc_dev; + uint64_t sc_ecc_tb; + uint64_t sc_ecc_iv; /* Interval */ + uint32_t sc_ecc_cnt; u_int sc_memsize; int sc_irq; }; -static int ecc_plbmatch(struct device *, struct cfdata *, void *); -static void ecc_plbattach(struct device *, struct device *, void *); -static void ecc_plb_deferred(struct device *); +static int ecc_plbmatch(device_t, cfdata_t, void *); +static void ecc_plbattach(device_t, device_t, void *); +static void ecc_plb_deferred(device_t); static int ecc_plb_intr(void *); -CFATTACH_DECL(ecc_plb, sizeof(struct ecc_plb_softc), +CFATTACH_DECL_NEW(ecc_plb, sizeof(struct ecc_plb_softc), ecc_plbmatch, ecc_plbattach, NULL, NULL); static int ecc_plb_found; static int -ecc_plbmatch(struct device *parent, struct cfdata *cf, void *aux) +ecc_plbmatch(device_t parent, cfdata_t cf, void *aux) { struct plb_attach_args *paa = aux; @@ -87,9 +87,9 @@ ecc_plbmatch(struct device *parent, struct cfdata *cf, void *aux) } static void -ecc_plbattach(struct device *parent, struct device *self, void *aux) +ecc_plbattach(device_t parent, device_t self, void *aux) { - struct ecc_plb_softc *sc = (struct ecc_plb_softc *)self; + struct ecc_plb_softc *sc = device_private(self); struct plb_attach_args *paa = aux; unsigned int processor_freq; unsigned int memsiz; @@ -105,8 +105,9 @@ ecc_plbattach(struct device *parent, struct device *self, void *aux) KASSERT(pn != NULL); memsiz = (unsigned int) prop_number_integer_value(pn); - printf(": ECC controller\n"); + aprint_normal(": ECC controller\n"); + sc->sc_dev = self; sc->sc_ecc_tb = 0; sc->sc_ecc_cnt = 0; sc->sc_ecc_iv = processor_freq; /* Set interval */ @@ -121,11 +122,11 @@ ecc_plbattach(struct device *parent, struct device *self, void *aux) } static void -ecc_plb_deferred(struct device *self) +ecc_plb_deferred(device_t self) { - struct ecc_plb_softc *sc = (struct ecc_plb_softc *)self; + struct ecc_plb_softc *sc = device_private(self); - intr_establish(sc->sc_irq, IST_LEVEL, IPL_SERIAL, ecc_plb_intr, NULL); + intr_establish(sc->sc_irq, IST_LEVEL, IPL_SERIAL, ecc_plb_intr, sc); } /* diff --git a/sys/arch/powerpc/ibm4xx/dev/exb.c b/sys/arch/powerpc/ibm4xx/dev/exb.c index 7ad9941eae93..0bf1db28fd41 100644 --- a/sys/arch/powerpc/ibm4xx/dev/exb.c +++ b/sys/arch/powerpc/ibm4xx/dev/exb.c @@ -1,4 +1,4 @@ -/* $Id: exb.c,v 1.2 2010/11/06 16:30:15 uebayasi Exp $ */ +/* $Id: exb.c,v 1.3 2011/06/17 19:03:02 matt Exp $ */ /*- * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: exb.c,v 1.2 2010/11/06 16:30:15 uebayasi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: exb.c,v 1.3 2011/06/17 19:03:02 matt Exp $"); #include "locators.h" @@ -48,8 +48,8 @@ struct exb_softc { extern const struct exb_conf exb_confs[]; -static int exb_match(device_t, struct cfdata *, void *); -static void exb_attach(device_t, struct device *, void *); +static int exb_match(device_t, cfdata_t, void *); +static void exb_attach(device_t, device_t, void *); static int exb_print(void *, const char *); CFATTACH_DECL_NEW(exb, sizeof(struct exb_softc), exb_match, exb_attach, @@ -59,7 +59,7 @@ static struct powerpc_bus_space exb_bus_space_tag = { _BUS_SPACE_BIG_ENDIAN | _BUS_SPACE_MEM_TYPE, 0 }; static int -exb_match(device_t parent, struct cfdata *cf, void *aux) +exb_match(device_t parent, cfdata_t cf, void *aux) { return 1; diff --git a/sys/arch/powerpc/ibm4xx/dev/gpiic_opb.c b/sys/arch/powerpc/ibm4xx/dev/gpiic_opb.c index e6e3bad4f5d4..e412be14dbda 100644 --- a/sys/arch/powerpc/ibm4xx/dev/gpiic_opb.c +++ b/sys/arch/powerpc/ibm4xx/dev/gpiic_opb.c @@ -1,4 +1,4 @@ -/* $NetBSD: gpiic_opb.c,v 1.7 2011/06/12 07:19:49 kiyohara Exp $ */ +/* $NetBSD: gpiic_opb.c,v 1.8 2011/06/17 19:03:02 matt Exp $ */ /* * Copyright 2002, 2003 Wasabi Systems, Inc. @@ -51,7 +51,7 @@ #include struct gpiic_softc { - struct device sc_dev; + device_t sc_dev; bus_space_tag_t sc_bust; bus_space_handle_t sc_bush; uint8_t sc_txen; @@ -61,10 +61,10 @@ struct gpiic_softc { kmutex_t sc_buslock; }; -static int gpiic_match(struct device *, struct cfdata *, void *); -static void gpiic_attach(struct device *, struct device *, void *); +static int gpiic_match(device_t, cfdata_t, void *); +static void gpiic_attach(device_t, device_t, void *); -CFATTACH_DECL(gpiic, sizeof(struct gpiic_softc), +CFATTACH_DECL_NEW(gpiic, sizeof(struct gpiic_softc), gpiic_match, gpiic_attach, NULL, NULL); static int gpiic_acquire_bus(void *, int); @@ -79,9 +79,9 @@ static void gpiic_set_bits(void *, uint32_t); static uint32_t gpiic_read_bits(void *); static int -gpiic_match(struct device *parent, struct cfdata *cf, void *args) +gpiic_match(device_t parent, cfdata_t cf, void *args) { - struct opb_attach_args *oaa = args; + struct opb_attach_args * const oaa = args; if (strcmp(oaa->opb_name, cf->cf_name) != 0) return 0; @@ -90,15 +90,16 @@ gpiic_match(struct device *parent, struct cfdata *cf, void *args) } static void -gpiic_attach(struct device *parent, struct device *self, void *args) +gpiic_attach(device_t parent, device_t self, void *args) { - struct gpiic_softc *sc = (struct gpiic_softc *)self; - struct opb_attach_args *oaa = args; + struct gpiic_softc * const sc = device_private(self); + struct opb_attach_args * const oaa = args; struct i2cbus_attach_args iba; aprint_naive(": IIC controller\n"); aprint_normal(": On-Chip IIC controller\n"); + sc->sc_dev = self; sc->sc_bust = oaa->opb_bt; bus_space_map(sc->sc_bust, oaa->opb_addr, IIC_NREG, 0, &sc->sc_bush); @@ -137,13 +138,13 @@ gpiic_attach(struct device *parent, struct device *self, void *args) memset(&iba, 0, sizeof(iba)); 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 gpiic_acquire_bus(void *arg, int flags) { - struct gpiic_softc *sc = arg; + struct gpiic_softc * const sc = arg; if (flags & I2C_F_POLL) return (0); @@ -155,7 +156,7 @@ gpiic_acquire_bus(void *arg, int flags) static void gpiic_release_bus(void *arg, int flags) { - struct gpiic_softc *sc = arg; + struct gpiic_softc * const sc = arg; if (flags & I2C_F_POLL) return; @@ -166,7 +167,7 @@ gpiic_release_bus(void *arg, int flags) static int gpiic_send_start(void *arg, int flags) { - struct gpiic_softc *sc = arg; + struct gpiic_softc * const sc = arg; return (i2c_bitbang_send_start(sc, flags, &sc->sc_bops)); } @@ -174,7 +175,7 @@ gpiic_send_start(void *arg, int flags) static int gpiic_send_stop(void *arg, int flags) { - struct gpiic_softc *sc = arg; + struct gpiic_softc * const sc = arg; return (i2c_bitbang_send_stop(sc, flags, &sc->sc_bops)); } @@ -182,7 +183,7 @@ gpiic_send_stop(void *arg, int flags) static int gpiic_initiate_xfer(void *arg, i2c_addr_t addr, int flags) { - struct gpiic_softc *sc = arg; + struct gpiic_softc * const sc = arg; return (i2c_bitbang_initiate_xfer(sc, addr, flags, &sc->sc_bops)); } @@ -190,7 +191,7 @@ gpiic_initiate_xfer(void *arg, i2c_addr_t addr, int flags) static int gpiic_read_byte(void *arg, uint8_t *vp, int flags) { - struct gpiic_softc *sc = arg; + struct gpiic_softc * const sc = arg; return (i2c_bitbang_read_byte(sc, vp, flags, &sc->sc_bops)); } @@ -198,7 +199,7 @@ gpiic_read_byte(void *arg, uint8_t *vp, int flags) static int gpiic_write_byte(void *arg, uint8_t v, int flags) { - struct gpiic_softc *sc = arg; + struct gpiic_softc * const sc = arg; return (i2c_bitbang_write_byte(sc, v, flags, &sc->sc_bops)); } @@ -206,7 +207,7 @@ gpiic_write_byte(void *arg, uint8_t v, int flags) static void gpiic_set_dir(void *arg, uint32_t bits) { - struct gpiic_softc *sc = arg; + struct gpiic_softc * const sc = arg; uint8_t tx, txen; txen = (uint8_t)bits; @@ -224,7 +225,7 @@ gpiic_set_dir(void *arg, uint32_t bits) static void gpiic_set_bits(void *arg, uint32_t bits) { - struct gpiic_softc *sc = arg; + struct gpiic_softc * const sc = arg; sc->sc_tx = (uint8_t)bits; if (sc->sc_txen == 0) @@ -236,7 +237,7 @@ gpiic_set_bits(void *arg, uint32_t bits) static uint32_t gpiic_read_bits(void *arg) { - struct gpiic_softc *sc = arg; + struct gpiic_softc * const sc = arg; uint8_t rv; rv = bus_space_read_1(sc->sc_bust, sc->sc_bush, IIC_DIRECTCNTL) << 2; diff --git a/sys/arch/powerpc/ibm4xx/dev/gpio_opb.c b/sys/arch/powerpc/ibm4xx/dev/gpio_opb.c index 8eb70e756a00..0173c9c46a15 100644 --- a/sys/arch/powerpc/ibm4xx/dev/gpio_opb.c +++ b/sys/arch/powerpc/ibm4xx/dev/gpio_opb.c @@ -1,4 +1,4 @@ -/* $NetBSD: gpio_opb.c,v 1.7 2010/03/18 13:47:04 kiyohara Exp $ */ +/* $NetBSD: gpio_opb.c,v 1.8 2011/06/17 19:03:02 matt Exp $ */ /* * Copyright (c) 2004 Shigeyuki Fukushima. @@ -45,7 +45,7 @@ #include struct gpio_opb_softc { - struct device sc_dev; /* device generic */ + device_t sc_dev; /* device generic */ /* GPIO interface */ bus_space_tag_t sc_gpio_iot; bus_space_handle_t sc_gpio_ioh; @@ -53,21 +53,44 @@ struct gpio_opb_softc { gpio_pin_t sc_gpio_pins[GPIO_NPINS]; }; -static int gpio_opb_match(struct device *, struct cfdata *, void *); -static void gpio_opb_attach(struct device *, struct device *, void *); +static int gpio_opb_match(device_t, cfdata_t, void *); +static void gpio_opb_attach(device_t, device_t, void *); -CFATTACH_DECL(opbgpio, sizeof(struct gpio_opb_softc), +CFATTACH_DECL_NEW(opbgpio, sizeof(struct gpio_opb_softc), gpio_opb_match, gpio_opb_attach, NULL, NULL); static int gpio_opb_pin_read(void *, int); static void gpio_opb_pin_write(void *, int, int); static void gpio_opb_pin_ctl(void *, int, int); +static inline uint32_t +gpio_read(struct gpio_opb_softc *sc, bus_size_t o) +{ + return bus_space_read_4(sc->sc_gpio_iot, sc->sc_gpio_ioh, o); +} + +static inline void +gpio_write(struct gpio_opb_softc *sc, bus_size_t o, uint32_t v) +{ + bus_space_write_4(sc->sc_gpio_iot, sc->sc_gpio_ioh, o, v); +} + +static inline void +gpio_set(struct gpio_opb_softc *sc, bus_size_t o, uint32_t v) +{ + gpio_write(sc, o, gpio_read(sc, o) | v); +} + +static inline void +gpio_clear(struct gpio_opb_softc *sc, bus_size_t o, uint32_t v) +{ + gpio_write(sc, o, gpio_read(sc, o) & ~v); +} static int -gpio_opb_match(struct device *parent, struct cfdata *cf, void *aux) +gpio_opb_match(device_t parent, cfdata_t cf, void *aux) { - struct opb_attach_args *oaa = aux; + struct opb_attach_args * const oaa = aux; if (strcmp(oaa->opb_name, cf->cf_name) != 0) return 0; @@ -76,45 +99,46 @@ gpio_opb_match(struct device *parent, struct cfdata *cf, void *aux) } static void -gpio_opb_attach(struct device *parent, struct device *self, void *aux) +gpio_opb_attach(device_t parent, device_t self, void *aux) { - struct gpio_opb_softc *sc = (struct gpio_opb_softc *)self; - struct opb_attach_args *oaa = aux; + struct gpio_opb_softc * const sc = device_private(self); + struct opb_attach_args * const oaa = aux; struct gpiobus_attach_args gba; - int i; - uint32_t reg1, reg2, reg3; + uint32_t reg_ir, reg_tcr, reg_odr; aprint_naive(": GPIO controller\n"); aprint_normal(": On-Chip GPIO controller\n"); + sc->sc_dev = self; + /* Map GPIO I/O space */ sc->sc_gpio_iot = oaa->opb_bt; bus_space_map(sc->sc_gpio_iot, oaa->opb_addr, GPIO_NREG, 0, &sc->sc_gpio_ioh); /* Read current register status */ - reg1 = bus_space_read_4(sc->sc_gpio_iot, sc->sc_gpio_ioh, GPIO_IR); - reg2 = bus_space_read_4(sc->sc_gpio_iot, sc->sc_gpio_ioh, GPIO_TCR); - reg3 = bus_space_read_4(sc->sc_gpio_iot, sc->sc_gpio_ioh, GPIO_ODR); + reg_ir = gpio_read(sc, GPIO_IR); + reg_tcr = gpio_read(sc, GPIO_TCR); + reg_odr = gpio_read(sc, GPIO_ODR); /* Initialize pins array */ - for (i = 0 ; i < GPIO_NPINS ; i++) { - int p = i + 1; - sc->sc_gpio_pins[i].pin_num = i; - sc->sc_gpio_pins[i].pin_caps = GPIO_PIN_INOUT - | GPIO_PIN_OPENDRAIN - | GPIO_PIN_TRISTATE; + gpio_pin_t *pin = sc->sc_gpio_pins; + for (u_int i = 0 ; i < GPIO_NPINS ; i++, pin++) { + const uint32_t pin_mask = 1 << GPIO_PIN_SHIFT(i + 1); + pin->pin_num = i; + pin->pin_caps = GPIO_PIN_INOUT + | GPIO_PIN_OPENDRAIN + | GPIO_PIN_TRISTATE; /* current defaults */ - sc->sc_gpio_pins[i].pin_flags = - ((reg3 >> GPIO_PIN_SHIFT(p)) & 0x01) + pin->pin_flags = + (reg_odr & pin_mask) ? GPIO_PIN_OPENDRAIN - : (((reg2 >> GPIO_PIN_SHIFT(p)) & 0x01) - ? GPIO_PIN_INOUT - : GPIO_PIN_TRISTATE); - sc->sc_gpio_pins[i].pin_state = - ((reg1 >> GPIO_PIN_SHIFT(p)) & 0x01); - sc->sc_gpio_pins[i].pin_mapped = 0; + : ((reg_tcr & pin_mask) + ? GPIO_PIN_INOUT + : GPIO_PIN_TRISTATE); + pin->pin_state = (reg_ir & pin_mask) != 0; + pin->pin_mapped = 0; } /* Create controller tag */ @@ -128,90 +152,58 @@ gpio_opb_attach(struct device *parent, struct device *self, void *aux) gba.gba_npins = GPIO_NPINS; /* Attach GPIO framework */ - (void) config_found(&sc->sc_dev, &gba, gpiobus_print); + (void) config_found(self, &gba, gpiobus_print); } static int gpio_opb_pin_read(void *arg, int pin) { - struct gpio_opb_softc *sc = arg; - uint32_t data; - int p; + struct gpio_opb_softc * const sc = arg; + const u_int p = (pin % GPIO_NPINS) + 1; + uint32_t reg_ir = gpio_read(sc, GPIO_IR); - p = pin % GPIO_NPINS; - p = p + 1; - - data = bus_space_read_4(sc->sc_gpio_iot, sc->sc_gpio_ioh, GPIO_IR); - - return (data >> GPIO_PIN_SHIFT(p)) & 0x01; + return (reg_ir >> GPIO_PIN_SHIFT(p)) & 0x01; } static void gpio_opb_pin_write(void *arg, int pin, int value) { - struct gpio_opb_softc *sc = arg; - uint32_t data; - int p; + struct gpio_opb_softc * const sc = arg; + const u_int p = (pin % GPIO_NPINS) + 1; + const uint32_t pin_mask = 1 << GPIO_PIN_SHIFT(p); - p = pin % GPIO_NPINS; - p = p + 1; - - data = bus_space_read_4(sc->sc_gpio_iot, sc->sc_gpio_ioh, GPIO_OR); if (value == 0) { - data &= ~(1 << GPIO_PIN_SHIFT(p)); + gpio_clear(sc, GPIO_OR, pin_mask); } else if (value == 1) { - data |= (1 << GPIO_PIN_SHIFT(p)); + gpio_set(sc, GPIO_OR, pin_mask); } - - bus_space_write_4(sc->sc_gpio_iot, sc->sc_gpio_ioh, GPIO_OR, data); } static void gpio_opb_pin_ctl(void *arg, int pin, int flags) { - struct gpio_opb_softc *sc = arg; - uint32_t data; - int p; - - p = pin % GPIO_NPINS; - p = p + 1; + struct gpio_opb_softc * const sc = arg; + const u_int p = (pin % GPIO_NPINS) + 1; + const uint32_t pin_mask = 1 << GPIO_PIN_SHIFT(p); if (flags & GPIO_PIN_INOUT) { /* GPIOn_ODR register bit is 0 */ - data = bus_space_read_4(sc->sc_gpio_iot, sc->sc_gpio_ioh, - GPIO_ODR); - data &= ~(1 << GPIO_PIN_SHIFT(p)); - bus_space_write_4(sc->sc_gpio_iot, sc->sc_gpio_ioh, - GPIO_ODR, data); + gpio_clear(sc, GPIO_ODR, pin_mask); + /* GPIOn_TCR register bit is 1 */ - data = bus_space_read_4(sc->sc_gpio_iot, sc->sc_gpio_ioh, - GPIO_TCR); - data |= (1 << GPIO_PIN_SHIFT(p)); - bus_space_write_4(sc->sc_gpio_iot, sc->sc_gpio_ioh, - GPIO_TCR, data); + gpio_set(sc, GPIO_TCR, pin_mask); } if (flags & GPIO_PIN_TRISTATE) { /* GPIOn_ODR register bit is 0 */ - data = bus_space_read_4(sc->sc_gpio_iot, sc->sc_gpio_ioh, - GPIO_ODR); - data &= ~(1 << GPIO_PIN_SHIFT(p)); - bus_space_write_4(sc->sc_gpio_iot, sc->sc_gpio_ioh, - GPIO_ODR, data); + gpio_clear(sc, GPIO_ODR, pin_mask); + /* GPIOn_TCR register bit is 0 */ - data = bus_space_read_4(sc->sc_gpio_iot, sc->sc_gpio_ioh, - GPIO_TCR); - data &= ~(1 << GPIO_PIN_SHIFT(p)); - bus_space_write_4(sc->sc_gpio_iot, sc->sc_gpio_ioh, - GPIO_TCR, data); + gpio_clear(sc, GPIO_TCR, pin_mask); } if (flags & GPIO_PIN_OPENDRAIN) { /* GPIOn_ODR register bit is 1 */ - data = bus_space_read_4(sc->sc_gpio_iot, sc->sc_gpio_ioh, - GPIO_ODR); - data |= (1 << GPIO_PIN_SHIFT(p)); - bus_space_write_4(sc->sc_gpio_iot, sc->sc_gpio_ioh, - GPIO_ODR, data); + gpio_set(sc, GPIO_ODR, pin_mask); } } diff --git a/sys/arch/powerpc/ibm4xx/dev/if_emac.c b/sys/arch/powerpc/ibm4xx/dev/if_emac.c index 224f2abad0b7..13a37e626a98 100644 --- a/sys/arch/powerpc/ibm4xx/dev/if_emac.c +++ b/sys/arch/powerpc/ibm4xx/dev/if_emac.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_emac.c,v 1.37 2010/04/05 07:19:31 joerg Exp $ */ +/* $NetBSD: if_emac.c,v 1.38 2011/06/17 19:03:02 matt Exp $ */ /* * Copyright 2001, 2002 Wasabi Systems, Inc. @@ -52,7 +52,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_emac.c,v 1.37 2010/04/05 07:19:31 joerg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_emac.c,v 1.38 2011/06/17 19:03:02 matt Exp $"); #include "opt_emac.h" @@ -332,6 +332,7 @@ emac_attach(device_t parent, device_t self, void *aux) struct emac_softc *sc = device_private(self); struct ifnet *ifp = &sc->sc_ethercom.ec_if; struct mii_data *mii = &sc->sc_mii; + const char * xname = device_xname(self); bus_dma_segment_t seg; int error, i, nseg, opb_freq, opbc, mii_phy = MII_PHY_ANY; const uint8_t *enaddr; @@ -526,7 +527,7 @@ emac_attach(device_t parent, device_t self, void *aux) ifmedia_set(&mii->mii_media, IFM_ETHER|IFM_AUTO); ifp = &sc->sc_ethercom.ec_if; - strcpy(ifp->if_xname, self->dv_xname); + strcpy(ifp->if_xname, xname); ifp->if_softc = sc; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_start = emac_start; @@ -552,26 +553,26 @@ emac_attach(device_t parent, device_t self, void *aux) * Attach the event counters. */ evcnt_attach_dynamic(&sc->sc_ev_txintr, EVCNT_TYPE_INTR, - NULL, self->dv_xname, "txintr"); + NULL, xname, "txintr"); evcnt_attach_dynamic(&sc->sc_ev_rxintr, EVCNT_TYPE_INTR, - NULL, self->dv_xname, "rxintr"); + NULL, xname, "rxintr"); evcnt_attach_dynamic(&sc->sc_ev_txde, EVCNT_TYPE_INTR, - NULL, self->dv_xname, "txde"); + NULL, xname, "txde"); evcnt_attach_dynamic(&sc->sc_ev_rxde, EVCNT_TYPE_INTR, - NULL, self->dv_xname, "rxde"); + NULL, xname, "rxde"); evcnt_attach_dynamic(&sc->sc_ev_intr, EVCNT_TYPE_INTR, - NULL, self->dv_xname, "intr"); + NULL, xname, "intr"); evcnt_attach_dynamic(&sc->sc_ev_txreap, EVCNT_TYPE_MISC, - NULL, self->dv_xname, "txreap"); + NULL, xname, "txreap"); evcnt_attach_dynamic(&sc->sc_ev_txsstall, EVCNT_TYPE_MISC, - NULL, self->dv_xname, "txsstall"); + NULL, xname, "txsstall"); evcnt_attach_dynamic(&sc->sc_ev_txdstall, EVCNT_TYPE_MISC, - NULL, self->dv_xname, "txdstall"); + NULL, xname, "txdstall"); evcnt_attach_dynamic(&sc->sc_ev_txdrop, EVCNT_TYPE_MISC, - NULL, self->dv_xname, "txdrop"); + NULL, xname, "txdrop"); evcnt_attach_dynamic(&sc->sc_ev_tu, EVCNT_TYPE_MISC, - NULL, self->dv_xname, "tu"); + NULL, xname, "tu"); #endif /* EMAC_EVENT_COUNTERS */ /* diff --git a/sys/arch/powerpc/ibm4xx/dev/wdog.c b/sys/arch/powerpc/ibm4xx/dev/wdog.c index 9acabf20b653..b3b7e55c6dda 100644 --- a/sys/arch/powerpc/ibm4xx/dev/wdog.c +++ b/sys/arch/powerpc/ibm4xx/dev/wdog.c @@ -1,4 +1,4 @@ -/* $NetBSD: wdog.c,v 1.10 2010/02/25 23:31:47 matt Exp $ */ +/* $NetBSD: wdog.c,v 1.11 2011/06/17 19:03:02 matt Exp $ */ /* * Copyright (c) 2002 Wasabi Systems, Inc. @@ -40,7 +40,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wdog.c,v 1.10 2010/02/25 23:31:47 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wdog.c,v 1.11 2011/06/17 19:03:02 matt Exp $"); #include #include @@ -55,25 +55,25 @@ __KERNEL_RCSID(0, "$NetBSD: wdog.c,v 1.10 2010/02/25 23:31:47 matt Exp $"); #include -static int wdog_match(struct device *, struct cfdata *, void *); -static void wdog_attach(struct device *, struct device *, void *); +static int wdog_match(device_t, cfdata_t, void *); +static void wdog_attach(device_t, device_t, void *); static int wdog_tickle(struct sysmon_wdog *); static int wdog_setmode(struct sysmon_wdog *); struct wdog_softc { - struct device sc_dev; + device_t sc_dev; struct sysmon_wdog sc_smw; - int sc_wdog_armed; + bool sc_wdog_armed; int sc_wdog_period; }; -CFATTACH_DECL(wdog, sizeof(struct wdog_softc), +CFATTACH_DECL_NEW(wdog, sizeof(struct wdog_softc), wdog_match, wdog_attach, NULL, NULL); static int -wdog_match(struct device *parent, struct cfdata *cf, void *aux) +wdog_match(device_t parent, cfdata_t cf, void *aux) { - struct opb_attach_args *oaa = aux; + struct opb_attach_args * const oaa = aux; /* match only watchdog devices */ if (strcmp(oaa->opb_name, cf->cf_name) != 0) @@ -83,9 +83,9 @@ wdog_match(struct device *parent, struct cfdata *cf, void *aux) } static void -wdog_attach(struct device *parent, struct device *self, void *aux) +wdog_attach(device_t parent, device_t self, void *aux) { - struct wdog_softc *sc = (void *)self; + struct wdog_softc * const sc = device_private(self); unsigned int processor_freq; prop_number_t freq; @@ -96,16 +96,15 @@ wdog_attach(struct device *parent, struct device *self, void *aux) sc->sc_wdog_period = (2LL << 29) / processor_freq; printf(": %d second period\n", sc->sc_wdog_period); - sc->sc_smw.smw_name = sc->sc_dev.dv_xname; + sc->sc_dev = self; + sc->sc_smw.smw_name = device_xname(self); sc->sc_smw.smw_cookie = sc; sc->sc_smw.smw_setmode = wdog_setmode; sc->sc_smw.smw_tickle = wdog_tickle; sc->sc_smw.smw_period = sc->sc_wdog_period; if (sysmon_wdog_register(&sc->sc_smw) != 0) - printf("%s: unable to register with sysmon\n", - sc->sc_dev.dv_xname); - + aprint_error_dev(self, "unable to register with sysmon\n"); } static int @@ -122,14 +121,14 @@ wdog_tickle(struct sysmon_wdog *smw) static int wdog_setmode(struct sysmon_wdog *smw) { - struct wdog_softc *sc = smw->smw_cookie; - uint32_t tcr, tsr; + struct wdog_softc * const sc = smw->smw_cookie; if ((smw->smw_mode & WDOG_MODE_MASK) == WDOG_MODE_DISARMED) { if (sc->sc_wdog_armed) { - tsr = mfspr(SPR_TSR); + uint32_t tsr = mfspr(SPR_TSR); tsr &= ~(TSR_ENW | TSR_WIS); mtspr(SPR_TSR, tsr); + sc->sc_wdog_armed = false; } } else { if (smw->smw_period == WDOG_PERIOD_DEFAULT) @@ -142,9 +141,9 @@ wdog_setmode(struct sysmon_wdog *smw) */ return (EOPNOTSUPP); } - sc->sc_wdog_armed = 1; + sc->sc_wdog_armed = true; - tcr = mfspr(SPR_TCR); + uint32_t tcr = mfspr(SPR_TCR); tcr |= TCR_WP_2_29 | TCR_WRC_SYSTEM; mtspr(SPR_TCR, tcr); diff --git a/sys/arch/powerpc/ibm4xx/ibm4xx_autoconf.c b/sys/arch/powerpc/ibm4xx/ibm4xx_autoconf.c index 100dc193f51e..0aff65de0210 100644 --- a/sys/arch/powerpc/ibm4xx/ibm4xx_autoconf.c +++ b/sys/arch/powerpc/ibm4xx/ibm4xx_autoconf.c @@ -1,4 +1,4 @@ -/* $NetBSD: ibm4xx_autoconf.c,v 1.13 2010/03/18 13:47:05 kiyohara Exp $ */ +/* $NetBSD: ibm4xx_autoconf.c,v 1.14 2011/06/17 19:03:01 matt Exp $ */ /* Original Tag: ibm4xxgpx_autoconf.c,v 1.2 2004/10/23 17:12:22 thorpej Exp $ */ /* @@ -33,7 +33,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ibm4xx_autoconf.c,v 1.13 2010/03/18 13:47:05 kiyohara Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ibm4xx_autoconf.c,v 1.14 2011/06/17 19:03:01 matt Exp $"); #include #include @@ -48,9 +48,9 @@ __KERNEL_RCSID(0, "$NetBSD: ibm4xx_autoconf.c,v 1.13 2010/03/18 13:47:05 kiyohar #include void -ibm4xx_device_register(struct device *dev, void *aux) +ibm4xx_device_register(device_t dev, void *aux) { - struct device *parent = device_parent(dev); + device_t parent = device_parent(dev); if (device_is_a(dev, "emac") && device_is_a(parent, "opb")) { /* Set the mac-address of the on-chip Ethernet. */ @@ -73,7 +73,7 @@ ibm4xx_device_register(struct device *dev, void *aux) if (prop_dictionary_set(dict, "mac-address", pd) == false) printf("WARNING: unable to set mac-address " - "property for %s\n", dev->dv_xname); + "property for %s\n", device_xname(dev)); snprintf(prop_name, sizeof(prop_name), "emac%d-mii-phy", oaa->opb_instance); diff --git a/sys/arch/powerpc/ibm4xx/pci/pchb.c b/sys/arch/powerpc/ibm4xx/pci/pchb.c index 3e068879a19a..978c44c51348 100644 --- a/sys/arch/powerpc/ibm4xx/pci/pchb.c +++ b/sys/arch/powerpc/ibm4xx/pci/pchb.c @@ -1,4 +1,4 @@ -/* $NetBSD: pchb.c,v 1.8 2011/06/06 16:42:18 matt Exp $ */ +/* $NetBSD: pchb.c,v 1.9 2011/06/17 19:03:02 matt Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: pchb.c,v 1.8 2011/06/06 16:42:18 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pchb.c,v 1.9 2011/06/17 19:03:02 matt Exp $"); #include "pci.h" #include "opt_pci.h" @@ -135,7 +135,7 @@ pchbattach(device_t parent, device_t self, void *aux) class = pci_conf_read(pc, tag, PCI_CLASS_REG); id = pci_conf_read(pc, tag, PCI_ID_REG); - printf("\n"); + aprint_normal("\n"); pcifound++; /* * All we do is print out a description. Eventually, we @@ -144,7 +144,7 @@ pchbattach(device_t parent, device_t self, void *aux) */ pci_devinfo(id, class, 0, devinfo, sizeof(devinfo)); - printf("%s: %s (rev. 0x%02x)\n", self->dv_xname, devinfo, + aprint_normal_dev(self, "%s (rev. 0x%02x)\n", devinfo, PCI_REVISION(class)); pci_machdep_init(); /* Redundant... */ diff --git a/sys/arch/powerpc/ibm4xx/pci/pci_machdep.c b/sys/arch/powerpc/ibm4xx/pci/pci_machdep.c index 7e7eea6ec09d..cc077245ed66 100644 --- a/sys/arch/powerpc/ibm4xx/pci/pci_machdep.c +++ b/sys/arch/powerpc/ibm4xx/pci/pci_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: pci_machdep.c,v 1.7 2010/03/18 13:58:38 kiyohara Exp $ */ +/* $NetBSD: pci_machdep.c,v 1.8 2011/06/17 19:03:02 matt Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved. @@ -43,7 +43,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.7 2010/03/18 13:58:38 kiyohara Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.8 2011/06/17 19:03:02 matt Exp $"); #include #include @@ -86,7 +86,7 @@ pci_machdep_init(void) } void -pci_attach_hook(struct device *parent, struct device *self, +pci_attach_hook(device_t parent, device_t self, struct pcibus_attach_args *pba) { diff --git a/sys/arch/powerpc/include/ibm4xx/cpu.h b/sys/arch/powerpc/include/ibm4xx/cpu.h index f8ef863bb4c8..0d436104475a 100644 --- a/sys/arch/powerpc/include/ibm4xx/cpu.h +++ b/sys/arch/powerpc/include/ibm4xx/cpu.h @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.h,v 1.16 2011/01/18 01:02:54 matt Exp $ */ +/* $NetBSD: cpu.h,v 1.17 2011/06/17 19:03:03 matt Exp $ */ /* * Copyright 2002 Wasabi Systems, Inc. @@ -74,7 +74,7 @@ extern char bootpath[]; #include /* export from ibm4xx/autoconf.c */ -extern void (*md_device_register)(struct device *dev, void *aux); +extern void (*md_device_register)(device_t dev, void *aux); /* export from ibm4xx/machdep.c */ extern void (*md_consinit)(void); @@ -90,7 +90,7 @@ extern void ibm4xx_dumpsys(void); extern void ibm4xx_install_extint(void (*)(void)); /* export from ibm4xx/ibm4xx_autoconf.c */ -extern void ibm4xx_device_register(struct device *dev, void *aux); +extern void ibm4xx_device_register(device_t dev, void *aux); /* export from ibm4xx/clock.c */ extern void calc_delayconst(void); diff --git a/sys/arch/powerpc/include/ibm4xx/pci_machdep.h b/sys/arch/powerpc/include/ibm4xx/pci_machdep.h index afc3cf3d62bc..018ead887e62 100644 --- a/sys/arch/powerpc/include/ibm4xx/pci_machdep.h +++ b/sys/arch/powerpc/include/ibm4xx/pci_machdep.h @@ -1,4 +1,4 @@ -/* $NetBSD: pci_machdep.h,v 1.5 2011/04/04 20:37:52 dyoung Exp $ */ +/* $NetBSD: pci_machdep.h,v 1.6 2011/06/17 19:03:03 matt Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved. @@ -67,7 +67,7 @@ struct ibm4xx_pci_chipset { /* * Functions provided to machine-independent PCI code. */ -void pci_attach_hook(struct device *, struct device *, +void pci_attach_hook(device_t, device_t, struct pcibus_attach_args *); int pci_bus_maxdevs(pci_chipset_tag_t, int); pcitag_t pci_make_tag(pci_chipset_tag_t, int, int, int); diff --git a/sys/arch/powerpc/include/isa_machdep.h b/sys/arch/powerpc/include/isa_machdep.h index de4ef29ce8e4..31338daf1483 100644 --- a/sys/arch/powerpc/include/isa_machdep.h +++ b/sys/arch/powerpc/include/isa_machdep.h @@ -1,4 +1,4 @@ -/* $NetBSD: isa_machdep.h,v 1.6 2009/08/20 14:21:12 dyoung Exp $ */ +/* $NetBSD: isa_machdep.h,v 1.7 2011/06/17 19:03:00 matt Exp $ */ /*- * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc. @@ -99,12 +99,11 @@ struct pic_ops; /* XXX */ /* * Functions provided to machine-independent ISA code. */ -void genppc_isa_attach_hook(struct device *, struct device *, - struct isabus_attach_args *); +void genppc_isa_attach_hook(device_t, device_t, struct isabus_attach_args *); void genppc_isa_detach_hook(isa_chipset_tag_t, device_t); const struct evcnt *genppc_isa_intr_evcnt(isa_chipset_tag_t, int); void *genppc_isa_intr_establish(isa_chipset_tag_t, int /*irq*/, int /*type*/, - int /*level*/, int (*ih_fun)(void *), void *); + int /*level*/, int (* /*ih_fun*/)(void *), void *); void genppc_isa_intr_disestablish(isa_chipset_tag_t, void *); int genppc_isa_intr_alloc(isa_chipset_tag_t, struct pic_ops *, int, int, int *); diff --git a/sys/arch/powerpc/oea/cpu_subr.c b/sys/arch/powerpc/oea/cpu_subr.c index 5d3b114314fd..c41198bc28c4 100644 --- a/sys/arch/powerpc/oea/cpu_subr.c +++ b/sys/arch/powerpc/oea/cpu_subr.c @@ -1,4 +1,4 @@ -/* $NetBSD: cpu_subr.c,v 1.65 2011/06/16 04:25:13 matt Exp $ */ +/* $NetBSD: cpu_subr.c,v 1.66 2011/06/17 19:03:04 matt Exp $ */ /*- * Copyright (c) 2001 Matt Thomas. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cpu_subr.c,v 1.65 2011/06/16 04:25:13 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu_subr.c,v 1.66 2011/06/17 19:03:04 matt Exp $"); #include "opt_ppcparam.h" #include "opt_multiprocessor.h" @@ -402,8 +402,9 @@ cpu_attach_common(device_t self, int id) */ if (id != 0) { aprint_normal(": ID %d\n", id); - aprint_normal("%s: processor off-line; multiprocessor support " - "not present in kernel\n", self->dv_xname); + aprint_normal_dev(self, + "processor off-line; " + "multiprocessor support not present in kernel\n"); return (NULL); } #endif @@ -455,6 +456,7 @@ void cpu_setup(device_t self, struct cpu_info *ci) { u_int hid0, hid0_save, pvr, vers; + const char * const xname = device_xname(self); const char *bitmask; char hidbuf[128]; char model[80]; @@ -593,8 +595,7 @@ cpu_setup(device_t self, struct cpu_info *ci) break; } snprintb(hidbuf, sizeof hidbuf, bitmask, hid0); - aprint_normal("%s: HID0 %s, powersave: %d\n", self->dv_xname, hidbuf, - powersave); + aprint_normal_dev(self, "HID0 %s, powersave: %d\n", hidbuf, powersave); ci->ci_khz = 0; @@ -615,7 +616,7 @@ cpu_setup(device_t self, struct cpu_info *ci) case MPC7450: case MPC7455: case MPC7457: - aprint_normal("%s: ", self->dv_xname); + aprint_normal_dev(self, ""); cpu_probe_speed(ci); aprint_normal("%u.%02u MHz", ci->ci_khz / 1000, (ci->ci_khz / 10) % 100); @@ -653,51 +654,51 @@ cpu_setup(device_t self, struct cpu_info *ci) #endif evcnt_attach_dynamic(&ci->ci_ev_clock, EVCNT_TYPE_INTR, - NULL, self->dv_xname, "clock"); + NULL, xname, "clock"); evcnt_attach_dynamic(&ci->ci_ev_softclock, EVCNT_TYPE_INTR, - NULL, self->dv_xname, "soft clock"); + NULL, xname, "soft clock"); evcnt_attach_dynamic(&ci->ci_ev_softnet, EVCNT_TYPE_INTR, - NULL, self->dv_xname, "soft net"); + NULL, xname, "soft net"); evcnt_attach_dynamic(&ci->ci_ev_softserial, EVCNT_TYPE_INTR, - NULL, self->dv_xname, "soft serial"); + NULL, xname, "soft serial"); evcnt_attach_dynamic(&ci->ci_ev_traps, EVCNT_TYPE_TRAP, - NULL, self->dv_xname, "traps"); + NULL, xname, "traps"); evcnt_attach_dynamic(&ci->ci_ev_kdsi, EVCNT_TYPE_TRAP, - &ci->ci_ev_traps, self->dv_xname, "kernel DSI traps"); + &ci->ci_ev_traps, xname, "kernel DSI traps"); evcnt_attach_dynamic(&ci->ci_ev_udsi, EVCNT_TYPE_TRAP, - &ci->ci_ev_traps, self->dv_xname, "user DSI traps"); + &ci->ci_ev_traps, xname, "user DSI traps"); evcnt_attach_dynamic(&ci->ci_ev_udsi_fatal, EVCNT_TYPE_TRAP, - &ci->ci_ev_udsi, self->dv_xname, "user DSI failures"); + &ci->ci_ev_udsi, xname, "user DSI failures"); evcnt_attach_dynamic(&ci->ci_ev_kisi, EVCNT_TYPE_TRAP, - &ci->ci_ev_traps, self->dv_xname, "kernel ISI traps"); + &ci->ci_ev_traps, xname, "kernel ISI traps"); evcnt_attach_dynamic(&ci->ci_ev_isi, EVCNT_TYPE_TRAP, - &ci->ci_ev_traps, self->dv_xname, "user ISI traps"); + &ci->ci_ev_traps, xname, "user ISI traps"); evcnt_attach_dynamic(&ci->ci_ev_isi_fatal, EVCNT_TYPE_TRAP, - &ci->ci_ev_isi, self->dv_xname, "user ISI failures"); + &ci->ci_ev_isi, xname, "user ISI failures"); evcnt_attach_dynamic(&ci->ci_ev_scalls, EVCNT_TYPE_TRAP, - &ci->ci_ev_traps, self->dv_xname, "system call traps"); + &ci->ci_ev_traps, xname, "system call traps"); evcnt_attach_dynamic(&ci->ci_ev_pgm, EVCNT_TYPE_TRAP, - &ci->ci_ev_traps, self->dv_xname, "PGM traps"); + &ci->ci_ev_traps, xname, "PGM traps"); evcnt_attach_dynamic(&ci->ci_ev_fpu, EVCNT_TYPE_TRAP, - &ci->ci_ev_traps, self->dv_xname, "FPU unavailable traps"); + &ci->ci_ev_traps, xname, "FPU unavailable traps"); evcnt_attach_dynamic(&ci->ci_ev_fpusw, EVCNT_TYPE_TRAP, - &ci->ci_ev_fpu, self->dv_xname, "FPU context switches"); + &ci->ci_ev_fpu, xname, "FPU context switches"); evcnt_attach_dynamic(&ci->ci_ev_ali, EVCNT_TYPE_TRAP, - &ci->ci_ev_traps, self->dv_xname, "user alignment traps"); + &ci->ci_ev_traps, xname, "user alignment traps"); evcnt_attach_dynamic(&ci->ci_ev_ali_fatal, EVCNT_TYPE_TRAP, - &ci->ci_ev_ali, self->dv_xname, "user alignment traps"); + &ci->ci_ev_ali, xname, "user alignment traps"); evcnt_attach_dynamic(&ci->ci_ev_umchk, EVCNT_TYPE_TRAP, - &ci->ci_ev_umchk, self->dv_xname, "user MCHK failures"); + &ci->ci_ev_umchk, xname, "user MCHK failures"); evcnt_attach_dynamic(&ci->ci_ev_vec, EVCNT_TYPE_TRAP, - &ci->ci_ev_traps, self->dv_xname, "AltiVec unavailable"); + &ci->ci_ev_traps, xname, "AltiVec unavailable"); #ifdef ALTIVEC if (cpu_altivec) { evcnt_attach_dynamic(&ci->ci_ev_vecsw, EVCNT_TYPE_TRAP, - &ci->ci_ev_vec, self->dv_xname, "AltiVec context switches"); + &ci->ci_ev_vec, xname, "AltiVec context switches"); } #endif evcnt_attach_dynamic(&ci->ci_ev_ipi, EVCNT_TYPE_INTR, - NULL, self->dv_xname, "IPIs"); + NULL, xname, "IPIs"); } /* @@ -1130,13 +1131,13 @@ cpu_tau_setup(struct cpu_info *ci) return; } - sme->sme_name = ci->ci_dev->dv_xname; + sme->sme_name = device_xname(ci->ci_dev); sme->sme_cookie = ci; sme->sme_refresh = cpu_tau_refresh; if ((error = sysmon_envsys_register(sme)) != 0) { - aprint_error("%s: unable to register with sysmon (%d)\n", - ci->ci_dev->dv_xname, error); + aprint_error_dev(ci->ci_dev, + " unable to register with sysmon (%d)\n", error); sysmon_envsys_destroy(sme); } } diff --git a/sys/arch/powerpc/oea/ofw_autoconf.c b/sys/arch/powerpc/oea/ofw_autoconf.c index e2dcfe5f7c70..aae68e90f3c3 100644 --- a/sys/arch/powerpc/oea/ofw_autoconf.c +++ b/sys/arch/powerpc/oea/ofw_autoconf.c @@ -1,4 +1,4 @@ -/* $NetBSD: ofw_autoconf.c,v 1.12 2010/06/09 04:41:43 kiyohara Exp $ */ +/* $NetBSD: ofw_autoconf.c,v 1.13 2011/06/17 19:03:04 matt Exp $ */ /* * Copyright (C) 1995, 1996 Wolfgang Solfrank. * Copyright (C) 1995, 1996 TooLs GmbH. @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ofw_autoconf.c,v 1.12 2010/06/09 04:41:43 kiyohara Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ofw_autoconf.c,v 1.13 2011/06/17 19:03:04 matt Exp $"); #ifdef ofppc #include "gtpci.h" @@ -205,9 +205,9 @@ canonicalize_bootpath(void) * known OF boot device. */ void -device_register(struct device *dev, void *aux) +device_register(device_t dev, void *aux) { - static struct device *parent; + static device_t parent; static char *bp = bootpath + 1, *cp = cbootpath; unsigned long addr, addr2; char *p; @@ -474,7 +474,7 @@ void cpu_rootconf(void) { printf("boot device: %s\n", - booted_device ? booted_device->dv_xname : ""); + booted_device ? device_xname(booted_device) : ""); setroot(booted_device, booted_partition); } diff --git a/sys/arch/powerpc/pci/pchb.c b/sys/arch/powerpc/pci/pchb.c index 340d40acd5b9..7a9e2ad1d758 100644 --- a/sys/arch/powerpc/pci/pchb.c +++ b/sys/arch/powerpc/pci/pchb.c @@ -1,4 +1,4 @@ -/* $NetBSD: pchb.c,v 1.5 2011/06/06 16:42:18 matt Exp $ */ +/* $NetBSD: pchb.c,v 1.6 2011/06/17 19:03:00 matt Exp $ */ /*- * Copyright (c) 2007 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pchb.c,v 1.5 2011/06/06 16:42:18 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pchb.c,v 1.6 2011/06/17 19:03:00 matt Exp $"); #include #include @@ -82,7 +82,7 @@ mpc105_print(struct pci_attach_args *pa, device_t self) reg1 = pci_conf_read(pa->pa_pc, pa->pa_tag, MPC105_PICR1); reg2 = pci_conf_read(pa->pa_pc, pa->pa_tag, MPC105_PICR2); - aprint_normal("%s: L2 cache: ", self->dv_xname); + aprint_normal_dev(self, "L2 cache: "); switch (reg2 & MPC105_PICR2_L2_SIZE) { case MPC105_PICR2_L2_SIZE_256K: @@ -125,7 +125,7 @@ mpc106_print(struct pci_attach_args *pa, device_t self) reg1 = pci_conf_read(pa->pa_pc, pa->pa_tag, MPC106_PICR1); reg2 = pci_conf_read(pa->pa_pc, pa->pa_tag, MPC106_PICR2); - aprint_normal("%s: L2 cache: ", self->dv_xname); + aprint_normal_dev(self, "L2 cache: "); switch (reg2 & MPC106_PICR2_L2_SIZE) { case MPC106_PICR2_L2_SIZE_256K: @@ -195,9 +195,9 @@ ibm82660_print(struct pci_attach_args *pa, device_t self) else s1 = "enabled"; if (reg2 & IBM_82660_SYSTEM_CTRL_L2_MI) - s2 = "(normal operation)"; + s2 = " (normal operation)"; else - s2 = "(miss updates inhibited)"; + s2 = " (miss updates inhibited)"; } else { s1 = "disabled"; s2 = ""; @@ -209,24 +209,24 @@ ibm82660_print(struct pci_attach_args *pa, device_t self) s1 = "disabled"; s2 = ""; #endif - aprint_normal("%s: L1: %s L2: %s %s\n", self->dv_xname, + aprint_normal_dev(self, "L1 %s L2 %s%s\n", (reg1 & IBM_82660_CACHE_STATUS_L1_EN) ? "enabled" : "disabled", s1, s2); reg1 = pci_conf_read(pa->pa_pc, pa->pa_tag, IBM_82660_OPTIONS_1); - aprint_verbose("%s: MCP# assertion %s " - "TEA# assertion %s\n", self->dv_xname, + aprint_verbose_dev(self, "MCP# assertion %s " + "TEA# assertion %s\n", (reg1 & IBM_82660_OPTIONS_1_MCP) ? "enabled" : "disabled", (reg1 & IBM_82660_OPTIONS_1_TEA) ? "enabled" : "disabled"); - aprint_verbose("%s: PCI/ISA I/O mapping %s\n", self->dv_xname, + aprint_verbose_dev(self, "PCI/ISA I/O mapping %s\n", (reg1 & IBM_82660_OPTIONS_1_ISA) ? "contiguous" : "non-contiguous"); reg1 = pci_conf_read(pa->pa_pc, pa->pa_tag, IBM_82660_OPTIONS_3); - aprint_normal("%s: DRAM %s (%s) SRAM %s\n", self->dv_xname, + aprint_normal_dev(self, "DRAM %s (%s) SRAM %s\n", (reg1 & IBM_82660_OPTIONS_3_DRAM) ? "EDO" : "standard", (reg1 & IBM_82660_OPTIONS_3_ECC) ? "ECC" : "parity", (reg1 & IBM_82660_OPTIONS_3_SRAM) ? "sync" : "async"); - aprint_verbose("%s: Snoop mode %s\n", self->dv_xname, + aprint_verbose_dev(self, "Snoop mode %s\n", (reg1 & IBM_82660_OPTIONS_3_SNOOP) ? "603" : "601/604"); } @@ -250,7 +250,7 @@ pchbattach(device_t parent, device_t self, void *aux) */ 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)) { diff --git a/sys/arch/powerpc/pci/pci_machdep_common.c b/sys/arch/powerpc/pci/pci_machdep_common.c index 825bf1f8f59e..f3418c27fbfd 100644 --- a/sys/arch/powerpc/pci/pci_machdep_common.c +++ b/sys/arch/powerpc/pci/pci_machdep_common.c @@ -1,4 +1,4 @@ -/* $NetBSD: pci_machdep_common.c,v 1.10 2011/04/04 20:37:53 dyoung Exp $ */ +/* $NetBSD: pci_machdep_common.c,v 1.11 2011/06/17 19:03:01 matt Exp $ */ /*- * Copyright (c) 2007 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pci_machdep_common.c,v 1.10 2011/04/04 20:37:53 dyoung Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pci_machdep_common.c,v 1.11 2011/06/17 19:03:01 matt Exp $"); #include #include @@ -206,11 +206,11 @@ bad: #include #include "isa.h" -void *genppc_pciide_machdep_compat_intr_establish(struct device *, +void *genppc_pciide_machdep_compat_intr_establish(device_t, struct pci_attach_args *, int, int (*)(void *), void *); void * -genppc_pciide_machdep_compat_intr_establish(struct device *dev, +genppc_pciide_machdep_compat_intr_establish(device_t dev, struct pci_attach_args *pa, int chan, int (*func)(void *), void *arg) { #if NISA > 0 @@ -221,7 +221,7 @@ genppc_pciide_machdep_compat_intr_establish(struct device *dev, cookie = isa_intr_establish(NULL, irq, IST_LEVEL, IPL_BIO, func, arg); if (cookie == NULL) return (NULL); - printf("%s: %s channel interrupting at irq %d\n", dev->dv_xname, + aprint_normal_dev(dev, "%s channel interrupting at irq %d\n", PCIIDE_CHANNEL_NAME(chan), irq); return (cookie); #else diff --git a/sys/arch/powerpc/pci/pcib.c b/sys/arch/powerpc/pci/pcib.c index b8c3b9f21c14..3dac5fb55bb3 100644 --- a/sys/arch/powerpc/pci/pcib.c +++ b/sys/arch/powerpc/pci/pcib.c @@ -1,4 +1,4 @@ -/* $NetBSD: pcib.c,v 1.5 2008/05/04 00:18:16 martin Exp $ */ +/* $NetBSD: pcib.c,v 1.6 2011/06/17 19:03:01 matt Exp $ */ /*- * Copyright (c) 1996, 1998 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pcib.c,v 1.5 2008/05/04 00:18:16 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pcib.c,v 1.6 2011/06/17 19:03:01 matt Exp $"); #include #include @@ -121,12 +121,11 @@ pcibattach(device_t parent, device_t self, void *aux) v = pci_conf_read(pa->pa_pc, pa->pa_tag, 0x40); if ((v & 0x20) == 0) { - aprint_verbose("%s: PIRQ[0-3] not used\n", self->dv_xname); + aprint_verbose_dev(self, "PIRQ[0-3] not used\n"); } else { v = pci_conf_read(pa->pa_pc, pa->pa_tag, 0x60); if ((v & 0x80808080) == 0x80808080) { - aprint_verbose("%s: PIRQ[0-3] disabled\n", - self->dv_xname); + aprint_verbose_dev(self, "PIRQ[0-3] disabled\n"); } else { int i; aprint_verbose("%s:", device_xname(self)); diff --git a/sys/arch/powerpc/pci/pciconf_indirect.c b/sys/arch/powerpc/pci/pciconf_indirect.c index d2d5a84ed85f..a66621279cbb 100644 --- a/sys/arch/powerpc/pci/pciconf_indirect.c +++ b/sys/arch/powerpc/pci/pciconf_indirect.c @@ -1,4 +1,4 @@ -/* $NetBSD: pciconf_indirect.c,v 1.3 2008/04/28 20:23:32 martin Exp $ */ +/* $NetBSD: pciconf_indirect.c,v 1.4 2011/06/17 19:03:01 matt Exp $ */ /*- * Copyright (c) 2007 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pciconf_indirect.c,v 1.3 2008/04/28 20:23:32 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pciconf_indirect.c,v 1.4 2011/06/17 19:03:01 matt Exp $"); #include #include @@ -62,7 +62,7 @@ __KERNEL_RCSID(0, "$NetBSD: pciconf_indirect.c,v 1.3 2008/04/28 20:23:32 martin #define PCI_MODE1_ENABLE 0x80000000UL void -genppc_pci_indirect_attach_hook(struct device *parent, struct device *self, +genppc_pci_indirect_attach_hook(device_t parent, device_t self, struct pcibus_attach_args *pba) { diff --git a/sys/arch/powerpc/pci/pciconf_ofmethod.c b/sys/arch/powerpc/pci/pciconf_ofmethod.c index 5a18e992a488..7b69741a3253 100644 --- a/sys/arch/powerpc/pci/pciconf_ofmethod.c +++ b/sys/arch/powerpc/pci/pciconf_ofmethod.c @@ -1,4 +1,4 @@ -/* $NetBSD: pciconf_ofmethod.c,v 1.2 2008/04/28 20:23:32 martin Exp $ */ +/* $NetBSD: pciconf_ofmethod.c,v 1.3 2011/06/17 19:03:01 matt Exp $ */ /*- * Copyright (c) 2007 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pciconf_ofmethod.c,v 1.2 2008/04/28 20:23:32 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pciconf_ofmethod.c,v 1.3 2011/06/17 19:03:01 matt Exp $"); #include #include @@ -62,7 +62,7 @@ __KERNEL_RCSID(0, "$NetBSD: pciconf_ofmethod.c,v 1.2 2008/04/28 20:23:32 martin #include void -genppc_pci_ofmethod_attach_hook(struct device *parent, struct device *self, +genppc_pci_ofmethod_attach_hook(device_t parent, device_t self, struct pcibus_attach_args *pba) { diff --git a/sys/arch/powerpc/powerpc/powerpc_machdep.c b/sys/arch/powerpc/powerpc/powerpc_machdep.c index 92a471271cbe..d5656b538338 100644 --- a/sys/arch/powerpc/powerpc/powerpc_machdep.c +++ b/sys/arch/powerpc/powerpc/powerpc_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: powerpc_machdep.c,v 1.54 2011/06/14 05:50:25 matt Exp $ */ +/* $NetBSD: powerpc_machdep.c,v 1.55 2011/06/17 19:03:01 matt Exp $ */ /* * Copyright (C) 1995, 1996 Wolfgang Solfrank. @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: powerpc_machdep.c,v 1.54 2011/06/14 05:50:25 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: powerpc_machdep.c,v 1.55 2011/06/17 19:03:01 matt Exp $"); #include "opt_altivec.h" #include "opt_modular.h" @@ -167,9 +167,11 @@ sysctl_machdep_booted_device(SYSCTLFN_ARGS) if (booted_device == NULL) return (EOPNOTSUPP); + const char * const xname = device_xname(booted_device); + node = *rnode; - node.sysctl_data = booted_device->dv_xname; - node.sysctl_size = strlen(booted_device->dv_xname) + 1; + node.sysctl_data = __UNCONST(xname); + node.sysctl_size = strlen(xname) + 1; return (sysctl_lookup(SYSCTLFN_CALL(&node))); } diff --git a/sys/arch/powerpc/powerpc/rtas.c b/sys/arch/powerpc/powerpc/rtas.c index d4bd9910f6c6..44ec5031401e 100644 --- a/sys/arch/powerpc/powerpc/rtas.c +++ b/sys/arch/powerpc/powerpc/rtas.c @@ -1,4 +1,4 @@ -/* $NetBSD: rtas.c,v 1.10 2011/06/12 21:28:26 mrg Exp $ */ +/* $NetBSD: rtas.c,v 1.11 2011/06/17 19:03:01 matt Exp $ */ /* * CHRP RTAS support routines @@ -9,7 +9,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: rtas.c,v 1.10 2011/06/12 21:28:26 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rtas.c,v 1.11 2011/06/17 19:03:01 matt Exp $"); #include #include @@ -68,10 +68,10 @@ static struct { { "thaw-time-base", RTAS_FUNC_THAW_TIME_BASE }, }; -static int rtas_match(struct device *, struct cfdata *, void *); -static void rtas_attach(struct device *, struct device *, void *); -static int rtas_detach(struct device *, int); -static int rtas_activate(struct device *, enum devact); +static int rtas_match(device_t, cfdata_t, void *); +static void rtas_attach(device_t, device_t, void *); +static int rtas_detach(device_t, int); +static int rtas_activate(device_t, enum devact); static int rtas_todr_gettime_ymdhms(struct todr_chip_handle *, struct clock_ymdhms *); static int rtas_todr_settime_ymdhms(struct todr_chip_handle *, @@ -81,7 +81,7 @@ CFATTACH_DECL_NEW(rtas, sizeof (struct rtas_softc), rtas_match, rtas_attach, rtas_detach, rtas_activate); static int -rtas_match(struct device *parent, struct cfdata *match, void *aux) +rtas_match(device_t parent, cfdata_t match, void *aux) { struct confargs *ca = aux; @@ -92,7 +92,7 @@ rtas_match(struct device *parent, struct cfdata *match, void *aux) } static void -rtas_attach(struct device *parent, struct device *self, void *aux) +rtas_attach(device_t parent, device_t self, void *aux) { struct confargs *ca = aux; struct rtas_softc *sc = device_private(self); @@ -179,13 +179,13 @@ fail: } static int -rtas_detach(struct device *self, int flags) +rtas_detach(device_t self, int flags) { return EOPNOTSUPP; } static int -rtas_activate(struct device *self, enum devact act) +rtas_activate(device_t self, enum devact act) { return EOPNOTSUPP; }