Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/emips/ebus - misc KNF



details:   https://anonhg.NetBSD.org/src/rev/f1846791db71
branches:  trunk
changeset: 765972:f1846791db71
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Sun Jun 12 05:27:56 2011 +0000

description:
- misc KNF
- use device_t and cfdata_t

diffstat:

 sys/arch/emips/ebus/gpio_ebus.c |  64 +++++++++++++++++++++-------------------
 1 files changed, 33 insertions(+), 31 deletions(-)

diffs (147 lines):

diff -r 1957ef94ea91 -r f1846791db71 sys/arch/emips/ebus/gpio_ebus.c
--- a/sys/arch/emips/ebus/gpio_ebus.c   Sun Jun 12 05:22:30 2011 +0000
+++ b/sys/arch/emips/ebus/gpio_ebus.c   Sun Jun 12 05:27:56 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: gpio_ebus.c,v 1.1 2011/01/26 01:18:50 pooka Exp $      */
+/*     $NetBSD: gpio_ebus.c,v 1.2 2011/06/12 05:27:56 tsutsui Exp $    */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>                 /* RCS ID & Copyright macro defns */
-__KERNEL_RCSID(0, "$NetBSD: gpio_ebus.c,v 1.1 2011/01/26 01:18:50 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gpio_ebus.c,v 1.2 2011/06/12 05:27:56 tsutsui Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -52,11 +52,11 @@
        struct device sc_dev;
        struct _Pio *sc_dp;
        struct gpio_chipset_tag sc_gpio_gc;
-       gpio_pin_t              sc_gpio_pins[GPIO_NPINS];
+       gpio_pin_t sc_gpio_pins[GPIO_NPINS];
 };
 
-static int     epio_ebus_match (struct device *, struct cfdata *, void *);
-static void    epio_ebus_attach (struct device *, struct device *, void *);
+static int     epio_ebus_match(device_t, cfdata_t, void *);
+static void    epio_ebus_attach(device_t, device_t, void *);
 
 CFATTACH_DECL(epio, sizeof (struct epio_softc),
     epio_ebus_match, epio_ebus_attach, NULL, NULL);
@@ -66,47 +66,49 @@
 static void    epio_pin_ctl(void *, int, int);
 
 static int
-epio_ebus_match(struct device *parent, struct cfdata *match, void *aux)
+epio_ebus_match(device_t parent, cfdata_t cf, void *aux)
 {
        struct ebus_attach_args *ia = aux;
-    struct _Pio *f = (struct _Pio *)ia->ia_vaddr;
+       struct _Pio *f = (struct _Pio *)ia->ia_vaddr;
 
        if (strcmp("gpio", ia->ia_name) != 0)
-               return (0);
-    if ((f == NULL) ||
-        (f->Tag != PMTTAG_GPIO))
-               return (0);
+               return 0;
+       if ((f == NULL) ||
+               (f->Tag != PMTTAG_GPIO))
+               return 0;
 
-       return (1);
+       return 1;
 }
 
 static void
-epio_ebus_attach(struct device *parent, struct device *self, void *aux)
+epio_ebus_attach(device_t parent, device_t self, void *aux)
 {
+       struct epio_softc *sc = (struct epio_softc *)self;
        struct ebus_attach_args *ia =aux;
-       struct epio_softc *sc = (struct epio_softc *)self;
        struct gpiobus_attach_args gba;
-    int i;
+       int i;
        uint32_t data;
 
-       sc->sc_dp = (struct _Pio*)ia->ia_vaddr;
+       sc->sc_dp = (struct _Pio *)ia->ia_vaddr;
        data = sc->sc_dp->PinData;
 
 #if DEBUG
-    printf(" virt=%p data=%zx", (void*)sc->sc_dp, data);
+       printf(" virt=%p data=%zx", (void*)sc->sc_dp, data);
 #endif
        printf(": GPIO controller\n");
 
        /* BUGBUG Initialize pins properly */
        for (i = 0 ; i < GPIO_NPINS ; i++) {
                sc->sc_gpio_pins[i].pin_num = i;
-               sc->sc_gpio_pins[i].pin_caps = GPIO_PIN_INOUT
-                                               | GPIO_PIN_OPENDRAIN
-                                               | GPIO_PIN_TRISTATE;
+               sc->sc_gpio_pins[i].pin_caps =
+                   GPIO_PIN_INOUT |
+                   GPIO_PIN_OPENDRAIN |
+                   GPIO_PIN_TRISTATE;
 
                /* current defaults */
                sc->sc_gpio_pins[i].pin_flags = GPIO_PIN_INOUT;
-               sc->sc_gpio_pins[i].pin_state = (data & (1 << i)) ? GPIO_PIN_HIGH : GPIO_PIN_LOW;
+               sc->sc_gpio_pins[i].pin_state =
+                   (data & (1 << i)) ? GPIO_PIN_HIGH : GPIO_PIN_LOW;
                sc->sc_gpio_pins[i].pin_mapped = 0;
        }
 
@@ -121,7 +123,7 @@
        gba.gba_npins = GPIO_NPINS;
 
        /* Attach GPIO framework */
-       (void) config_found(&sc->sc_dev, &gba, gpiobus_print);
+       (void)config_found(&sc->sc_dev, &gba, gpiobus_print);
 }
 
 static int
@@ -143,11 +145,11 @@
        int p;
 
        p = pin % GPIO_NPINS;
-    data = 1 << p;
-    if (value)
-        sc->sc_dp->PinData = data;
-    else
-        sc->sc_dp->ClearData = data;
+       data = 1 << p;
+       if (value)
+               sc->sc_dp->PinData = data;
+       else
+               sc->sc_dp->ClearData = data;
 }
 
 static void
@@ -158,17 +160,17 @@
        int p;
 
        p = pin % GPIO_NPINS;
-    data = (1 << p);
+       data = (1 << p);
 
        if (flags & GPIO_PIN_INOUT) {
-        sc->sc_dp->Direction = data;
+               sc->sc_dp->Direction = data;
        }
 
        if (flags & GPIO_PIN_TRISTATE) {
-        sc->sc_dp->OutDisable = data;
+               sc->sc_dp->OutDisable = data;
        }
 
        if (flags & GPIO_PIN_OPENDRAIN) {
-        sc->sc_dp->Enable = data;
+               sc->sc_dp->Enable = data;
        }
 }



Home | Main Index | Thread Index | Old Index