Source-Changes-HG archive

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

[src/trunk]: src/sys Use device_private(), proper types or variables for devi...



details:   https://anonhg.NetBSD.org/src/rev/7813434aeb13
branches:  trunk
changeset: 747428:7813434aeb13
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Mon Sep 14 13:41:15 2009 +0000

description:
Use device_private(), proper types or variables for device_t and softc.
(not yet split though)

No crash on gxemul emulating hpcmips mobilepro.

diffstat:

 sys/arch/hpcmips/vr/vrecu.c  |  22 +++++++++++-----------
 sys/dev/ic/i82365.c          |  28 +++++++++++++++-------------
 sys/dev/isa/i82365_isa.c     |   8 ++++----
 sys/dev/isa/i82365_isasubr.c |  40 ++++++++++++++++++++--------------------
 sys/dev/pci/i82365_pci.c     |  10 +++++-----
 5 files changed, 55 insertions(+), 53 deletions(-)

diffs (truncated from 407 to 300 lines):

diff -r a9564a5fdce6 -r 7813434aeb13 sys/arch/hpcmips/vr/vrecu.c
--- a/sys/arch/hpcmips/vr/vrecu.c       Mon Sep 14 12:52:20 2009 +0000
+++ b/sys/arch/hpcmips/vr/vrecu.c       Mon Sep 14 13:41:15 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vrecu.c,v 1.8 2009/09/14 12:49:33 tsutsui Exp $ */
+/* $NetBSD: vrecu.c,v 1.9 2009/09/14 13:41:15 tsutsui Exp $ */
 
 /*
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vrecu.c,v 1.8 2009/09/14 12:49:33 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vrecu.c,v 1.9 2009/09/14 13:41:15 tsutsui Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -105,8 +105,8 @@
 static void
 pcic_vrip_attach(struct device *parent, struct device *self, void *aux)
 {
-       struct pcic_softc       *sc = (void *) self;
-       struct pcic_vrip_softc  *vsc = (void *) self;
+       struct pcic_vrip_softc  *vsc = device_private(self);
+       struct pcic_softc       *sc = &vsc->sc_pcic;
        struct vrip_attach_args *va = aux;
        bus_space_handle_t      ioh;
        bus_space_handle_t      memh;
@@ -118,9 +118,9 @@
                vsc->sc_intrhand[i].ih_fun = NULL;
 
        if ((sc->ih = vrip_intr_establish(va->va_vc, va->va_unit, 0,
-                                         IPL_NET, pcic_vrip_intr, sc))
+                                         IPL_NET, pcic_vrip_intr, vsc))
            == NULL) {
-               printf("%s: can't establish interrupt", sc->dev.dv_xname);
+               printf(": can't establish interrupt");
        }
 
         /* Map i/o space. */
@@ -203,8 +203,8 @@
 
 
        h = (struct pcic_handle *) pch;
-       sc = (struct pcic_softc *) h->ph_parent;
-       vsc = (struct pcic_vrip_softc *) h->ph_parent;
+       vsc = device_private(h->ph_parent);
+       sc = &vsc->sc_pcic;
 
 
        ih = &vsc->sc_intrhand[irq];
@@ -239,8 +239,8 @@
        int     r;
 
        h = (struct pcic_handle *) pch;
-       sc = (struct pcic_softc *) h->ph_parent;
-       vsc = (struct pcic_vrip_softc *) h->ph_parent;
+       vsc = device_private(h->ph_parent);
+       sc = &vsc->sc_pcic;
 
        if (ih != &vsc->sc_intrhand[h->ih_irq])
                panic("pcic_vrip_chip_intr_disestablish: bad handler");
