Module Name: src
Committed By: tsutsui
Date: Sun Feb 2 15:35:06 UTC 2014
Modified Files:
src/sys/arch/luna68k/dev: lunaws.c sio.c siotty.c siovar.h
Log Message:
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.
To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/luna68k/dev/lunaws.c
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/luna68k/dev/sio.c
cvs rdiff -u -r1.38 -r1.39 src/sys/arch/luna68k/dev/siotty.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/luna68k/dev/siovar.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/luna68k/dev/lunaws.c
diff -u src/sys/arch/luna68k/dev/lunaws.c:1.27 src/sys/arch/luna68k/dev/lunaws.c:1.28
--- src/sys/arch/luna68k/dev/lunaws.c:1.27 Mon Sep 23 17:27:09 2013
+++ src/sys/arch/luna68k/dev/lunaws.c Sun Feb 2 15:35:06 2014
@@ -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 @@ static const struct wsmouse_accessops om
};
#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 @@ static void
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 @@ wsattach(device_t parent, device_t self,
/*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;
Index: src/sys/arch/luna68k/dev/sio.c
diff -u src/sys/arch/luna68k/dev/sio.c:1.12 src/sys/arch/luna68k/dev/sio.c:1.13
--- src/sys/arch/luna68k/dev/sio.c:1.12 Mon Sep 23 17:27:09 2013
+++ src/sys/arch/luna68k/dev/sio.c Sun Feb 2 15:35:06 2014
@@ -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 @@ static int sio_print(void *, const char
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 @@ sio_attach(device_t parent, device_t sel
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 @@ xsiointr(void *arg)
{
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)
{
}
Index: src/sys/arch/luna68k/dev/siotty.c
diff -u src/sys/arch/luna68k/dev/siotty.c:1.38 src/sys/arch/luna68k/dev/siotty.c:1.39
--- src/sys/arch/luna68k/dev/siotty.c:1.38 Thu Jan 2 03:32:35 2014
+++ src/sys/arch/luna68k/dev/siotty.c Sun Feb 2 15:35:06 2014
@@ -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 @@ static struct cnm_state siotty_cnm_state
#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 @@ siotty_match(device_t parent, cfdata_t c
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 @@ siotty_attach(device_t parent, device_t
/*-------------------- low level routine --------------------*/
static void
-siottyintr(int chan)
+siottyintr(void *arg)
{
struct siotty_softc *sc;
struct sioreg *sio;
@@ -208,10 +211,7 @@ siottyintr(int chan)
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;
Index: src/sys/arch/luna68k/dev/siovar.h
diff -u src/sys/arch/luna68k/dev/siovar.h:1.7 src/sys/arch/luna68k/dev/siovar.h:1.8
--- src/sys/arch/luna68k/dev/siovar.h:1.7 Tue Dec 31 14:24:09 2013
+++ src/sys/arch/luna68k/dev/siovar.h Sun Feb 2 15:35:06 2014
@@ -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 @@ struct sioreg {
#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);