Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/pmax/ibus Split device_t/softc. No crash during de...



details:   https://anonhg.NetBSD.org/src/rev/d473d1515f7e
branches:  trunk
changeset: 765724:d473d1515f7e
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Sat Jun 04 01:31:23 2011 +0000

description:
Split device_t/softc.  No crash during device attach on GXemul.

diffstat:

 sys/arch/pmax/ibus/pm.c     |  19 +++++----
 sys/arch/pmax/ibus/sii.c    |  87 ++++++++++++++++++++++++--------------------
 sys/arch/pmax/ibus/sii_ds.c |   7 ++-
 sys/arch/pmax/ibus/siivar.h |   4 +-
 4 files changed, 64 insertions(+), 53 deletions(-)

diffs (truncated from 413 to 300 lines):

diff -r 9c9df3cd1cd0 -r d473d1515f7e sys/arch/pmax/ibus/pm.c
--- a/sys/arch/pmax/ibus/pm.c   Sat Jun 04 01:27:57 2011 +0000
+++ b/sys/arch/pmax/ibus/pm.c   Sat Jun 04 01:31:23 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pm.c,v 1.8 2010/05/15 20:31:10 tsutsui Exp $   */
+/*     $NetBSD: pm.c,v 1.9 2011/06/04 01:31:23 tsutsui Exp $   */
 
 /*-
  * Copyright (c) 2002, 2003 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pm.c,v 1.8 2010/05/15 20:31:10 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pm.c,v 1.9 2011/06/04 01:31:23 tsutsui Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -76,7 +76,7 @@
 };
 
 struct pm_softc {
-       struct device           sc_dev;
+       device_t                sc_dev;
        size_t                  sc_cmap_size;
        size_t                  sc_fb_size;
        int                     sc_type;
@@ -89,8 +89,8 @@
 };
 #define        WSDISPLAY_CMAP_DOLUT    0x20
 
-int    pm_match(struct device *, struct cfdata *, void *);
-void   pm_attach(struct device *, struct device *, void *);
+int    pm_match(device_t, cfdata_t, void *);
+void   pm_attach(device_t, device_t, void *);
 int    pm_ioctl(void *, void *, u_long, void *, int, struct lwp *);
 paddr_t        pm_mmap(void *, void *, off_t, int);
 int    pm_alloc_screen(void *, const struct wsscreen_descr *,
@@ -110,7 +110,7 @@
 void   pm_set_curpos(struct pm_softc *, struct wsdisplay_curpos *);
 void   pm_init_cmap(struct pm_softc *);
 
-CFATTACH_DECL(pm, sizeof(struct pm_softc),
+CFATTACH_DECL_NEW(pm, sizeof(struct pm_softc),
    pm_match, pm_attach, NULL, NULL);
 
 struct rasops_info pm_ri;
@@ -142,7 +142,7 @@
 u_int  pm_creg;
 
 int
-pm_match(struct device *parent, struct cfdata *match, void *aux)
+pm_match(device_t parent, cfdata_t cf, void *aux)
 {
        struct ibus_attach_args *ia;
        void *pmaddr;
@@ -160,14 +160,15 @@
 }
 
 void
-pm_attach(struct device *parent, struct device *self, void *aux)
+pm_attach(device_t parent, device_t self, void *aux)
 {
        struct pm_softc *sc;
        struct rasops_info *ri;
        struct wsemuldisplaydev_attach_args waa;
        int console;
 
-       sc = (struct pm_softc *)self;
+       sc = device_private(self);
+       sc->sc_dev = self;
        ri = &pm_ri;
        console = (ri->ri_bits != NULL);
 
diff -r 9c9df3cd1cd0 -r d473d1515f7e sys/arch/pmax/ibus/sii.c
--- a/sys/arch/pmax/ibus/sii.c  Sat Jun 04 01:27:57 2011 +0000
+++ b/sys/arch/pmax/ibus/sii.c  Sat Jun 04 01:31:23 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sii.c,v 1.8 2009/03/18 10:22:33 cegger Exp $   */
+/*     $NetBSD: sii.c,v 1.9 2011/06/04 01:31:23 tsutsui Exp $  */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sii.c,v 1.8 2009/03/18 10:22:33 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sii.c,v 1.9 2011/06/04 01:31:23 tsutsui Exp $");
 
 #include "sii.h"
 /*
@@ -172,7 +172,7 @@
        sii_Reset(sc, RESET);
        printf(": target %d\n", sc->sc_regs->id & SII_IDMSK);
 
-       sc->sc_adapter.adapt_dev = &sc->sc_dev;
+       sc->sc_adapter.adapt_dev = sc->sc_dev;
        sc->sc_adapter.adapt_nchannels = 1;
        sc->sc_adapter.adapt_openings = 7; 
        sc->sc_adapter.adapt_max_periph = 1;
@@ -191,7 +191,7 @@
        /*
         * Now try to attach all the sub-devices
         */
