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 Misc cleanup of sio drivers.



details:   https://anonhg.NetBSD.org/src/rev/99c06b167f5a
branches:  trunk
changeset: 326554:99c06b167f5a
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Sun Feb 02 15:35:06 2014 +0000

description:
Misc cleanup of sio drivers.

- register softc of child devices as an argument of the sio interrupt
  handler to avoid device_lookup_private() calls on every interrupt
- change type of sc_reg from (void *) to (struct sioreg *)
  to avoid weird address offset calculations with redundant casts
- rename struct sio_softc members for consistency
- use a channel number passed via sio_attach_args in lunaws_attach()

No functional chnages.  Tested on LUNA.

diffstat:

 sys/arch/luna68k/dev/lunaws.c |  18 ++++++++++--------
 sys/arch/luna68k/dev/sio.c    |  22 +++++++++++++---------
 sys/arch/luna68k/dev/siotty.c |  22 +++++++++++-----------
 sys/arch/luna68k/dev/siovar.h |  17 ++++++++++-------
 4 files changed, 44 insertions(+), 35 deletions(-)

diffs (227 lines):

diff -r 204d520e6c2a -r 99c06b167f5a sys/arch/luna68k/dev/lunaws.c
--- a/sys/arch/luna68k/dev/lunaws.c     Sun Feb 02 14:54:39 2014 +0000
+++ b/sys/arch/luna68k/dev/lunaws.c     Sun Feb 02 15:35:06 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lunaws.c,v 1.27 2013/09/23 17:27:09 tsutsui Exp $ */
+/* $NetBSD: lunaws.c,v 1.28 2014/02/02 15:35:06 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.27 2013/09/23 17:27:09 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lunaws.c,v 1.28 2014/02/02 15:35:06 tsutsui Exp $");
 
 #include "wsmouse.h"
 
@@ -118,7 +118,7 @@
 };
 #endif
 
-static void wsintr(int);
+static void wsintr(void *);
 static void wssoftintr(void *);
 
 static int  wsmatch(device_t, cfdata_t, void *);
@@ -144,14 +144,16 @@
 wsattach(device_t parent, device_t self, void *aux)
 {
        struct ws_softc *sc = device_private(self);
-       struct sio_softc *scp = device_private(parent);
+       struct sio_softc *siosc = device_private(parent);
        struct sio_attach_args *args = aux;
+       int channel = args->channel;
        struct wskbddev_attach_args a;
 
        sc->sc_dev = self;
-       sc->sc_ctl = (struct sioreg *)scp->scp_ctl + 1;
+       sc->sc_ctl = &siosc->sc_ctl[channel];
        memcpy(sc->sc_wr, ch1_regs, sizeof(ch1_regs));
-       scp->scp_intr[1] = wsintr;
+       siosc->sc_intrhand[channel].ih_func = wsintr;
+       siosc->sc_intrhand[channel].ih_arg = sc;
 
        setsioreg(sc->sc_ctl, WR0, sc->sc_wr[WR0]);
        setsioreg(sc->sc_ctl, WR4, sc->sc_wr[WR4]);
@@ -189,9 +191,9 @@
 
 /*ARGSUSED*/
 static void
-wsintr(int chan)
+wsintr(void *arg)
 {
-       struct ws_softc *sc = device_lookup_private(&ws_cd, 0);
+       struct ws_softc *sc = arg;
        struct sioreg *sio = sc->sc_ctl;
        uint8_t code;
        int rr;
diff -r 204d520e6c2a -r 99c06b167f5a sys/arch/luna68k/dev/sio.c
--- a/sys/arch/luna68k/dev/sio.c        Sun Feb 02 14:54:39 2014 +0000
+++ b/sys/arch/luna68k/dev/sio.c        Sun Feb 02 15:35:06 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sio.c,v 1.12 2013/09/23 17:27:09 tsutsui Exp $ */
+/* $NetBSD: sio.c,v 1.13 2014/02/02 15:35:06 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.12 2013/09/23 17:27:09 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sio.c,v 1.13 2014/02/02 15:35:06 tsutsui Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -52,7 +52,7 @@
 CFATTACH_DECL_NEW(sio, sizeof(struct sio_softc),
     sio_match, sio_attach, NULL, NULL);
 
-static void nullintr(int);
+static void nullintr(void *);
 static int xsiointr(void *);
 
 static int
@@ -78,10 +78,10 @@
 
        aprint_normal(": uPD7201A\n");
 
-       sc->scp_dev = self;
-       sc->scp_ctl = (void *)ma->ma_addr;
-       sc->scp_intr[0] = sc->scp_intr[1] = nullintr;
+       sc->sc_dev = self;
+       sc->sc_ctl = (void *)ma->ma_addr;
        for (channel = 0; channel < 2; channel++) {
+               sc->sc_intrhand[channel].ih_func = nullintr;
                sio_args.channel = channel;
                sio_args.hwflags = (channel == sysconsole);
                config_found(self, (void *)&sio_args, sio_print);
@@ -109,12 +109,16 @@
 {
        struct sio_softc *sc = arg;
 
-       (*sc->scp_intr[0])(0);  /* 0: ttya system serial port */
-       (*sc->scp_intr[1])(1);  /* 1: keyboard and mouse */
+       /* channel 0: ttya system serial port */
+       (*sc->sc_intrhand[0].ih_func)(sc->sc_intrhand[0].ih_arg);
+
+       /* channel 1: keyboard and mouse */
+       (*sc->sc_intrhand[1].ih_func)(sc->sc_intrhand[1].ih_arg);
+
        return 1;
 }
 
 static void
