Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/luna68k/dev - split device_t/softc and use device_t...



details:   https://anonhg.NetBSD.org/src/rev/25930dbad736
branches:  trunk
changeset: 767684:25930dbad736
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Wed Jul 27 11:54:40 2011 +0000

description:
- split device_t/softc and use device_t and cfdata_t etc.
- use aprint_normal(9)
- include "ioconf.h" for struct cfdriver decls
No crash on LUNA.

diffstat:

 sys/arch/luna68k/dev/lunafb.c     |  25 ++++++++++++++-----------
 sys/arch/luna68k/dev/lunaws.c     |  26 ++++++++++++++------------
 sys/arch/luna68k/dev/sio.c        |  22 ++++++++++++----------
 sys/arch/luna68k/dev/siotty.c     |  26 ++++++++++++++------------
 sys/arch/luna68k/dev/siovar.h     |   4 ++--
 sys/arch/luna68k/dev/timekeeper.c |  27 +++++++++++++++------------
 6 files changed, 71 insertions(+), 59 deletions(-)

diffs (truncated from 436 to 300 lines):

diff -r ede2fec4452a -r 25930dbad736 sys/arch/luna68k/dev/lunafb.c
--- a/sys/arch/luna68k/dev/lunafb.c     Wed Jul 27 10:25:09 2011 +0000
+++ b/sys/arch/luna68k/dev/lunafb.c     Wed Jul 27 11:54:40 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lunafb.c,v 1.23 2011/07/21 10:33:17 tsutsui Exp $ */
+/* $NetBSD: lunafb.c,v 1.24 2011/07/27 11:54:40 tsutsui Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include <sys/cdefs.h>                 /* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: lunafb.c,v 1.23 2011/07/21 10:33:17 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lunafb.c,v 1.24 2011/07/27 11:54:40 tsutsui Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -55,6 +55,8 @@
 #include <machine/cpu.h>
 #include <machine/autoconf.h>
 
+#include "ioconf.h"
+
 struct bt454 {
        volatile u_int8_t bt_addr;      /* map address register */
        volatile u_int8_t bt_cmap;      /* colormap data register */
@@ -98,7 +100,7 @@
 };
 
 struct omfb_softc {
-       struct device sc_dev;           /* base device */
+       device_t sc_dev;                /* base device */
        struct om_hwdevconfig *sc_dc;   /* device configuration */
        struct hwcmap sc_cmap;          /* software copy of colormap */
        int nscreens;
@@ -145,12 +147,11 @@
        0 /* load_font */
 };
 
-static int  omfbmatch(struct device *, struct cfdata *, void *);
-static void omfbattach(struct device *, struct device *, void *);
+static int  omfbmatch(device_t, cfdata_t, void *);
+static void omfbattach(device_t, device_t, void *);
 
