Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/arm/xscale split iopi2c(4) device/softc



details:   https://anonhg.NetBSD.org/src/rev/12f3c3fc5158
branches:  trunk
changeset: 772653:12f3c3fc5158
user:      jakllsch <jakllsch%NetBSD.org@localhost>
date:      Tue Jan 10 18:55:37 2012 +0000

description:
split iopi2c(4) device/softc

diffstat:

 sys/arch/arm/xscale/i80312_i2c.c |  21 +++++++++++----------
 sys/arch/arm/xscale/i80321_i2c.c |  21 +++++++++++----------
 sys/arch/arm/xscale/iopi2c.c     |  17 +++++++++--------
 sys/arch/arm/xscale/iopi2cvar.h  |   4 ++--
 4 files changed, 33 insertions(+), 30 deletions(-)

diffs (229 lines):

diff -r d04c11bfc20d -r 12f3c3fc5158 sys/arch/arm/xscale/i80312_i2c.c
--- a/sys/arch/arm/xscale/i80312_i2c.c  Tue Jan 10 17:53:51 2012 +0000
+++ b/sys/arch/arm/xscale/i80312_i2c.c  Tue Jan 10 18:55:37 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: i80312_i2c.c,v 1.5 2011/07/01 20:32:51 dyoung Exp $    */
+/*     $NetBSD: i80312_i2c.c,v 1.6 2012/01/10 18:55:37 jakllsch Exp $  */
 
 /*
  * Copyright (c) 2003 Wasabi Systems, Inc.
@@ -40,7 +40,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i80312_i2c.c,v 1.5 2011/07/01 20:32:51 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i80312_i2c.c,v 1.6 2012/01/10 18:55:37 jakllsch Exp $");
 
 #include <sys/param.h>
 #include <sys/mutex.h>
@@ -59,7 +59,7 @@
 #include <arm/xscale/iopi2creg.h>
 
 static int
-iic312_match(struct device *parent, struct cfdata *cf, void *aux)
+iic312_match(device_t parent, cfdata_t cf, void *aux)
 {
        struct iopxs_attach_args *ia = aux;
 
@@ -70,21 +70,22 @@
 }
 
 static void
-iic312_attach(struct device *parent, struct device *self, void *aux)
+iic312_attach(device_t parent, device_t self, void *aux)
 {
-       struct iopiic_softc *sc = (void *) self;
+       struct iopiic_softc *sc = device_private(self);
        struct iopxs_attach_args *ia = aux;
        int error;
 
        aprint_naive(": I2C controller\n");
        aprint_normal(": I2C controller\n");
 
+       sc->sc_dev = self;
        sc->sc_st = ia->ia_st;
        if ((error = bus_space_subregion(sc->sc_st, ia->ia_sh,
                                         ia->ia_offset, ia->ia_size,
                                         &sc->sc_sh)) != 0) {
-               aprint_error("%s: unable to subregion registers, error = %d\n",
-                   sc->sc_dev.dv_xname, error);
+               aprint_error_dev(self,
+                   "unable to subregion registers, error = %d\n", error);
                return;
        }
 
@@ -97,8 +98,8 @@
        sc->sc_ih = i80321_intr_establish(ICU_INT_I2C, IPL_BIO,
                                          iopiic_intr, sc);
        if (sc->sc_ih == NULL) {
-               aprint_error("%s: unable to establish interrupt handler\n",
-                   sc->sc_dev.dv_xname);
+               aprint_error_dev(self,
+                   "unable to establish interrupt handler\n");
                return;
        }
 #endif
@@ -117,5 +118,5 @@
        iopiic_attach(sc);
 }
 
-CFATTACH_DECL(iopiic, sizeof(struct iopiic_softc),
+CFATTACH_DECL_NEW(iopiic, sizeof(struct iopiic_softc),
     iic312_match, iic312_attach, NULL, NULL);
diff -r d04c11bfc20d -r 12f3c3fc5158 sys/arch/arm/xscale/i80321_i2c.c
--- a/sys/arch/arm/xscale/i80321_i2c.c  Tue Jan 10 17:53:51 2012 +0000
+++ b/sys/arch/arm/xscale/i80321_i2c.c  Tue Jan 10 18:55:37 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: i80321_i2c.c,v 1.4 2011/07/01 20:32:51 dyoung Exp $    */
+/*     $NetBSD: i80321_i2c.c,v 1.5 2012/01/10 18:55:37 jakllsch Exp $  */
 
 /*
  * Copyright (c) 2003 Wasabi Systems, Inc.
@@ -40,7 +40,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i80321_i2c.c,v 1.4 2011/07/01 20:32:51 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i80321_i2c.c,v 1.5 2012/01/10 18:55:37 jakllsch Exp $");
 
 #include <sys/param.h>
 #include <sys/mutex.h>
@@ -60,7 +60,7 @@
 #include <arm/xscale/iopi2cvar.h>
 
 static int
-iic321_match(struct device *parent, struct cfdata *cf, void *aux)
+iic321_match(device_t parent, cfdata_t cf, void *aux)
 {
        struct iopxs_attach_args *ia = aux;
 
@@ -71,9 +71,9 @@
 }
 
 static void
-iic321_attach(struct device *parent, struct device *self, void *aux)
+iic321_attach(device_t parent, device_t self, void *aux)
 {
-       struct iopiic_softc *sc = (void *) self;
+       struct iopiic_softc *sc = device_private(self);
        struct iopxs_attach_args *ia = aux;
        int error;
        uint8_t gpio_bits;
@@ -81,12 +81,13 @@
        aprint_naive(": I2C controller\n");
        aprint_normal(": I2C controller\n");
 
+       sc->sc_dev = self;
        sc->sc_st = ia->ia_st;
        if ((error = bus_space_subregion(sc->sc_st, ia->ia_sh,
                                         ia->ia_offset, ia->ia_size,
                                         &sc->sc_sh)) != 0) {
-               aprint_error("%s: unable to subregion registers, error = %d\n",
-                   sc->sc_dev.dv_xname, error);
+               aprint_error_dev(self,
+                   "unable to subregion registers, error = %d\n", error);
                return;
        }
 
@@ -104,8 +105,8 @@
        sc->sc_ih = i80321_intr_establish((ia->ia_offset == VERDE_I2C_BASE0) ?
            ICU_INT_I2C0 : ICU_INT_I2C1, IPL_BIO, iopiic_intr, sc);
        if (sc->sc_ih == NULL) {
-               aprint_error("%s: unable to establish interrupt handler\n",
-                   sc->sc_dev.dv_xname);
+               aprint_error_dev(self,
+                   "unable to establish interrupt handler\n");
                return;
        }
 #endif
@@ -122,5 +123,5 @@
        iopiic_attach(sc);
 }
 
-CFATTACH_DECL(iopiic, sizeof(struct iopiic_softc),
+CFATTACH_DECL_NEW(iopiic, sizeof(struct iopiic_softc),
     iic321_match, iic321_attach, NULL, NULL);
diff -r d04c11bfc20d -r 12f3c3fc5158 sys/arch/arm/xscale/iopi2c.c
--- a/sys/arch/arm/xscale/iopi2c.c      Tue Jan 10 17:53:51 2012 +0000
+++ b/sys/arch/arm/xscale/iopi2c.c      Tue Jan 10 18:55:37 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: iopi2c.c,v 1.6 2011/07/01 20:32:51 dyoung Exp $        */
+/*     $NetBSD: iopi2c.c,v 1.7 2012/01/10 18:55:37 jakllsch Exp $      */
 
 /*
  * Copyright (c) 2003 Wasabi Systems, Inc.
@@ -40,7 +40,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: iopi2c.c,v 1.6 2011/07/01 20:32:51 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: iopi2c.c,v 1.7 2012/01/10 18:55:37 jakllsch Exp $");
 
 #include <sys/param.h>
 #include <sys/mutex.h>
@@ -80,7 +80,7 @@
        sc->sc_i2c.ic_write_byte = iopiic_write_byte;
 
        iba.iba_tag = &sc->sc_i2c;
-       (void) config_found_ia(&sc->sc_dev, "i2cbus", &iba, iicbus_print);
+       (void) config_found_ia(sc->sc_dev, "i2cbus", &iba, iicbus_print);
 }
 
 static int
@@ -148,8 +148,9 @@
                error = ETIMEDOUT;
 
        if (error)
-               printf("%s: iopiic_wait, (%08x) error %d: ISR = 0x%08x\n",
-                   sc->sc_dev.dv_xname, bit, error, isr);
+               device_printf(sc->sc_dev,
+                   "iopiic_wait, (%08x) error %d: ISR = 0x%08x\n",
+                   bit, error, isr);
 
        /*
         * The IIC_ISR is Read/Clear apart from the bottom 4 bits, which are
@@ -216,7 +217,7 @@
        error = iopiic_wait(sc, IIC_ISR_ITE, flags);
 #if 0
        if (error)
-               printf("%s: failed to initiate %s xfer\n", sc->sc_dev.dv_xname,
+               device_printf(sc->sc_dev, "failed to initiate %s xfer\n",
                    rd_req ? "read" : "write");
 #endif
        return (error);
@@ -236,7 +237,7 @@
                *bytep = bus_space_read_4(sc->sc_st, sc->sc_sh, IIC_IDBR);
 #if 0
        if (error)
-               printf("%s: read byte failed\n", sc->sc_dev.dv_xname);
+               device_printf(sc->sc_dev, "read byte failed\n");
 #endif
 
        return (error);
@@ -255,7 +256,7 @@
 
 #if 0
        if (error)
-               printf("%s: write byte failed\n", sc->sc_dev.dv_xname);
+               device_printf(sc->sc_dev, "write byte failed\n");
 #endif
 
        return (error);
diff -r d04c11bfc20d -r 12f3c3fc5158 sys/arch/arm/xscale/iopi2cvar.h
--- a/sys/arch/arm/xscale/iopi2cvar.h   Tue Jan 10 17:53:51 2012 +0000
+++ b/sys/arch/arm/xscale/iopi2cvar.h   Tue Jan 10 18:55:37 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: iopi2cvar.h,v 1.3 2007/12/08 13:54:32 ad Exp $ */
+/*     $NetBSD: iopi2cvar.h,v 1.4 2012/01/10 18:55:37 jakllsch Exp $   */
 
 /*
  * Copyright (c) 2003 Wasabi Systems, Inc.
@@ -39,7 +39,7 @@
 #define _ARM_XSCALE_IOPIICVAR_H_ 
 
 struct iopiic_softc {
-       struct device sc_dev;
+       device_t sc_dev;
        bus_space_tag_t sc_st;
        bus_space_handle_t sc_sh;
 



Home | Main Index | Thread Index | Old Index