@@ -270,8 +270,8 @@
 static int
 pcic_vrip_intr(void *arg)
 {
-       struct pcic_softc       *sc = arg;
        struct pcic_vrip_softc  *vsc = arg;
+       struct pcic_softc       *sc = &vsc->sc_pcic;
        int                     i;
        uint16_t                r;
 
diff -r a9564a5fdce6 -r 7813434aeb13 sys/dev/ic/i82365.c
--- a/sys/dev/ic/i82365.c       Mon Sep 14 12:52:20 2009 +0000
+++ b/sys/dev/ic/i82365.c       Mon Sep 14 13:41:15 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: i82365.c,v 1.109 2009/09/14 12:49:33 tsutsui Exp $     */
+/*     $NetBSD: i82365.c,v 1.110 2009/09/14 13:41:15 tsutsui Exp $     */
 
 /*
  * Copyright (c) 2004 Charles M. Hannum.  All rights reserved.
@@ -49,7 +49,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i82365.c,v 1.109 2009/09/14 12:49:33 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i82365.c,v 1.110 2009/09/14 13:41:15 tsutsui Exp $");
 
 #define        PCICDEBUG
 
@@ -230,9 +230,11 @@
 {
        int i, reg, chip, socket;
        struct pcic_handle *h;
+       device_t self;
 
        DPRINTF(("pcic ident regs:"));
 
+       self = &sc->dev;
        mutex_init(&sc->sc_pcic_lock, MUTEX_DEFAULT, IPL_NONE);
 
        /* find and configure for the available sockets */
@@ -241,7 +243,7 @@
                chip = i / 2;
                socket = i % 2;
 
-               h->ph_parent = (device_t)sc;
+               h->ph_parent = self;
                h->chip = chip;
                h->socket = socket;
                h->sock = chip * PCIC_CHIP_OFFSET + socket * PCIC_SOCKET_OFFSET;
@@ -315,7 +317,7 @@
                if (h->vendor == PCIC_VENDOR_NONE)
                        continue;
 
-               aprint_normal_dev(&sc->dev, "controller %d (%s) has ",
+               aprint_normal_dev(self, "controller %d (%s) has ",
                    chip, pcic_vendor_to_string(sc->handle[i].vendor));
 
                if ((h->flags & PCIC_FLAG_SOCKETP) &&
@@ -347,7 +349,7 @@
 pcic_power(int why, void *arg)
 {
        struct pcic_handle *h = (struct pcic_handle *)arg;
-       struct pcic_softc *sc = (struct pcic_softc *)h->ph_parent;
+       struct pcic_softc *sc = device_private(h->ph_parent);
        int reg;
 
        DPRINTF(("%s: power: why %d\n", device_xname(h->ph_parent), why));
@@ -388,7 +390,7 @@
 pcic_attach_socket(struct pcic_handle *h)
 {
        struct pcmciabus_attach_args paa;
-       struct pcic_softc *sc = (struct pcic_softc *)h->ph_parent;
+       struct pcic_softc *sc = device_private(h->ph_parent);
        int locs[PCMCIABUSCF_NLOCS];
 
        /* initialize the rest of the handle */
@@ -439,7 +441,7 @@
 void
 pcic_attach_socket_finish(struct pcic_handle *h)
 {
-       struct pcic_softc *sc = (struct pcic_softc *)h->ph_parent;
+       struct pcic_softc *sc = device_private(h->ph_parent);
        int reg;
        char cs[4];
 
@@ -520,7 +522,7 @@
        struct pcic_handle *h = arg;
        struct pcic_event *pe;
        int s, first = 1;
-       struct pcic_softc *sc = (struct pcic_softc *)h->ph_parent;
+       struct pcic_softc *sc = device_private(h->ph_parent);
 
        while (h->shutdown == 0) {
                /*
@@ -797,7 +799,7 @@
        bus_addr_t addr;
        bus_size_t sizepg;
        int i, mask, mhandle;
-       struct pcic_softc *sc = (struct pcic_softc *)h->ph_parent;
+       struct pcic_softc *sc = device_private(h->ph_parent);
 
        /* out of sc->memh, allocate as many pages as necessary */
 
@@ -837,7 +839,7 @@
 pcic_chip_mem_free(pcmcia_chipset_handle_t pch, struct pcmcia_mem_handle *pcmhp)
 {
        struct pcic_handle *h = (struct pcic_handle *) pch;
-       struct pcic_softc *sc = (struct pcic_softc *)h->ph_parent;
+       struct pcic_softc *sc = device_private(h->ph_parent);
 
        sc->subregionmask |= pcmhp->mhandle;
 }
@@ -964,7 +966,7 @@
        bus_addr_t busaddr;
        long card_offset;
        int i, win;
-       struct pcic_softc *sc = (struct pcic_softc *)h->ph_parent;
+       struct pcic_softc *sc = device_private(h->ph_parent);
 
        win = -1;
        for (i = 0; i < (sizeof(mem_map_index) / sizeof(mem_map_index[0]));
@@ -1044,7 +1046,7 @@
        bus_space_handle_t ioh;
        bus_addr_t ioaddr;
        int flags = 0;
-       struct pcic_softc *sc = (struct pcic_softc *)h->ph_parent;
+       struct pcic_softc *sc = device_private(h->ph_parent);
 
        /*
         * Allocate some arbitrary I/O space.
@@ -1172,7 +1174,7 @@
 #ifdef PCICDEBUG
        static const char *width_names[] = { "auto", "io8", "io16" };
 #endif
-       struct pcic_softc *sc = (struct pcic_softc *)h->ph_parent;
+       struct pcic_softc *sc = device_private(h->ph_parent);
 
        /* XXX Sanity check offset/size. */
 
diff -r a9564a5fdce6 -r 7813434aeb13 sys/dev/isa/i82365_isa.c
--- a/sys/dev/isa/i82365_isa.c  Mon Sep 14 12:52:20 2009 +0000
+++ b/sys/dev/isa/i82365_isa.c  Mon Sep 14 13:41:15 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: i82365_isa.c,v 1.31 2009/05/12 09:10:15 cegger Exp $   */
+/*     $NetBSD: i82365_isa.c,v 1.32 2009/09/14 13:41:15 tsutsui Exp $  */
 
 /*
  * Copyright (c) 1997 Marc Horowitz.  All rights reserved.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i82365_isa.c,v 1.31 2009/05/12 09:10:15 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i82365_isa.c,v 1.32 2009/09/14 13:41:15 tsutsui Exp $");
 
 #define        PCICISADEBUG
 
@@ -184,8 +184,8 @@
 void
 pcic_isa_attach(device_t parent, device_t self, void *aux)
 {
-       struct pcic_softc *sc = (void *) self;
-       struct pcic_isa_softc *isc = (void *) self;
+       struct pcic_isa_softc *isc = device_private(self);
+       struct pcic_softc *sc = &isc->sc_pcic;
        struct isa_attach_args *ia = aux;
        isa_chipset_tag_t ic = ia->ia_ic;
        bus_space_tag_t iot = ia->ia_iot;
diff -r a9564a5fdce6 -r 7813434aeb13 sys/dev/isa/i82365_isasubr.c
--- a/sys/dev/isa/i82365_isasubr.c      Mon Sep 14 12:52:20 2009 +0000
+++ b/sys/dev/isa/i82365_isasubr.c      Mon Sep 14 13:41:15 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: i82365_isasubr.c,v 1.43 2009/05/12 09:10:15 cegger Exp $       */
+/*     $NetBSD: i82365_isasubr.c,v 1.44 2009/09/14 13:41:15 tsutsui Exp $      */
 
 /*
  * Copyright (c) 2000 Christian E. Hopps.  All rights reserved.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i82365_isasubr.c,v 1.43 2009/05/12 09:10:15 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i82365_isasubr.c,v 1.44 2009/09/14 13:41:15 tsutsui Exp $");
 
 #define        PCICISADEBUG
 
@@ -126,7 +126,7 @@
  * just use socket 0
  */
 
-void pcic_isa_probe_interrupts(struct pcic_softc *, struct pcic_handle *);
+void pcic_isa_probe_interrupts(struct pcic_isa_softc *, struct pcic_handle *);
 static int pcic_isa_count_intr(void *);
 
 static int
@@ -138,8 +138,8 @@
        int cscreg;
 
        h = arg;
-       sc = (struct pcic_softc *)h->ph_parent;
-       isc = (struct pcic_isa_softc *)h->ph_parent;
+       isc = device_private(h->ph_parent);
+       sc = &isc->sc_pcic;
 
        cscreg = pcic_read(h, PCIC_CSC);
        if (cscreg & PCIC_CSC_CD) {
@@ -176,9 +176,9 @@
  * for this controller
  */
 void
-pcic_isa_probe_interrupts(struct pcic_softc *sc, struct pcic_handle *h)
+pcic_isa_probe_interrupts(struct pcic_isa_softc *isc, struct pcic_handle *h)
 {
-       struct pcic_isa_softc *isc = (void *) sc;
+       struct pcic_softc *sc = &isc->sc_pcic;
        isa_chipset_tag_t ic;
        int i, j, mask, irq;
        int cd, cscintr, intr, csc;
@@ -277,8 +277,8 @@
        isa_chipset_tag_t ic;
        int s, i, chipmask, chipuniq;
 
-       sc = (struct pcic_softc *) self;
-       isc = (struct pcic_isa_softc *) self;
+       isc = device_private(self);
+       sc = &isc->sc_pcic;
        ic = isc->sc_ic;
 
        /* probe each controller */
@@ -297,7 +297,7 @@
                /* the cirrus chips lack support for the soft interrupt */
                if (pcic_irq_probe != 0 &&
                    h->vendor != PCIC_VENDOR_CIRRUS_PD67XX)
-                       pcic_isa_probe_interrupts(sc, h);
+                       pcic_isa_probe_interrupts(isc, h);
 
                chipmask &= sc->intr_mask[h->chip];



Home | Main Index | Thread Index | Old Index