-CFATTACH_DECL(fb, sizeof(struct omfb_softc),
+CFATTACH_DECL_NEW(fb, sizeof(struct omfb_softc),
     omfbmatch, omfbattach, NULL, NULL);
-extern struct cfdriver fb_cd;
 
 extern int hwplanemask;        /* hardware planemask; retrieved at boot */
 
@@ -158,7 +159,7 @@
 int  omfb_cnattach(void);
 
 static int
-omfbmatch(struct device *parent, struct cfdata *cf, void *aux)
+omfbmatch(device_t parent, cfdata_t cf, void *aux)
 {
        struct mainbus_attach_args *ma = aux;
 
@@ -175,11 +176,13 @@
 }
 
 static void
-omfbattach(struct device *parent, struct device *self, void *args)
+omfbattach(device_t parent, device_t self, void *args)
 {
-       struct omfb_softc *sc = (struct omfb_softc *)self;
+       struct omfb_softc *sc = device_private(self);
        struct wsemuldisplaydev_attach_args waa;
 
+       sc->sc_dev = self;
+
        if (omfb_console) {
                sc->sc_dc = &omfb_console_dc;
                sc->nscreens = 1;
@@ -189,7 +192,7 @@
                    malloc(sizeof(struct om_hwdevconfig), M_DEVBUF, M_WAITOK);
                omfb_getdevconfig(OMFB_FB_WADDR, sc->sc_dc);
        }
-       printf(": %d x %d, %dbpp\n", sc->sc_dc->dc_wid, sc->sc_dc->dc_ht,
+       aprint_normal(": %d x %d, %dbpp\n", sc->sc_dc->dc_wid, sc->sc_dc->dc_ht,
            sc->sc_dc->dc_depth);
 
        /* WHITE on BLACK */
diff -r ede2fec4452a -r 25930dbad736 sys/arch/luna68k/dev/lunaws.c
--- a/sys/arch/luna68k/dev/lunaws.c     Wed Jul 27 10:25:09 2011 +0000
+++ b/sys/arch/luna68k/dev/lunaws.c     Wed Jul 27 11:54:40 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lunaws.c,v 1.21 2011/07/21 10:33:17 tsutsui Exp $ */
+/* $NetBSD: lunaws.c,v 1.22 2011/07/27 11:54:40 tsutsui Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include <sys/cdefs.h>                 /* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: lunaws.c,v 1.21 2011/07/21 10:33:17 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lunaws.c,v 1.22 2011/07/27 11:54:40 tsutsui Exp $");
 
 #include "wsmouse.h"
 
@@ -49,6 +49,8 @@
 #include <luna68k/dev/sioreg.h>
 #include <luna68k/dev/siovar.h>
 
+#include "ioconf.h"
+
 static const u_int8_t ch1_regs[6] = {
        WR0_RSTINT,                             /* Reset E/S Interrupt */
        WR1_RXALLS,                             /* Rx per char, No Tx */
@@ -59,7 +61,7 @@
 };
 
 struct ws_softc {
-       struct device   sc_dv;
+       device_t        sc_dev;
        struct sioreg   *sc_ctl;
        u_int8_t        sc_wr[6];
        struct device   *sc_wskbddev;
@@ -110,18 +112,17 @@
 
 static void wsintr(int);
 
-static int  wsmatch(struct device *, struct cfdata *, void *);
-static void wsattach(struct device *, struct device *, void *);
+static int  wsmatch(device_t, cfdata_t, void *);
+static void wsattach(device_t, device_t, void *);
 
-CFATTACH_DECL(ws, sizeof(struct ws_softc),
+CFATTACH_DECL_NEW(ws, sizeof(struct ws_softc),
     wsmatch, wsattach, NULL, NULL);
-extern struct cfdriver ws_cd;
 
 extern int  syscngetc(dev_t);
 extern void syscnputc(dev_t, int);
 
 static int
-wsmatch(struct device *parent, struct cfdata *match, void *aux)
+wsmatch(device_t parent, cfdata_t cf, void *aux)
 {
        struct sio_attach_args *args = aux;
 
@@ -131,13 +132,14 @@
 }
 
 static void
-wsattach(struct device *parent, struct device *self, void *aux)
+wsattach(device_t parent, device_t self, void *aux)
 {
-       struct ws_softc *sc = (struct ws_softc *)self;
-       struct sio_softc *scp = (struct sio_softc *)parent;
+       struct ws_softc *sc = device_private(self);
+       struct sio_softc *scp = device_private(parent);
        struct sio_attach_args *args = aux;
        struct wskbddev_attach_args a;
 
+       sc->sc_dev = self;
        sc->sc_ctl = (struct sioreg *)scp->scp_ctl + 1;
        memcpy(sc->sc_wr, ch1_regs, sizeof(ch1_regs));
        scp->scp_intr[1] = wsintr;
@@ -151,7 +153,7 @@
 
        syscnputc((dev_t)1, 0x20); /* keep quiet mouse */
 
-       printf("\n");
+       aprint_normal("\n");
 
        a.console = (args->hwflags == 1);
        a.keymap = &omkbd_keymapdata;
diff -r ede2fec4452a -r 25930dbad736 sys/arch/luna68k/dev/sio.c
--- a/sys/arch/luna68k/dev/sio.c        Wed Jul 27 10:25:09 2011 +0000
+++ b/sys/arch/luna68k/dev/sio.c        Wed Jul 27 11:54:40 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sio.c,v 1.8 2009/03/14 21:04:11 dsl Exp $ */
+/* $NetBSD: sio.c,v 1.9 2011/07/27 11:54:40 tsutsui Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include <sys/cdefs.h>                 /* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: sio.c,v 1.8 2009/03/14 21:04:11 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sio.c,v 1.9 2011/07/27 11:54:40 tsutsui Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -43,19 +43,20 @@
 #include <luna68k/luna68k/isr.h>
 #include <luna68k/dev/siovar.h>
 
-static int  sio_match(struct device *, struct cfdata *, void *);
-static void sio_attach(struct device *, struct device *, void *);
+#include "ioconf.h"
+
+static int  sio_match(device_t, cfdata_t, void *);
+static void sio_attach(device_t, device_t, void *);
 static int  sio_print(void *, const char *);
 
-CFATTACH_DECL(sio, sizeof(struct sio_softc),
+CFATTACH_DECL_NEW(sio, sizeof(struct sio_softc),
     sio_match, sio_attach, NULL, NULL);
-extern struct cfdriver sio_cd;
 
 static void nullintr(int);
 static int xsiointr(void *);
 
 static int
-sio_match(struct device *parent, struct cfdata *cf, void *aux)
+sio_match(device_t parent, cfdata_t cf, void *aux)
 {
        struct mainbus_attach_args *ma = aux;
 
@@ -67,16 +68,17 @@
 }
 
 static void
-sio_attach(struct device *parent, struct device *self, void *aux)
+sio_attach(device_t parent, device_t self, void *aux)
 {
-       struct sio_softc *sc = (void *)self;
+       struct sio_softc *sc = device_private(self);
        struct mainbus_attach_args *ma = aux;
        struct sio_attach_args sio_args;
        int channel;
        extern int sysconsole; /* console: 0 for ttya, 1 for desktop */
 
-       printf(": 7201a\n");
+       aprint_normal(": 7201a\n");
 
+       sc->scp_dev = self;
        sc->scp_ctl = (void *)ma->ma_addr;
        sc->scp_intr[0] = sc->scp_intr[1] = nullintr;
        for (channel = 0; channel < 2; channel++) {
diff -r ede2fec4452a -r 25930dbad736 sys/arch/luna68k/dev/siotty.c
--- a/sys/arch/luna68k/dev/siotty.c     Wed Jul 27 10:25:09 2011 +0000
+++ b/sys/arch/luna68k/dev/siotty.c     Wed Jul 27 11:54:40 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: siotty.c,v 1.30 2011/04/24 16:26:56 rmind Exp $ */
+/* $NetBSD: siotty.c,v 1.31 2011/07/27 11:54:40 tsutsui Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include <sys/cdefs.h>                 /* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: siotty.c,v 1.30 2011/04/24 16:26:56 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: siotty.c,v 1.31 2011/07/27 11:54:40 tsutsui Exp $");
 
 #include "opt_ddb.h"
 
@@ -53,6 +53,8 @@
 #include <luna68k/dev/sioreg.h>
 #include <luna68k/dev/siovar.h>
 
+#include "ioconf.h"
+
 #define        TIOCM_BREAK 01000 /* non standard use */
 
 static const u_int8_t ch0_regs[6] = {
@@ -72,7 +74,7 @@
 };
 
 struct siotty_softc {
-       struct device   sc_dev;
+       device_t        sc_dev;
        struct tty      *sc_tty;
        struct sioreg   *sc_ctl;
        u_int           sc_flags;
@@ -85,12 +87,11 @@
 static void siottyintr(int);
 static int  siomctl(struct siotty_softc *, int, int);
 
-static int  siotty_match(struct device *, struct cfdata *, void *);
-static void siotty_attach(struct device *, struct device *, void *);
+static int  siotty_match(device_t, cfdata_t, void *);
+static void siotty_attach(device_t, device_t, void *);
 
-CFATTACH_DECL(siotty, sizeof(struct siotty_softc),
+CFATTACH_DECL_NEW(siotty, sizeof(struct siotty_softc),
     siotty_match, siotty_attach, NULL, NULL);
-extern struct cfdriver siotty_cd;
 
 dev_type_open(sioopen);
 dev_type_close(sioclose);
@@ -107,7 +108,7 @@
 };
 
 static int 
-siotty_match(struct device *parent, struct cfdata *cf, void *aux)
+siotty_match(device_t parent, cfdata_t cf, void *aux)
 {
        struct sio_attach_args *args = aux;
 
@@ -119,16 +120,17 @@
 static void 



Home | Main Index | Thread Index | Old Index