-       config_found(&sc->sc_dev, &sc->sc_channel, scsiprint);
+       config_found(sc->sc_dev, &sc->sc_channel, scsiprint);
 }
 
 /*
@@ -205,11 +205,13 @@
 {
        struct scsipi_xfer *xs;
        struct scsipi_periph *periph;
-       struct siisoftc *sc = (void *)chan->chan_adapter->adapt_dev;
+       struct siisoftc *sc;
        int target;
        int s;
        int count;
 
+       sc = device_private(chan->chan_adapter->adapt_dev);
+
        switch (req) {
        case ADAPTER_REQ_RUN_XFER:
                xs = arg;
@@ -310,7 +312,7 @@
         * Set host adapter ID (from PROM sciiidN variable).
         */
        /* XXX device_unit() abuse */
-       regs->id = SII_ID_IO | prom_scsiid(device_unit(&sc->sc_dev));
+       regs->id = SII_ID_IO | prom_scsiid(device_unit(sc->sc_dev));
        /*
         * Enable SII to drive the SCSI bus.
         */
@@ -389,9 +391,9 @@
 #ifdef DEBUG
        if (sii_debug > 1) {
                printf("sii_StartCmd: %s target %d cmd 0x%x addr %p size %d DMA %d\n",
-                       sc->sc_dev.dv_xname,
-                       target, scsicmd->cmd[0], scsicmd->buf, scsicmd->buflen,
-                       state->dmaDataPhase);
+                   device_xname(sc->sc_dev),
+                   target, scsicmd->cmd[0], scsicmd->buf, scsicmd->buflen,
+                   state->dmaDataPhase);
        }
        sii_debug_cmd = scsicmd->cmd[0];
        if (scsicmd->cmd[0] == READ_10 ||
@@ -612,7 +614,8 @@
 
                /* check for a BUS RESET */
                if (cstat & SII_RST) {
-                       printf("%s: SCSI bus reset!!\n", sc->sc_dev.dv_xname);
+                       printf("%s: SCSI bus reset!!\n",
+                           device_xname(sc->sc_dev));
                        /* need to flush disconnected commands */
                        for (i = 0; i < SII_NCMD; i++) {
                                if (!sc->sc_cmd[i])
@@ -660,9 +663,9 @@
                if (sc->sc_target < 0) {
                        cstat = regs->cstat;
                        printf("%s: target %d DNE?? dev %d,%d cs %x\n",
-                               sc->sc_dev.dv_xname, sc->sc_target,
-                               regs->slcsr, regs->destat,
-                               cstat); /* XXX */
+                           device_xname(sc->sc_dev), sc->sc_target,
+                           regs->slcsr, regs->destat,
+                           cstat); /* XXX */
                        if (cstat & SII_DST) {
                                sc->sc_target = regs->destat;
                                state = &sc->sc_st[sc->sc_target];
@@ -674,7 +677,8 @@
                /* check for a PARITY ERROR */
                if (dstat & SII_IPE) {
                        state->flags |= PARITY_ERR;
-                       printf("%s: Parity error!!\n", sc->sc_dev.dv_xname);
+                       printf("%s: Parity error!!\n",
+                           device_xname(sc->sc_dev));
                        goto abort;
                }
                /* dmalen = amount left to transfer, i = amount transfered */
@@ -688,7 +692,8 @@
                                printf("no TCZ?? (%d) ", regs->dmlotc);
                } else if (!(dstat & SII_TCZ)) {
                        printf("%s: device %d: no TCZ?? (%d)\n",
-                               sc->sc_dev.dv_xname, sc->sc_target, regs->dmlotc);
+                           device_xname(sc->sc_dev),
+                           sc->sc_target, regs->dmlotc);
                        sii_DumpLog(); /* XXX */
                }
 #endif
@@ -768,9 +773,9 @@
                if (sc->sc_target < 0) {
                        cstat = regs->cstat;
                        printf("%s: target %d MIS?? dev %d,%d cs %x ds %x\n",
-                               sc->sc_dev.dv_xname, sc->sc_target,
-                               regs->slcsr, regs->destat,
-                               cstat, dstat); /* XXX */
+                           device_xname(sc->sc_dev), sc->sc_target,
+                           regs->slcsr, regs->destat,
+                           cstat, dstat); /* XXX */
                        if (cstat & SII_DST) {
                                sc->sc_target = regs->destat;
                                state = &sc->sc_st[sc->sc_target];
@@ -789,7 +794,8 @@
                                /* restart DMA after disconnect/reconnect */
                                if (state->dmaPrevPhase != SII_CMD_PHASE) {
                                        printf("%s: device %d: DMA reselect phase doesn't match\n",
-                                               sc->sc_dev.dv_xname, sc->sc_target);
+                                           device_xname(sc->sc_dev),
+                                           sc->sc_target);
                                        goto abort;
                                }
                                state->dmaCurPhase = SII_CMD_PHASE;
@@ -814,7 +820,8 @@
                                i = state->cmdlen;
                                if (i == 0) {
                                        printf("%s: device %d: cmd count exceeded\n",
-                                               sc->sc_dev.dv_xname, sc->sc_target);
+                                           device_xname(sc->sc_dev),
+                                           sc->sc_target);
                                        goto abort;
                                }
                                sc->sii_copytobuf((u_short *)state->cmd,
@@ -843,9 +850,9 @@
                case SII_DATA_OUT_PHASE:
                        if (state->cmdlen > 0) {
                                printf("%s: device %d: cmd %x: command data not all sent (%d) 1\n",
-                                       sc->sc_dev.dv_xname, sc->sc_target,
-                                       sc->sc_cmd[sc->sc_target]->cmd[0],
-                                       state->cmdlen);
+                                   device_xname(sc->sc_dev), sc->sc_target,
+                                   sc->sc_cmd[sc->sc_target]->cmd[0],
+                                   state->cmdlen);
                                state->cmdlen = 0;
 #ifdef DEBUG
                                sii_DumpLog();
@@ -856,7 +863,8 @@
                                if (state->dmaPrevPhase !=
                                    (dstat & SII_PHASE_MSK)) {
                                        printf("%s: device %d: DMA reselect phase doesn't match\n",
-                                               sc->sc_dev.dv_xname, sc->sc_target);
+                                           device_xname(sc->sc_dev),
+                                           sc->sc_target);
                                        goto abort;
                                }
                                state->dmaCurPhase = state->dmaPrevPhase;
@@ -890,7 +898,7 @@
                        i = state->buflen;
                        if (i == 0) {
                                printf("%s: device %d: data count exceeded\n",
-                                       sc->sc_dev.dv_xname, sc->sc_target);
+                                   device_xname(sc->sc_dev), sc->sc_target);
                                goto abort;
                        }
                        if (i > SII_MAX_DMA_XFER_LENGTH)