-nullintr(int v)
+nullintr(void *arg)
 {
 }
diff -r 204d520e6c2a -r 99c06b167f5a sys/arch/luna68k/dev/siotty.c
--- a/sys/arch/luna68k/dev/siotty.c     Sun Feb 02 14:54:39 2014 +0000
+++ b/sys/arch/luna68k/dev/siotty.c     Sun Feb 02 15:35:06 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: siotty.c,v 1.38 2014/01/02 03:32:35 tsutsui Exp $ */
+/* $NetBSD: siotty.c,v 1.39 2014/02/02 15:35:06 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.38 2014/01/02 03:32:35 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: siotty.c,v 1.39 2014/02/02 15:35:06 tsutsui Exp $");
 
 #include "opt_ddb.h"
 
@@ -106,7 +106,7 @@
 #include "siotty.h"
 static void siostart(struct tty *);
 static int  sioparam(struct tty *, struct termios *);
-static void siottyintr(int);
+static void siottyintr(void *);
 static void siottysoft(void *);
 static void siotty_rxsoft(struct siotty_softc *, struct tty *);
 static void siotty_txsoft(struct siotty_softc *, struct tty *);
@@ -145,15 +145,18 @@
 static void
 siotty_attach(device_t parent, device_t self, void *aux)
 {
-       struct sio_softc *scp = device_private(parent);
+       struct sio_softc *siosc = device_private(parent);
        struct siotty_softc *sc = device_private(self);
        struct sio_attach_args *args = aux;
+       int channel;
        struct tty *tp;
 
        sc->sc_dev = self;
-       sc->sc_ctl = (struct sioreg *)scp->scp_ctl + args->channel;
+       channel = args->channel;
+       sc->sc_ctl = &siosc->sc_ctl[channel];
        memcpy(sc->sc_wr, ch0_regs, sizeof(ch0_regs));
-       scp->scp_intr[args->channel] = siottyintr;
+       siosc->sc_intrhand[channel].ih_func = siottyintr;
+       siosc->sc_intrhand[channel].ih_arg = sc;
        if (args->hwflags == 1)
                sc->sc_hwflags |= SIOTTY_HW_CONSOLE;
 
@@ -199,7 +202,7 @@
 /*--------------------  low level routine --------------------*/
 
 static void
-siottyintr(int chan)
+siottyintr(void *arg)
 {
        struct siotty_softc *sc;
        struct sioreg *sio;
@@ -208,10 +211,7 @@
        uint16_t rr;
        int cc;
 
-       sc = device_lookup_private(&siotty_cd, chan);
-       if (sc == NULL)
-               return;
-
+       sc = arg;
        end = sc->sc_rbufend;
        put = sc->sc_rbput;
        cc = sc->sc_rbavail;
diff -r 204d520e6c2a -r 99c06b167f5a sys/arch/luna68k/dev/siovar.h
--- a/sys/arch/luna68k/dev/siovar.h     Sun Feb 02 14:54:39 2014 +0000
+++ b/sys/arch/luna68k/dev/siovar.h     Sun Feb 02 15:35:06 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: siovar.h,v 1.7 2013/12/31 14:24:09 tsutsui Exp $ */
+/* $NetBSD: siovar.h,v 1.8 2014/02/02 15:35:06 tsutsui Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -29,12 +29,6 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
-struct sio_softc {
-       device_t scp_dev;
-       void *scp_ctl;
-       void (*scp_intr[2])(int);
-};
-
 struct sio_attach_args {
        int channel;
        int hwflags;
@@ -48,5 +42,14 @@
 #define sio_stat sio_cmd
 };
 
+struct sio_softc {
+       device_t sc_dev;
+       struct sioreg *sc_ctl;
+       struct {
+               void (*ih_func)(void *);
+               void *ih_arg;
+       } sc_intrhand[2];
+};
+
 uint16_t getsiocsr(struct sioreg *);
 void setsioreg(struct sioreg *, int, int);



Home | Main Index | Thread Index | Old Index