Source-Changes-HG archive

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

[src/trunk]: src/sys/arch Fix device_t/softc split botches that could be fata...



details:   https://anonhg.NetBSD.org/src/rev/f385029a41b8
branches:  trunk
changeset: 781964:f385029a41b8
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Wed Oct 10 16:51:50 2012 +0000

description:
Fix device_t/softc split botches that could be fatal.  From
Chuck Silvers' patch posted current-users and tech-kern:
http://mail-index.netbsd.org/current-users/2012/10/09/msg021233.html

Should be pulled up to netbsd-6.

diffstat:

 sys/arch/sparc/dev/fd.c       |  20 ++++++++++----------
 sys/arch/sparc/sparc/memecc.c |   6 +++---
 sys/arch/x68k/dev/mha.c       |  10 +++++-----
 3 files changed, 18 insertions(+), 18 deletions(-)

diffs (162 lines):

diff -r b1c043e4dc25 -r f385029a41b8 sys/arch/sparc/dev/fd.c
--- a/sys/arch/sparc/dev/fd.c   Wed Oct 10 16:51:10 2012 +0000
+++ b/sys/arch/sparc/dev/fd.c   Wed Oct 10 16:51:50 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fd.c,v 1.150 2011/07/17 23:18:23 mrg Exp $     */
+/*     $NetBSD: fd.c,v 1.151 2012/10/10 16:51:50 tsutsui Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -101,7 +101,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fd.c,v 1.150 2011/07/17 23:18:23 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fd.c,v 1.151 2012/10/10 16:51:50 tsutsui Exp $");
 
 #include "opt_ddb.h"
 #include "opt_md.h"
@@ -174,7 +174,7 @@
 
 /* software state, per controller */
 struct fdc_softc {
-       struct device   *sc_dev;
+       device_t        sc_dev;
        bus_space_tag_t sc_bustag;
 
        struct callout sc_timo_ch;      /* timeout callout */
@@ -259,7 +259,7 @@
 
 /* software state, per disk (with up to 4 disks per ctlr) */
 struct fd_softc {
-       struct device   *sc_dv;         /* generic device info */
+       device_t        sc_dv;          /* generic device info */
        struct disk     sc_dk;          /* generic disk info */
 
        struct fd_type *sc_deftype;     /* default type descriptor */
@@ -342,7 +342,7 @@
 void   fdfinish(struct fd_softc *, struct buf *);
 int    fdformat(dev_t, struct ne7_fd_formb *, struct proc *);
 void   fd_do_eject(struct fd_softc *);
-void   fd_mountroot_hook(struct device *);
+void   fd_mountroot_hook(device_t);
 static int fdconf(struct fdc_softc *);
 static void establish_chip_type(
                struct fdc_softc *,
@@ -547,7 +547,7 @@
                        ma->ma_size,
                        BUS_SPACE_MAP_LINEAR,
                        &fdc->sc_handle) != 0) {
-               printf("%s: cannot map registers\n", self->dv_xname);
+               printf("%s: cannot map registers\n", device_xname(self));
                return;
        }
 
@@ -580,7 +580,7 @@
                         sa->sa_slot, sa->sa_offset, sa->sa_size,
                         BUS_SPACE_MAP_LINEAR, &fdc->sc_handle) != 0) {
                printf("%s: cannot map control registers\n",
-                       self->dv_xname);
+                       device_xname(self));
                return;
        }
 
@@ -890,7 +890,7 @@
                fdstart(fd);
 #ifdef DIAGNOSTIC
        else {
-               struct fdc_softc *fdc = (void *)device_parent(fd->sc_dv);
+               struct fdc_softc *fdc = device_private(device_parent(fd->sc_dv));
                if (fdc->sc_state == DEVIDLE) {
                        printf("fdstrategy: controller inactive\n");
                        fdcstart(fdc);
@@ -1012,7 +1012,7 @@
 
        s = splbio();
        fd->sc_flags &= ~(FD_MOTOR | FD_MOTOR_WAIT);
-       fd_set_motor((struct fdc_softc *)device_parent(fd->sc_dv));
+       fd_set_motor(device_private(device_parent(fd->sc_dv)));
        splx(s);
 }
 
@@ -2305,7 +2305,7 @@
 
 /* ARGSUSED */
 void
-fd_mountroot_hook(struct device *dev)
+fd_mountroot_hook(device_t dev)
 {
        int c;
 
diff -r b1c043e4dc25 -r f385029a41b8 sys/arch/sparc/sparc/memecc.c
--- a/sys/arch/sparc/sparc/memecc.c     Wed Oct 10 16:51:10 2012 +0000
+++ b/sys/arch/sparc/sparc/memecc.c     Wed Oct 10 16:51:50 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: memecc.c,v 1.14 2012/07/29 00:04:05 matt Exp $ */
+/*     $NetBSD: memecc.c,v 1.15 2012/10/10 16:51:51 tsutsui Exp $      */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: memecc.c,v 1.14 2012/07/29 00:04:05 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: memecc.c,v 1.15 2012/10/10 16:51:51 tsutsui Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -75,7 +75,7 @@
 void
 memecc_attach(device_t parent, device_t self, void *aux)
 {
-       struct memecc_softc *sc = (struct memecc_softc *)self;
+       struct memecc_softc *sc = device_private(self);
        struct mainbus_attach_args *ma = aux;
        int node;
        uint32_t reg;
diff -r b1c043e4dc25 -r f385029a41b8 sys/arch/x68k/dev/mha.c
--- a/sys/arch/x68k/dev/mha.c   Wed Oct 10 16:51:10 2012 +0000
+++ b/sys/arch/x68k/dev/mha.c   Wed Oct 10 16:51:50 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mha.c,v 1.52 2009/11/23 00:11:45 rmind Exp $   */
+/*     $NetBSD: mha.c,v 1.53 2012/10/10 16:55:50 tsutsui Exp $ */
 
 /*-
  * Copyright (c) 1996-1999 The NetBSD Foundation, Inc.
@@ -59,7 +59,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mha.c,v 1.52 2009/11/23 00:11:45 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mha.c,v 1.53 2012/10/10 16:55:50 tsutsui Exp $");
 
 #include "opt_ddb.h"
 
@@ -337,7 +337,7 @@
        /*
         * Fill in the adapter.
         */
-       sc->sc_adapter.adapt_dev = sc->sc_dev;
+       sc->sc_adapter.adapt_dev = self;
        sc->sc_adapter.adapt_nchannels = 1;
        sc->sc_adapter.adapt_openings = 7;
        sc->sc_adapter.adapt_max_periph = 1;
@@ -674,7 +674,7 @@
 {
        struct scsipi_xfer *xs;
        struct scsipi_periph *periph;
-       struct mha_softc *sc = (void *)chan->chan_adapter->adapt_dev;
+       struct mha_softc *sc = device_private(chan->chan_adapter->adapt_dev);
        struct acb *acb;
        int s, flags;
 
@@ -1949,7 +1949,7 @@
        struct scsipi_xfer *xs = acb->xs;
        struct scsipi_periph *periph = xs->xs_periph;
        struct mha_softc *sc =
-           (void *)periph->periph_channel->chan_adapter->adapt_dev;
+           device_private(periph->periph_channel->chan_adapter->adapt_dev);
        int s;
 
        s = splbio();



Home | Main Index | Thread Index | Old Index