@@ -928,9 +936,9 @@
                case SII_STATUS_PHASE:
                        if (state->cmdlen > 0) {
                                printf("%s: device %d: cmd %x: command data not all sent (%d) 2\n",
-                                       sc->sc_dev.dv_xname, sc->sc_target,
-                                       sc->sc_cmd[sc->sc_target]->cmd[0],
-                                       state->cmdlen);
+                                   device_xname(sc->sc_dev), sc->sc_target,
+                                   sc->sc_cmd[sc->sc_target]->cmd[0],
+                                   state->cmdlen);
                                state->cmdlen = 0;
 #ifdef DEBUG
                                sii_DumpLog();
@@ -1277,14 +1285,15 @@
                                regs->dstat = SII_DNE;
                                wbflush();
                                printf("%s: device %d: message reject.\n",
-                                       sc->sc_dev.dv_xname, sc->sc_target);
+                                   device_xname(sc->sc_dev), sc->sc_target);
                                break;
 
                        default:
                                if (!(msg & MSG_IDENTIFYFLAG)) {
                                        printf("%s: device %d: couldn't handle "
                                            "message 0x%x... rejecting.\n",
-                                           sc->sc_dev.dv_xname, sc->sc_target,
+                                           device_xname(sc->sc_dev),
+                                           sc->sc_target,
                                            msg);
 #ifdef DEBUG
                                        sii_DumpLog();
@@ -1350,7 +1359,7 @@
 
                default:
                        printf("%s: Couldn't handle phase %d... ignoring.\n",
-                                  sc->sc_dev.dv_xname, dstat & SII_PHASE_MSK);
+                           device_xname(sc->sc_dev), dstat & SII_PHASE_MSK);
                }
        }
 
@@ -1383,7 +1392,7 @@
 abort:
        /* jump here to abort the current command */
        printf("%s: device %d: current command terminated\n",
-               sc->sc_dev.dv_xname, sc->sc_target);



Home | Main Index | Thread Index | Old Index