summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authortsutsui <tsutsui@NetBSD.org>2008-03-29 19:15:34 +0000
committertsutsui <tsutsui@NetBSD.org>2008-03-29 19:15:34 +0000
commit02cb47cab231ebd863359e08e47b4a2356127b4c (patch)
treed4e2f934dfa66a49d12dde22d4f3f41dab354c75 /sys/dev
parent38b9530a914c80dd885a7adc75088041592a9d00 (diff)
Split softc and device_t for zsc(4) and its children.
XXX we should restructure MI APIs and make it really machine independent.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/ic/z8530sc.c43
-rw-r--r--sys/dev/ic/z8530tty.c269
-rw-r--r--sys/dev/sun/kbd.c40
-rw-r--r--sys/dev/sun/kbd_zs.c49
-rw-r--r--sys/dev/sun/kbdsun.c64
-rw-r--r--sys/dev/sun/kbdsunvar.h4
-rw-r--r--sys/dev/sun/kbdvar.h6
-rw-r--r--sys/dev/sun/ms.c55
-rw-r--r--sys/dev/sun/ms_zs.c47
-rw-r--r--sys/dev/sun/msvar.h11
-rw-r--r--sys/dev/sun/sunkbd.c61
-rw-r--r--sys/dev/sun/sunms.c60
-rw-r--r--sys/dev/tc/zs_ioasic.c50
-rw-r--r--sys/dev/tc/zskbd.c32
-rw-r--r--sys/dev/tc/zsms.c29
15 files changed, 356 insertions, 464 deletions
diff --git a/sys/dev/ic/z8530sc.c b/sys/dev/ic/z8530sc.c
index 0a90f44f9e5..93b1c2feaff 100644
--- a/sys/dev/ic/z8530sc.c
+++ b/sys/dev/ic/z8530sc.c
@@ -1,4 +1,4 @@
-/* $NetBSD: z8530sc.c,v 1.27 2007/11/12 17:28:23 ad Exp $ */
+/* $NetBSD: z8530sc.c,v 1.28 2008/03/29 19:15:36 tsutsui Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -91,7 +91,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: z8530sc.c,v 1.27 2007/11/12 17:28:23 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: z8530sc.c,v 1.28 2008/03/29 19:15:36 tsutsui Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -109,9 +109,7 @@ __KERNEL_RCSID(0, "$NetBSD: z8530sc.c,v 1.27 2007/11/12 17:28:23 ad Exp $");
#include <machine/z8530var.h>
void
-zs_break(cs, set)
- struct zs_chanstate *cs;
- int set;
+zs_break(struct zs_chanstate *cs, int set)
{
if (set) {
@@ -129,10 +127,9 @@ zs_break(cs, set)
* drain on-chip fifo
*/
void
-zs_iflush(cs)
- struct zs_chanstate *cs;
+zs_iflush(struct zs_chanstate *cs)
{
- u_char c, rr0, rr1;
+ uint8_t c, rr0, rr1;
int i;
/*
@@ -167,10 +164,9 @@ zs_iflush(cs)
* Call this with interrupts disabled.
*/
void
-zs_loadchannelregs(cs)
- struct zs_chanstate *cs;
+zs_loadchannelregs(struct zs_chanstate *cs)
{
- u_char *reg, v;
+ uint8_t *reg, v;
zs_write_csr(cs, ZSM_RESET_ERR); /* XXX: reset error condition */
@@ -290,12 +286,11 @@ zs_lock_init(struct zs_chanstate *cs)
* the order.
*/
int
-zsc_intr_hard(arg)
- void *arg;
+zsc_intr_hard(void *arg)
{
struct zsc_softc *zsc = arg;
struct zs_chanstate *cs;
- u_char rr3;
+ uint8_t rr3;
/* First look at channel A. */
cs = zsc->zsc_cs[0];
@@ -350,8 +345,7 @@ zsc_intr_hard(arg)
* ZS software interrupt. Scan all channels for deferred interrupts.
*/
int
-zsc_intr_soft(arg)
- void *arg;
+zsc_intr_soft(void *arg)
{
struct zsc_softc *zsc = arg;
struct zs_chanstate *cs;
@@ -385,34 +379,33 @@ static void zsnull_txint (struct zs_chanstate *);
static void zsnull_softint(struct zs_chanstate *);
static void
-zsnull_rxint(cs)
- struct zs_chanstate *cs;
+zsnull_rxint(struct zs_chanstate *cs)
{
+
/* Ask for softint() call. */
cs->cs_softreq = 1;
}
static void
-zsnull_stint(cs, force)
- struct zs_chanstate *cs;
- int force;
+zsnull_stint(struct zs_chanstate *cs, int force)
{
+
/* Ask for softint() call. */
cs->cs_softreq = 1;
}
static void
-zsnull_txint(cs)
- struct zs_chanstate *cs;
+zsnull_txint(struct zs_chanstate *cs)
{
+
/* Ask for softint() call. */
cs->cs_softreq = 1;
}
static void
-zsnull_softint(cs)
- struct zs_chanstate *cs;
+zsnull_softint(struct zs_chanstate *cs)
{
+
zs_write_reg(cs, 1, 0);
zs_write_reg(cs, 15, 0);
}
diff --git a/sys/dev/ic/z8530tty.c b/sys/dev/ic/z8530tty.c
index 099160efbd0..a5e8457dbe9 100644
--- a/sys/dev/ic/z8530tty.c
+++ b/sys/dev/ic/z8530tty.c
@@ -1,4 +1,4 @@
-/* $NetBSD: z8530tty.c,v 1.121 2008/03/14 08:23:51 martin Exp $ */
+/* $NetBSD: z8530tty.c,v 1.122 2008/03/29 19:15:36 tsutsui Exp $ */
/*-
* Copyright (c) 1993, 1994, 1995, 1996, 1997, 1998, 1999
@@ -137,7 +137,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: z8530tty.c,v 1.121 2008/03/14 08:23:51 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: z8530tty.c,v 1.122 2008/03/29 19:15:36 tsutsui Exp $");
#include "opt_kgdb.h"
#include "opt_ntp.h"
@@ -162,6 +162,7 @@ __KERNEL_RCSID(0, "$NetBSD: z8530tty.c,v 1.121 2008/03/14 08:23:51 martin Exp $"
#include <dev/cons.h>
+#include "ioconf.h"
#include "locators.h"
/*
@@ -185,7 +186,7 @@ u_int zstty_rbuf_hiwat = (ZSTTY_RING_SIZE * 1) / 4;
u_int zstty_rbuf_lowat = (ZSTTY_RING_SIZE * 3) / 4;
struct zstty_softc {
- struct device zst_dev; /* required first: base device */
+ device_t zst_dev; /* required first: base device */
struct tty *zst_tty;
struct zs_chanstate *zst_cs;
@@ -200,11 +201,11 @@ struct zstty_softc {
u_int zst_r_hiwat,
zst_r_lowat;
- u_char *volatile zst_rbget,
- *volatile zst_rbput;
+ uint8_t *volatile zst_rbget,
+ *volatile zst_rbput;
volatile u_int zst_rbavail;
- u_char *zst_rbuf,
- *zst_ebuf;
+ uint8_t *zst_rbuf,
+ *zst_ebuf;
/*
* The transmit byte count and address are used for pseudo-DMA
@@ -212,12 +213,12 @@ struct zstty_softc {
* to get pending changes done; heldtbc is used for this. It can
* also be stopped for ^S; this sets TS_TTSTOP in tp->t_state.
*/
- u_char *zst_tba; /* transmit buffer address */
+ uint8_t *zst_tba; /* transmit buffer address */
u_int zst_tbc, /* transmit byte count */
zst_heldtbc; /* held tbc while xmission stopped */
/* Flags to communicate with zstty_softint() */
- volatile u_char zst_rx_flags, /* receiver blocked */
+ volatile uint8_t zst_rx_flags, /* receiver blocked */
#define RX_TTY_BLOCKED 0x01
#define RX_TTY_OVERFLOWED 0x02
#define RX_IBUF_BLOCKED 0x04
@@ -230,19 +231,17 @@ struct zstty_softc {
zst_rx_ready;
/* PPS signal on DCD, with or without inkernel clock disciplining */
- u_char zst_ppsmask; /* pps signal mask */
+ uint8_t zst_ppsmask; /* pps signal mask */
struct pps_state zst_pps_state;
};
/* Definition of the driver for autoconfig. */
-static int zstty_match(struct device *, struct cfdata *, void *);
-static void zstty_attach(struct device *, struct device *, void *);
+static int zstty_match(device_t, cfdata_t, void *);
+static void zstty_attach(device_t, device_t, void *);
-CFATTACH_DECL(zstty, sizeof(struct zstty_softc),
+CFATTACH_DECL_NEW(zstty, sizeof(struct zstty_softc),
zstty_match, zstty_attach, NULL, NULL);
-extern struct cfdriver zstty_cd;
-
dev_type_open(zsopen);
dev_type_close(zsclose);
dev_type_read(zsread);
@@ -290,7 +289,7 @@ struct tty *zstty_get_tty_from_dev(struct device *);
struct tty *
zstty_get_tty_from_dev(struct device *dev)
{
- struct zstty_softc *sc = (struct zstty_softc *)dev;
+ struct zstty_softc *sc = device_private(dev);
return sc->zst_tty;
}
@@ -299,10 +298,7 @@ zstty_get_tty_from_dev(struct device *dev)
* zstty_match: how is this zs channel configured?
*/
int
-zstty_match(parent, cf, aux)
- struct device *parent;
- struct cfdata *cf;
- void *aux;
+zstty_match(device_t parent, cfdata_t cf, void *aux)
{
struct zsc_attach_args *args = aux;
@@ -318,27 +314,26 @@ zstty_match(parent, cf, aux)
}
void
-zstty_attach(parent, self, aux)
- struct device *parent, *self;
- void *aux;
-
+zstty_attach(device_t parent, device_t self, void *aux)
{
- struct zsc_softc *zsc = (void *) parent;
- struct zstty_softc *zst = (void *) self;
+ struct zstty_softc *zst = device_private(self);
+ struct zsc_softc *zsc = device_private(parent);
struct cfdata *cf = device_cfdata(self);
struct zsc_attach_args *args = aux;
struct zs_chanstate *cs;
struct tty *tp;
- int channel, tty_unit;
+ int channel, tty_unit;
dev_t dev;
const char *i, *o;
int dtr_on;
int resetbit;
+ zst->zst_dev = self;
+
callout_init(&zst->zst_diag_ch, 0);
cn_init_magic(&zstty_cnm_state);
- tty_unit = device_unit(&zst->zst_dev);
+ tty_unit = device_unit(self);
channel = args->channel;
cs = zsc->zsc_cs[channel];
cs->cs_private = zst;
@@ -350,7 +345,7 @@ zstty_attach(parent, self, aux)
dev = makedev(cdevsw_lookup_major(&zstty_cdevsw), tty_unit);
if (zst->zst_swflags)
- printf(" flags 0x%x", zst->zst_swflags);
+ aprint_normal(" flags 0x%x", zst->zst_swflags);
/*
* Check whether we serve as a console device.
@@ -377,7 +372,7 @@ zstty_attach(parent, self, aux)
cn_tab->cn_dev = dev;
}
if (i != NULL || o != NULL)
- printf(" (console %s)", i ? (o ? "i/o" : i) : o);
+ aprint_normal(" (console %s)", i ? (o ? "i/o" : i) : o);
#ifdef KGDB
if (zs_check_kgdb(cs, dev)) {
@@ -385,7 +380,7 @@ zstty_attach(parent, self, aux)
* Allow kgdb to "take over" this port. Returns true
* if this serial port is in-use by kgdb.
*/
- printf(" (kgdb)\n");
+ aprint_normal(" (kgdb)\n");
/*
* This is the kgdb port (exclusive use)
* so skip the normal attach code.
@@ -393,7 +388,7 @@ zstty_attach(parent, self, aux)
return;
}
#endif
- printf("\n");
+ aprint_normal("\n");
tp = ttymalloc();
tp->t_dev = dev;
@@ -405,8 +400,8 @@ zstty_attach(parent, self, aux)
zst->zst_tty = tp;
zst->zst_rbuf = malloc(zstty_rbuf_size << 1, M_DEVBUF, M_NOWAIT);
if (zst->zst_rbuf == NULL) {
- aprint_error("%s: unable to allocate ring buffer\n",
- zst->zst_dev.dv_xname);
+ aprint_error_dev(zst->zst_dev,
+ "unable to allocate ring buffer\n");
return;
}
zst->zst_ebuf = zst->zst_rbuf + (zstty_rbuf_size << 1);
@@ -470,18 +465,18 @@ zstty_attach(parent, self, aux)
* Return pointer to our tty.
*/
struct tty *
-zstty(dev)
- dev_t dev;
+zstty(dev_t dev)
{
- struct zstty_softc *zst = device_lookup(&zstty_cd, ZSUNIT(dev));
+ struct zstty_softc *zst;
+
+ zst = device_lookup_private(&zstty_cd, ZSUNIT(dev));
return (zst->zst_tty);
}
void
-zs_shutdown(zst)
- struct zstty_softc *zst;
+zs_shutdown(struct zstty_softc *zst)
{
struct zs_chanstate *cs = zst->zst_cs;
struct tty *tp = zst->zst_tty;
@@ -525,7 +520,7 @@ zs_shutdown(zst)
if (cs->disable) {
#ifdef DIAGNOSTIC
if (!cs->enabled)
- panic("zs_shutdown: not enabled?");
+ panic("%s: not enabled?", __func__);
#endif
(*cs->disable)(zst->zst_cs);
}
@@ -537,18 +532,14 @@ zs_shutdown(zst)
* Open a zs serial (tty) port.
*/
int
-zsopen(dev, flags, mode, l)
- dev_t dev;
- int flags;
- int mode;
- struct lwp *l;
+zsopen(dev_t dev, int flags, int mode, struct lwp *l)
{
struct zstty_softc *zst;
struct zs_chanstate *cs;
struct tty *tp;
int error;
- zst = device_lookup(&zstty_cd, ZSUNIT(dev));
+ zst = device_lookup_private(&zstty_cd, ZSUNIT(dev));
if (zst == NULL)
return (ENXIO);
@@ -577,7 +568,7 @@ zsopen(dev, flags, mode, l)
if ((*cs->enable)(cs)) {
mutex_spin_exit(&tty_lock);
printf("%s: device enable failed\n",
- zst->zst_dev.dv_xname);
+ device_xname(zst->zst_dev));
return (EIO);
}
}
@@ -611,7 +602,8 @@ zsopen(dev, flags, mode, l)
/* Clear PPS capture state on first open. */
zst->zst_ppsmask = 0;
memset(&zst->zst_pps_state, 0, sizeof(zst->zst_pps_state));
- zst->zst_pps_state.ppscap = PPS_CAPTUREASSERT | PPS_CAPTURECLEAR;
+ zst->zst_pps_state.ppscap =
+ PPS_CAPTUREASSERT | PPS_CAPTURECLEAR;
pps_init(&zst->zst_pps_state);
mutex_spin_exit(&cs->cs_lock);
@@ -686,14 +678,13 @@ bad:
* Close a zs serial port.
*/
int
-zsclose(dev, flags, mode, l)
- dev_t dev;
- int flags;
- int mode;
- struct lwp *l;
+zsclose(dev_t dev, int flags, int mode, struct lwp *l)
{
- struct zstty_softc *zst = device_lookup(&zstty_cd, ZSUNIT(dev));
- struct tty *tp = zst->zst_tty;
+ struct zstty_softc *zst;
+ struct tty *tp;
+
+ zst = device_lookup_private(&zstty_cd, ZSUNIT(dev));
+ tp = zst->zst_tty;
/* XXX This is for cons.c. */
if (!ISSET(tp->t_state, TS_ISOPEN))
@@ -718,54 +709,52 @@ zsclose(dev, flags, mode, l)
* Read/write zs serial port.
*/
int
-zsread(dev, uio, flags)
- dev_t dev;
- struct uio *uio;
- int flags;
+zsread(dev_t dev, struct uio *uio, int flags)
{
- struct zstty_softc *zst = device_lookup(&zstty_cd, ZSUNIT(dev));
- struct tty *tp = zst->zst_tty;
+ struct zstty_softc *zst;
+ struct tty *tp;
+
+ zst = device_lookup_private(&zstty_cd, ZSUNIT(dev));
+ tp = zst->zst_tty;
return ((*tp->t_linesw->l_read)(tp, uio, flags));
}
int
-zswrite(dev, uio, flags)
- dev_t dev;
- struct uio *uio;
- int flags;
+zswrite(dev_t dev, struct uio *uio, int flags)
{
- struct zstty_softc *zst = device_lookup(&zstty_cd, ZSUNIT(dev));
- struct tty *tp = zst->zst_tty;
+ struct zstty_softc *zst;
+ struct tty *tp;
+
+ zst = device_lookup_private(&zstty_cd, ZSUNIT(dev));
+ tp = zst->zst_tty;
return ((*tp->t_linesw->l_write)(tp, uio, flags));
}
int
-zspoll(dev, events, l)
- dev_t dev;
- int events;
- struct lwp *l;
+zspoll(dev_t dev, int events, struct lwp *l)
{
- struct zstty_softc *zst = device_lookup(&zstty_cd, ZSUNIT(dev));
- struct tty *tp = zst->zst_tty;
+ struct zstty_softc *zst;
+ struct tty *tp;
+
+ zst = device_lookup_private(&zstty_cd, ZSUNIT(dev));
+ tp = zst->zst_tty;
return ((*tp->t_linesw->l_poll)(tp, events, l));
}
int
-zsioctl(dev, cmd, data, flag, l)
- dev_t dev;
- u_long cmd;
- void *data;
- int flag;
- struct lwp *l;
+zsioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
{
- struct zstty_softc *zst = device_lookup(&zstty_cd, ZSUNIT(dev));
- struct zs_chanstate *cs = zst->zst_cs;
- struct tty *tp = zst->zst_tty;
+ struct zstty_softc *zst;
+ struct zs_chanstate *cs;
+ struct tty *tp;
int error;
+ zst = device_lookup_private(&zstty_cd, ZSUNIT(dev));
+ cs = zst->zst_cs;
+ tp = zst->zst_tty;
error = (*tp->t_linesw->l_ioctl)(tp, cmd, data, flag, l);
if (error != EPASSTHROUGH)
return (error);
@@ -884,14 +873,16 @@ zsioctl(dev, cmd, data, flag, l)
* Start or restart transmission.
*/
static void
-zsstart(tp)
- struct tty *tp;
+zsstart(struct tty *tp)
{
- struct zstty_softc *zst = device_lookup(&zstty_cd, ZSUNIT(tp->t_dev));
- struct zs_chanstate *cs = zst->zst_cs;
+ struct zstty_softc *zst;
+ struct zs_chanstate *cs;
u_char *tba;
int tbc;
+ zst = device_lookup_private(&zstty_cd, ZSUNIT(tp->t_dev));
+ cs = zst->zst_cs;
+
if (ISSET(tp->t_state, TS_BUSY | TS_TIMEOUT | TS_TTSTOP))
return;
if (zst->zst_tx_stopped)
@@ -937,13 +928,13 @@ zsstart(tp)
* Stop output, e.g., for ^S or output flush.
*/
void
-zsstop(tp, flag)
- struct tty *tp;
- int flag;
+zsstop(struct tty *tp, int flag)
{
- struct zstty_softc *zst = device_lookup(&zstty_cd, ZSUNIT(tp->t_dev));
+ struct zstty_softc *zst;
int s;
+ zst = device_lookup_private(&zstty_cd, ZSUNIT(tp->t_dev));
+
s = splzs();
if (ISSET(tp->t_state, TS_BUSY)) {
/* Stop transmitting at the next chunk. */
@@ -961,17 +952,17 @@ zsstop(tp, flag)
* making sure all the changes could be done.
*/
static int
-zsparam(tp, t)
- struct tty *tp;
- struct termios *t;
+zsparam(struct tty *tp, struct termios *t)
{
- struct zstty_softc *zst = device_lookup(&zstty_cd, ZSUNIT(tp->t_dev));
- struct zs_chanstate *cs = zst->zst_cs;
+ struct zstty_softc *zst;
+ struct zs_chanstate *cs;
int ospeed;
tcflag_t cflag;
- u_char tmp3, tmp4, tmp5;
+ uint8_t tmp3, tmp4, tmp5;
int error;
+ zst = device_lookup_private(&zstty_cd, ZSUNIT(tp->t_dev));
+ cs = zst->zst_cs;
ospeed = t->c_ospeed;
cflag = t->c_cflag;
@@ -1141,11 +1132,10 @@ zsparam(tp, t)
* Must be called at splzs().
*/
static void
-zs_maskintr(zst)
- struct zstty_softc *zst;
+zs_maskintr(struct zstty_softc *zst)
{
struct zs_chanstate *cs = zst->zst_cs;
- int tmp15;
+ uint8_t tmp15;
cs->cs_rr0_mask = cs->cs_rr0_cts | cs->cs_rr0_dcd;
if (zst->zst_ppsmask != 0)
@@ -1169,9 +1159,7 @@ zs_maskintr(zst)
* Called at splzs() and with the channel lock held.
*/
static void
-zs_modem(zst, onoff)
- struct zstty_softc *zst;
- int onoff;
+zs_modem(struct zstty_softc *zst, int onoff)
{
struct zs_chanstate *cs = zst->zst_cs, *ccs;
@@ -1200,13 +1188,10 @@ zs_modem(zst, onoff)
* Called at splzs() and with the channel lock held.
*/
static void
-tiocm_to_zs(zst, how, ttybits)
- struct zstty_softc *zst;
- u_long how;
- int ttybits;
+tiocm_to_zs(struct zstty_softc *zst, u_long how, int ttybits)
{
struct zs_chanstate *cs = zst->zst_cs, *ccs;
- u_char zsbits;
+ uint8_t zsbits;
ccs = (cs->cs_ctl_chan != NULL ? cs->cs_ctl_chan : cs);
@@ -1246,11 +1231,10 @@ tiocm_to_zs(zst, how, ttybits)
* Called at splzs() and with the channel lock held.
*/
static int
-zs_to_tiocm(zst)
- struct zstty_softc *zst;
+zs_to_tiocm(struct zstty_softc *zst)
{
struct zs_chanstate *cs = zst->zst_cs, *ccs;
- u_char zsbits;
+ uint8_t zsbits;
int ttybits = 0;
ccs = (cs->cs_ctl_chan != NULL ? cs->cs_ctl_chan : cs);
@@ -1277,12 +1261,13 @@ zs_to_tiocm(zst)
* be set or cleared according to the "block" arg passed.
*/
int
-zshwiflow(tp, block)
- struct tty *tp;
- int block;
+zshwiflow(struct tty *tp, int block)
{
- struct zstty_softc *zst = device_lookup(&zstty_cd, ZSUNIT(tp->t_dev));
- struct zs_chanstate *cs = zst->zst_cs;
+ struct zstty_softc *zst;
+ struct zs_chanstate *cs;
+
+ zst = device_lookup_private(&zstty_cd, ZSUNIT(tp->t_dev));
+ cs = zst->zst_cs;
if (cs->cs_wr5_rts == 0)
return (0);
@@ -1313,8 +1298,7 @@ zshwiflow(tp, block)
* Called at splzs() and with the channel lock held.
*/
static void
-zs_hwiflow(zst)
- struct zstty_softc *zst;
+zs_hwiflow(struct zstty_softc *zst)
{
struct zs_chanstate *cs = zst->zst_cs, *ccs;
@@ -1349,13 +1333,12 @@ static void zstty_diag(void *);
* Called at splzs() and with the channel lock held.
*/
static void
-zstty_rxint(cs)
- struct zs_chanstate *cs;
+zstty_rxint(struct zs_chanstate *cs)
{
struct zstty_softc *zst = cs->cs_private;
- u_char *put, *end;
+ uint8_t *put, *end;
u_int cc;
- u_char rr0, rr1, c;
+ uint8_t rr0, rr1, c;
end = zst->zst_ebuf;
put = zst->zst_rbput;
@@ -1431,8 +1414,7 @@ zstty_rxint(cs)
* Called at splzs() and with the channel lock held.
*/
static void
-zstty_txint(cs)
- struct zs_chanstate *cs;
+zstty_txint(struct zs_chanstate *cs)
{
struct zstty_softc *zst = cs->cs_private;
@@ -1472,12 +1454,10 @@ zstty_txint(cs)
* Called at splzs() and with the channel lock held.
*/
static void
-zstty_stint(cs, force)
- struct zs_chanstate *cs;
- int force;
+zstty_stint(struct zs_chanstate *cs, int force)
{
struct zstty_softc *zst = cs->cs_private;
- u_char rr0, delta;
+ uint8_t rr0, delta;
rr0 = zs_read_csr(cs);
zs_write_csr(cs, ZSWR0_RESET_STATUS);
@@ -1502,7 +1482,8 @@ zstty_stint(cs, force)
* Pulse-per-second clock signal on edge of DCD?
*/
if (ISSET(delta, zst->zst_ppsmask)) {
- if (zst->zst_pps_state.ppsparam.mode & PPS_CAPTUREBOTH) {
+ if (zst->zst_pps_state.ppsparam.mode &
+ PPS_CAPTUREBOTH) {
pps_capture(&zst->zst_pps_state);
pps_event(&zst->zst_pps_state,
(ISSET(cs->cs_rr0, zst->zst_ppsmask))
@@ -1526,8 +1507,7 @@ zstty_stint(cs, force)
}
void
-zstty_diag(arg)
- void *arg;
+zstty_diag(void *arg)
{
struct zstty_softc *zst = arg;
int overflows, floods;
@@ -1542,21 +1522,19 @@ zstty_diag(arg)
splx(s);
log(LOG_WARNING, "%s: %d silo overflow%s, %d ibuf flood%s\n",
- zst->zst_dev.dv_xname,
+ device_xname(zst->zst_dev),
overflows, overflows == 1 ? "" : "s",
floods, floods == 1 ? "" : "s");
}
integrate void
-zstty_rxsoft(zst, tp)
- struct zstty_softc *zst;
- struct tty *tp;
+zstty_rxsoft(struct zstty_softc *zst, struct tty *tp)
{
struct zs_chanstate *cs = zst->zst_cs;
int (*rint)(int, struct tty *) = tp->t_linesw->l_rint;
- u_char *get, *end;
+ uint8_t *get, *end;
u_int cc, scc;
- u_char rr1;
+ uint8_t rr1;
int code;
end = zst->zst_ebuf;
@@ -1652,9 +1630,7 @@ zstty_rxsoft(zst, tp)
}
integrate void
-zstty_txsoft(zst, tp)
- struct zstty_softc *zst;
- struct tty *tp;
+zstty_txsoft(struct zstty_softc *zst, struct tty *tp)
{
struct zs_chanstate *cs = zst->zst_cs;
@@ -1669,12 +1645,10 @@ zstty_txsoft(zst, tp)
}
integrate void
-zstty_stsoft(zst, tp)
- struct zstty_softc *zst;
- struct tty *tp;
+zstty_stsoft(struct zstty_softc *zst, struct tty *tp)
{
struct zs_chanstate *cs = zst->zst_cs;
- u_char rr0, delta;
+ uint8_t rr0, delta;
mutex_spin_enter(&cs->cs_lock);
rr0 = cs->cs_rr0;
@@ -1715,16 +1689,14 @@ zstty_stsoft(zst, tp)
* EITHER the TS_TBLOCK flag or zst_rx_blocked flag is set.
*/
static void
-zstty_softint(cs)
- struct zs_chanstate *cs;
+zstty_softint(struct zs_chanstate *cs)
{
zstty_softint1(cs);
}
static void
-zstty_softint1(cs)
- struct zs_chanstate *cs;
+zstty_softint1(struct zs_chanstate *cs)
{
struct zstty_softc *zst = cs->cs_private;
struct tty *tp = zst->zst_tty;
@@ -1755,8 +1727,7 @@ struct zsops zsops_tty = {
#ifdef ZS_TXDMA
void
-zstty_txdma_int(arg)
- void *arg;
+zstty_txdma_int(void *arg)
{
struct zs_chanstate *cs = arg;
struct zstty_softc *zst = cs->cs_private;
diff --git a/sys/dev/sun/kbd.c b/sys/dev/sun/kbd.c
index d9efba0701f..aed968e7b73 100644
--- a/sys/dev/sun/kbd.c
+++ b/sys/dev/sun/kbd.c
@@ -1,4 +1,4 @@
-/* $NetBSD: kbd.c,v 1.59 2007/07/09 21:01:23 ad Exp $ */
+/* $NetBSD: kbd.c,v 1.60 2008/03/29 19:15:36 tsutsui Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -47,7 +47,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kbd.c,v 1.59 2007/07/09 21:01:23 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kbd.c,v 1.60 2008/03/29 19:15:36 tsutsui Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -173,7 +173,7 @@ kbdopen(dev_t dev, int flags, int mode, struct lwp *l)
unit = minor(dev);
if (unit >= kbd_cd.cd_ndevs)
return (ENXIO);
- k = kbd_cd.cd_devs[unit];
+ k = device_private(kbd_cd.cd_devs[unit]);
if (k == NULL)
return (ENXIO);
@@ -223,7 +223,7 @@ kbdclose(dev_t dev, int flags, int mode, struct lwp *l)
{
struct kbd_softc *k;
- k = kbd_cd.cd_devs[minor(dev)];
+ k = device_private(kbd_cd.cd_devs[minor(dev)]);
k->k_evmode = 0;
ev_fini(&k->k_events);
k->k_events.ev_io = NULL;
@@ -242,7 +242,7 @@ kbdread(dev_t dev, struct uio *uio, int flags)
{
struct kbd_softc *k;
- k = kbd_cd.cd_devs[minor(dev)];
+ k = device_private(kbd_cd.cd_devs[minor(dev)]);
return (ev_read(&k->k_events, uio, flags));
}
@@ -252,7 +252,7 @@ kbdpoll(dev_t dev, int events, struct lwp *l)
{
struct kbd_softc *k;
- k = kbd_cd.cd_devs[minor(dev)];
+ k = device_private(kbd_cd.cd_devs[minor(dev)]);
return (ev_poll(&k->k_events, events, l));
}
@@ -261,7 +261,7 @@ kbdkqfilter(dev_t dev, struct knote *kn)
{
struct kbd_softc *k;
- k = kbd_cd.cd_devs[minor(dev)];
+ k = device_private(kbd_cd.cd_devs[minor(dev)]);
return (ev_kqfilter(&k->k_events, kn));
}
@@ -272,7 +272,7 @@ kbdioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
struct kbd_state *ks;
int error = 0;
- k = kbd_cd.cd_devs[minor(dev)];
+ k = device_private(kbd_cd.cd_devs[minor(dev)]);
ks = &k->k_state;
switch (cmd) {
@@ -505,7 +505,7 @@ kbd_cc_alloc(struct kbd_softc *k)
return (NULL);
/* our callbacks for the console driver */
- cc->cc_dev = k;
+ cc->cc_private = k;
cc->cc_iopen = kbd_cc_open;
cc->cc_iclose = kbd_cc_close;
@@ -531,7 +531,7 @@ kbd_cc_open(struct cons_channel *cc)
if (cc == NULL)
return (0);
- k = (struct kbd_softc *)cc->cc_dev;
+ k = cc->cc_private;
if (k == NULL)
return (0);
@@ -558,7 +558,7 @@ kbd_cc_close(struct cons_channel *cc)
if (cc == NULL)
return (0);
- k = (struct kbd_softc *)cc->cc_dev;
+ k = cc->cc_private;
if (k == NULL)
return (0);
@@ -600,7 +600,7 @@ kbd_input_console(struct kbd_softc *k, int code)
if (kbd_input_keysym(k, keysym)) {
log(LOG_WARNING, "%s: code=0x%x with mod=0x%x"
" produced unexpected keysym 0x%x\n",
- k->k_dev.dv_xname,
+ device_xname(k->k_dev),
code, ks->kbd_modbits, keysym);
return; /* no point in auto-repeat here */
}
@@ -623,7 +623,7 @@ kbd_input_console(struct kbd_softc *k, int code)
static void
kbd_repeat(void *arg)
{
- struct kbd_softc *k = (struct kbd_softc *)arg;
+ struct kbd_softc *k = arg;
int s;
s = spltty();
@@ -779,7 +779,7 @@ kbd_input_event(struct kbd_softc *k, int code)
#ifdef DIAGNOSTIC
if (!k->k_evmode) {
printf("%s: kbd_input_event called when not in event mode\n",
- k->k_dev.dv_xname);
+ device_xname(k->k_dev));
return;
}
#endif
@@ -788,7 +788,7 @@ kbd_input_event(struct kbd_softc *k, int code)
put = (put + 1) % EV_QSIZE;
if (put == k->k_events.ev_get) {
log(LOG_WARNING, "%s: event queue overflow\n",
- k->k_dev.dv_xname);
+ device_xname(k->k_dev));
return;
}
@@ -888,7 +888,9 @@ kbd_code_to_keysym(struct kbd_state *ks, int c)
void
kbd_bell(int on)
{
- struct kbd_softc *k = kbd_cd.cd_devs[0]; /* XXX: hardcoded minor */
+ struct kbd_softc *k;
+
+ k = device_private(kbd_cd.cd_devs[0]); /* XXX: hardcoded minor */
if (k == NULL || k->k_ops == NULL || k->k_ops->docmd == NULL)
return;
@@ -1017,7 +1019,7 @@ sunkbd_wskbd_cnbell(void *v, u_int pitch, u_int period, u_int volume)
void
kbd_enable(struct device *dev)
{
- struct kbd_softc *k = (struct kbd_softc *)(void *)dev;
+ struct kbd_softc *k = device_private(dev);
struct wskbddev_attach_args a;
if (k->k_isconsole)
@@ -1033,7 +1035,7 @@ kbd_enable(struct device *dev)
k->k_wsenabled = 0;
/* Attach the wskbd */
- k->k_wskbd = config_found(&k->k_dev, &a, wskbddevprint);
+ k->k_wskbd = config_found(k->k_dev, &a, wskbddevprint);
callout_init(&k->k_wsbell, 0);
@@ -1049,6 +1051,6 @@ kbd_wskbd_attach(struct kbd_softc *k, int isconsole)
{
k->k_isconsole = isconsole;
- config_interrupts(&k->k_dev, kbd_enable);
+ config_interrupts(k->k_dev, kbd_enable);
}
#endif
diff --git a/sys/dev/sun/kbd_zs.c b/sys/dev/sun/kbd_zs.c
index 561944ed95a..988abf7219b 100644
--- a/sys/dev/sun/kbd_zs.c
+++ b/sys/dev/sun/kbd_zs.c
@@ -1,4 +1,4 @@
-/* $NetBSD: kbd_zs.c,v 1.21 2006/03/30 16:12:10 thorpej Exp $ */
+/* $NetBSD: kbd_zs.c,v 1.22 2008/03/29 19:15:36 tsutsui Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -53,7 +53,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kbd_zs.c,v 1.21 2006/03/30 16:12:10 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kbd_zs.c,v 1.22 2008/03/29 19:15:36 tsutsui Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -97,11 +97,11 @@ struct zsops zsops_kbd = {
kbd_zs_softint, /* process software interrupt */
};
-static int kbd_zs_match(struct device *, struct cfdata *, void *);
-static void kbd_zs_attach(struct device *, struct device *, void *);
+static int kbd_zs_match(device_t, cfdata_t, void *);
+static void kbd_zs_attach(device_t, device_t, void *);
static void kbd_zs_write_data(struct kbd_sun_softc *, int);
-CFATTACH_DECL(kbd_zs, sizeof(struct kbd_sun_softc),
+CFATTACH_DECL_NEW(kbd_zs, sizeof(struct kbd_sun_softc),
kbd_zs_match, kbd_zs_attach, NULL, NULL);
/* Fall-back baud rate */
@@ -111,10 +111,7 @@ int kbd_zs_bps = KBD_DEFAULT_BPS;
* kbd_zs_match: how is this zs channel configured?
*/
int
-kbd_zs_match(parent, cf, aux)
- struct device *parent;
- struct cfdata *cf;
- void *aux;
+kbd_zs_match(device_t parent, cfdata_t cf, void *aux)
{
struct zsc_attach_args *args = aux;
@@ -126,19 +123,18 @@ kbd_zs_match(parent, cf, aux)
}
void
-kbd_zs_attach(parent, self, aux)
- struct device *parent, *self;
- void *aux;
-
+kbd_zs_attach(device_t parent, device_t self, void *aux)
{
- struct zsc_softc *zsc = device_private(parent);
struct kbd_sun_softc *k = device_private(self);
+ struct zsc_softc *zsc = device_private(parent);
struct zsc_attach_args *args = aux;
struct zs_chanstate *cs;
int channel;
int reset, s;
int bps;
+ k->k_kbd.k_dev = self;
+
/* provide upper layer with a link to the middle layer */
k->k_kbd.k_ops = &kbd_ops_sun;
@@ -153,7 +149,7 @@ kbd_zs_attach(parent, self, aux)
if ((bps = cs->cs_defspeed) == 0)
bps = kbd_zs_bps;
- printf(": baud rate %d", bps);
+ aprint_normal(": baud rate %d", bps);
if ((args->hwflags & ZS_HWFLAG_CONSOLE_INPUT) != 0) {
/*
@@ -166,9 +162,9 @@ kbd_zs_attach(parent, self, aux)
cons_attach_input(cc, args->consdev);
k->k_kbd.k_isconsole = 1;
- printf(" (console input)");
+ aprint_normal(" (console input)");
}
- printf("\n");
+ aprint_normal("\n");
/* Initialize the speed, etc. */
s = splzs();
@@ -213,8 +209,7 @@ kbd_zs_write_data(k, c)
}
static void
-kbd_zs_rxint(cs)
- struct zs_chanstate *cs;
+kbd_zs_rxint(struct zs_chanstate *cs)
{
struct kbd_sun_softc *k;
int put, put_next;
@@ -277,8 +272,7 @@ kbd_zs_rxint(cs)
static void
-kbd_zs_txint(cs)
- struct zs_chanstate *cs;
+kbd_zs_txint(struct zs_chanstate *cs)
{
struct kbd_sun_softc *k;
@@ -291,9 +285,7 @@ kbd_zs_txint(cs)
static void
-kbd_zs_stint(cs, force)
- struct zs_chanstate *cs;
- int force;
+kbd_zs_stint(struct zs_chanstate *cs, int force)
{
struct kbd_sun_softc *k;
int rr0;
@@ -331,8 +323,7 @@ kbd_zs_stint(cs, force)
* Note: this is called at splsoftclock()
*/
static void
-kbd_zs_softint(cs)
- struct zs_chanstate *cs;
+kbd_zs_softint(struct zs_chanstate *cs)
{
struct kbd_sun_softc *k;
int get, c, s;
@@ -368,7 +359,7 @@ kbd_zs_softint(cs)
* send a reset to resync key translation.
*/
log(LOG_ERR, "%s: input error (0x%x)\n",
- k->k_kbd.k_dev.dv_xname, ring_data);
+ device_xname(k->k_kbd.k_dev), ring_data);
get = k->k_rbput; /* flush */
goto send_reset;
}
@@ -378,7 +369,7 @@ kbd_zs_softint(cs)
}
if (intr_flags & INTR_RX_OVERRUN) {
log(LOG_ERR, "%s: input overrun\n",
- k->k_kbd.k_dev.dv_xname);
+ device_xname(k->k_kbd.k_dev));
send_reset:
/* Send a reset to resync translation. */
kbd_sun_output(k, KBD_CMD_RESET);
@@ -400,7 +391,7 @@ kbd_zs_softint(cs)
* Status line change. (Not expected.)
*/
log(LOG_ERR, "%s: status interrupt?\n",
- k->k_kbd.k_dev.dv_xname);
+ device_xname(k->k_kbd.k_dev));
cs->cs_rr0_delta = 0;
}
diff --git a/sys/dev/sun/kbdsun.c b/sys/dev/sun/kbdsun.c
index 56df0ba82b3..d86cb416b55 100644
--- a/sys/dev/sun/kbdsun.c
+++ b/sys/dev/sun/kbdsun.c
@@ -1,4 +1,4 @@
-/* $NetBSD: kbdsun.c,v 1.10 2007/03/04 06:02:45 christos Exp $ */
+/* $NetBSD: kbdsun.c,v 1.11 2008/03/29 19:15:36 tsutsui Exp $ */
/* NetBSD: kbd.c,v 1.29 2001/11/13 06:54:32 lukem Exp */
/*
@@ -47,7 +47,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kbdsun.c,v 1.10 2007/03/04 06:02:45 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kbdsun.c,v 1.11 2008/03/29 19:15:36 tsutsui Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -107,8 +107,7 @@ static void kbd_sun_new_layout(struct kbd_sun_softc *);
* Called with user context.
*/
static int
-kbd_sun_open(kbd)
- struct kbd_softc *kbd;
+kbd_sun_open(struct kbd_softc *kbd)
{
struct kbd_sun_softc *k = (struct kbd_sun_softc *)kbd;
struct kbd_state *ks;
@@ -125,7 +124,7 @@ kbd_sun_open(kbd)
/* open internal device */
if (k->k_deviopen)
- (*k->k_deviopen)((struct device *)k, FREAD|FWRITE);
+ (*k->k_deviopen)(k->k_kbd.k_dev, FREAD|FWRITE);
s = spltty();
@@ -143,7 +142,7 @@ kbd_sun_open(kbd)
}
if (error == EWOULDBLOCK || ks->kbd_id == 0) { /* no response */
- log(LOG_ERR, "%s: reset failed\n", kbd->k_dev.dv_xname);
+ log(LOG_ERR, "%s: reset failed\n", device_xname(kbd->k_dev));
/*
* Allow the open anyway (to keep getty happy)
@@ -172,7 +171,7 @@ kbd_sun_open(kbd)
}
if (error == EWOULDBLOCK || ks->kbd_layout == 0xff) {
log(LOG_ERR, "%s: no response to get_layout\n",
- kbd->k_dev.dv_xname);
+ device_xname(kbd->k_dev));
error = 0;
ks->kbd_layout = 0; /* US layout */
}
@@ -190,8 +189,7 @@ kbd_sun_open(kbd)
static int
-kbd_sun_close(kbd)
- struct kbd_softc *kbd;
+kbd_sun_close(struct kbd_softc *kbd)
{
return (0); /* nothing to do so far */
@@ -204,10 +202,7 @@ kbd_sun_close(kbd)
* XXX: This is also exported to the fb driver (for bell).
*/
static int
-kbd_sun_do_cmd(kbd, cmd, isioctl)
- struct kbd_softc *kbd;
- int cmd;
- int isioctl;
+kbd_sun_do_cmd(struct kbd_softc *kbd, int cmd, int isioctl)
{
struct kbd_sun_softc *k = (struct kbd_sun_softc *)kbd;
struct kbd_state *ks;
@@ -256,10 +251,7 @@ kbd_sun_do_cmd(kbd, cmd, isioctl)
* Take care about spl and call kbd_sun_set_leds.
*/
static int
-kbd_sun_set_leds(kbd, leds, isioctl)
- struct kbd_softc *kbd;
- int leds;
- int isioctl;
+kbd_sun_set_leds(struct kbd_softc *kbd, int leds, int isioctl)
{
struct kbd_sun_softc *k = (struct kbd_sun_softc *)kbd;
@@ -285,9 +277,7 @@ kbd_sun_set_leds(kbd, leds, isioctl)
* by kbd_sun_iocsled and kbd_sun_input (via kbd_update_leds).
*/
static void
-kbd_sun_set_leds1(kbd, new_leds)
- struct kbd_softc *kbd;
- int new_leds;
+kbd_sun_set_leds1(struct kbd_softc *kbd, int new_leds)
{
struct kbd_sun_softc *k = (struct kbd_sun_softc *)kbd;
struct kbd_state *ks = &kbd->k_state;
@@ -318,20 +308,18 @@ kbd_sun_set_leds1(kbd, new_leds)
* Called at spltty().
*/
void
-kbd_sun_output(k, c)
- struct kbd_sun_softc *k;
- int c; /* the data */
+kbd_sun_output(struct kbd_sun_softc *k, int c)
{
int put;
put = k->k_tbput;
- k->k_tbuf[put] = (u_char)c;
+ k->k_tbuf[put] = (uint8_t)c;
put = (put + 1) & KBD_TX_RING_MASK;
/* Would overrun if increment makes (put == get) */
if (put == k->k_tbget) {
log(LOG_WARNING, "%s: output overrun\n",
- k->k_kbd.k_dev.dv_xname);
+ device_xname(k->k_kbd.k_dev));
} else {
/* OK, really increment. */
k->k_tbput = put;
@@ -344,8 +332,7 @@ kbd_sun_output(k, c)
* Wait for output to keyboard to finish.
*/
static int
-kbd_sun_drain_tx(k)
- struct kbd_sun_softc *k;
+kbd_sun_drain_tx(struct kbd_sun_softc *k)
{
int error = 0, bail = 0;
@@ -354,8 +341,8 @@ kbd_sun_drain_tx(k)
error = tsleep(&k->k_txflags, PZERO | PCATCH, "kbdout", 1);
bail++;
}
- if (bail==1000)
- error=EIO;
+ if (bail == 1000)
+ error = EIO;
return (error);
}
@@ -364,11 +351,10 @@ kbd_sun_drain_tx(k)
* Called at spltty().
*/
void
-kbd_sun_start_tx(k)
- struct kbd_sun_softc *k;
+kbd_sun_start_tx(struct kbd_sun_softc *k)
{
int get;
- u_char c;
+ uint8_t c;
if (k->k_txflags & K_TXBUSY)
return;
@@ -401,9 +387,7 @@ kbd_sun_start_tx(k)
* Called at spltty()
*/
int
-kbd_sun_input(k, code)
- struct kbd_sun_softc *k;
- int code;
+kbd_sun_input(struct kbd_sun_softc *k, int code)
{
struct kbd_softc *kbd = (struct kbd_softc *)k;
@@ -440,7 +424,7 @@ kbd_sun_input(k, code)
case KBD_ERROR:
log(LOG_WARNING, "%s: received error indicator\n",
- kbd->k_dev.dv_xname);
+ device_xname(kbd->k_dev));
return(-1);
case KBD_IDLE:
@@ -459,8 +443,7 @@ kbd_sun_input(k, code)
* Called at spltty().
*/
static void
-kbd_sun_was_reset(k)
- struct kbd_sun_softc *k;
+kbd_sun_was_reset(struct kbd_sun_softc *k)
{
struct kbd_state *ks = &k->k_kbd.k_state;
@@ -496,7 +479,7 @@ kbd_sun_was_reset(k)
break;
default:
printf("%s: unknown keyboard type ID %u\n",
- k->k_kbd.k_dev.dv_xname, (unsigned int)ks->kbd_id);
+ device_xname(k->k_kbd.k_dev), (unsigned int)ks->kbd_id);
}
/* LEDs are off after reset. */
@@ -508,8 +491,7 @@ kbd_sun_was_reset(k)
* Called at spltty().
*/
static void
-kbd_sun_new_layout(k)
- struct kbd_sun_softc *k;
+kbd_sun_new_layout(struct kbd_sun_softc *k)
{
struct kbd_state *ks = &k->k_kbd.k_state;
diff --git a/sys/dev/sun/kbdsunvar.h b/sys/dev/sun/kbdsunvar.h
index 09d81609d82..10569e472e8 100644
--- a/sys/dev/sun/kbdsunvar.h
+++ b/sys/dev/sun/kbdsunvar.h
@@ -1,4 +1,4 @@
-/* $NetBSD: kbdsunvar.h,v 1.5 2005/12/11 12:23:56 christos Exp $ */
+/* $NetBSD: kbdsunvar.h,v 1.6 2008/03/29 19:15:36 tsutsui Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -69,7 +69,7 @@
struct kbd_sun_softc {
- /* upper layer (also inherits struct device) */
+ /* upper layer (also inherits device_t) */
struct kbd_softc k_kbd;
union {
diff --git a/sys/dev/sun/kbdvar.h b/sys/dev/sun/kbdvar.h
index 70c5b8f7a70..57e991b6895 100644
--- a/sys/dev/sun/kbdvar.h
+++ b/sys/dev/sun/kbdvar.h
@@ -1,4 +1,4 @@
-/* $NetBSD: kbdvar.h,v 1.18 2005/12/11 12:23:56 christos Exp $ */
+/* $NetBSD: kbdvar.h,v 1.19 2008/03/29 19:15:36 tsutsui Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -49,7 +49,7 @@
#endif
struct kbd_softc {
- struct device k_dev; /* required first: base device */
+ device_t k_dev; /* required first: base device */
/* middle layer methods */
const struct kbd_ops *k_ops;
@@ -104,7 +104,7 @@ struct cons_channel {
* Callbacks provided by underlying device (e.g. keyboard driver).
* Console driver will call these before console is opened/closed.
*/
- void *cc_dev; /* underlying device private data */
+ void *cc_private; /* underlying device private data */
int (*cc_iopen)(struct cons_channel *); /* open underlying device */
int (*cc_iclose)(struct cons_channel *); /* close underlying device */
diff --git a/sys/dev/sun/ms.c b/sys/dev/sun/ms.c
index 4a3d0ea3087..7eb75caa1ac 100644
--- a/sys/dev/sun/ms.c
+++ b/sys/dev/sun/ms.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ms.c,v 1.35 2007/03/04 06:02:45 christos Exp $ */
+/* $NetBSD: ms.c,v 1.36 2008/03/29 19:15:36 tsutsui Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -52,7 +52,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ms.c,v 1.35 2007/03/04 06:02:45 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ms.c,v 1.36 2008/03/29 19:15:36 tsutsui Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -101,10 +101,7 @@ const struct cdevsw ms_cdevsw = {
****************************************************************/
int
-msopen(dev, flags, mode, l)
- dev_t dev;
- int flags, mode;
- struct lwp *l;
+msopen(dev_t dev, int flags, int mode, struct lwp *l)
{
struct ms_softc *ms;
int unit;
@@ -112,7 +109,7 @@ msopen(dev, flags, mode, l)
unit = minor(dev);
if (unit >= ms_cd.cd_ndevs)
return (ENXIO);
- ms = ms_cd.cd_devs[unit];
+ ms = device_private(ms_cd.cd_devs[unit]);
if (ms == NULL)
return (ENXIO);
@@ -122,7 +119,7 @@ msopen(dev, flags, mode, l)
if (ms->ms_deviopen) {
int err;
- err = (*ms->ms_deviopen)((struct device *)ms, flags);
+ err = (*ms->ms_deviopen)(ms->ms_dev, flags);
if (err)
return (err);
}
@@ -134,21 +131,18 @@ msopen(dev, flags, mode, l)
}
int
-msclose(dev, flags, mode, l)
- dev_t dev;
- int flags, mode;
- struct lwp *l;
+msclose(dev_t dev, int flags, int mode, struct lwp *l)
{
struct ms_softc *ms;
- ms = ms_cd.cd_devs[minor(dev)];
+ ms = device_private(ms_cd.cd_devs[minor(dev)]);
ms->ms_ready = 0; /* stop accepting events */
ev_fini(&ms->ms_events);
ms->ms_events.ev_io = NULL;
if (ms->ms_deviclose) {
int err;
- err = (*ms->ms_deviclose)((struct device *)ms, flags);
+ err = (*ms->ms_deviclose)(ms->ms_dev, flags);
if (err)
return (err);
}
@@ -156,28 +150,20 @@ msclose(dev, flags, mode, l)
}
int
-msread(dev, uio, flags)
- dev_t dev;
- struct uio *uio;
- int flags;
+msread(dev_t dev, struct uio *uio, int flags)
{
struct ms_softc *ms;
- ms = ms_cd.cd_devs[minor(dev)];
+ ms = device_private(ms_cd.cd_devs[minor(dev)]);
return (ev_read(&ms->ms_events, uio, flags));
}
int
-msioctl(dev, cmd, data, flag, l)
- dev_t dev;
- u_long cmd;
- void *data;
- int flag;
- struct lwp *l;
+msioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
{
struct ms_softc *ms;
- ms = ms_cd.cd_devs[minor(dev)];
+ ms = device_private(ms_cd.cd_devs[minor(dev)]);
switch (cmd) {
@@ -213,25 +199,20 @@ msioctl(dev, cmd, data, flag, l)
}
int
-mspoll(dev, events, l)
- dev_t dev;
- int events;
- struct lwp *l;
+mspoll(dev_t dev, int events, struct lwp *l)
{
struct ms_softc *ms;
- ms = ms_cd.cd_devs[minor(dev)];
+ ms = device_private(ms_cd.cd_devs[minor(dev)]);
return (ev_poll(&ms->ms_events, events, l));
}
int
-mskqfilter(dev, kn)
- dev_t dev;
- struct knote *kn;
+mskqfilter(dev_t dev, struct knote *kn)
{
struct ms_softc *ms;
- ms = ms_cd.cd_devs[minor(dev)];
+ ms = device_private(ms_cd.cd_devs[minor(dev)]);
return (ev_kqfilter(&ms->ms_events, kn));
}
@@ -243,9 +224,7 @@ mskqfilter(dev, kn)
* Called by our ms_softint() routine on input.
*/
void
-ms_input(ms, c)
- struct ms_softc *ms;
- int c;
+ms_input(struct ms_softc *ms, int c)
{
struct firm_event *fe;
int mb, ub, d, get, put, any;
diff --git a/sys/dev/sun/ms_zs.c b/sys/dev/sun/ms_zs.c
index e848ddf3989..d2c9e30caf8 100644
--- a/sys/dev/sun/ms_zs.c
+++ b/sys/dev/sun/ms_zs.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ms_zs.c,v 1.16 2006/03/30 16:12:10 thorpej Exp $ */
+/* $NetBSD: ms_zs.c,v 1.17 2008/03/29 19:15:36 tsutsui Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -52,7 +52,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ms_zs.c,v 1.16 2006/03/30 16:12:10 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ms_zs.c,v 1.17 2008/03/29 19:15:36 tsutsui Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -93,20 +93,17 @@ int ms_zs_bps = SUN_MS_BPS;
int ms_zs_bps = MS_DEFAULT_BPS;
#endif
-static int ms_zs_match(struct device *, struct cfdata *, void *);
-static void ms_zs_attach(struct device *, struct device *, void *);
+static int ms_zs_match(device_t, cfdata_t, void *);
+static void ms_zs_attach(device_t, device_t, void *);
-CFATTACH_DECL(ms_zs, sizeof(struct ms_softc),
+CFATTACH_DECL_NEW(ms_zs, sizeof(struct ms_softc),
ms_zs_match, ms_zs_attach, NULL, NULL);
/*
* ms_match: how is this zs channel configured?
*/
int
-ms_zs_match(parent, cf, aux)
- struct device *parent;
- struct cfdata *cf;
- void *aux;
+ms_zs_match(struct device *parent, struct cfdata *cf, void *aux)
{
struct zsc_attach_args *args = aux;
@@ -121,9 +118,7 @@ ms_zs_match(parent, cf, aux)
}
void
-ms_zs_attach(parent, self, aux)
- struct device *parent, *self;
- void *aux;
+ms_zs_attach(device_t parent, device_t self, void *aux)
{
struct zsc_softc *zsc = device_private(parent);
@@ -135,8 +130,9 @@ ms_zs_attach(parent, self, aux)
int reset, s;
int bps;
- cf = device_cfdata(&ms->ms_dev);
- ms_unit = device_unit(&ms->ms_dev);
+ ms->ms_dev = self;
+ cf = device_cfdata(self);
+ ms_unit = device_unit(self);
channel = args->channel;
cs = zsc->zsc_cs[channel];
cs->cs_private = ms;
@@ -148,7 +144,7 @@ ms_zs_attach(parent, self, aux)
#endif
bps = ms_zs_bps;
- printf(": baud rate %d\n", bps);
+ aprint_normal(": baud rate %d\n", bps);
/* Initialize the speed, etc. */
s = splzs();
@@ -172,8 +168,7 @@ ms_zs_attach(parent, self, aux)
****************************************************************/
static void
-ms_zs_rxint(cs)
- struct zs_chanstate *cs;
+ms_zs_rxint(struct zs_chanstate *cs)
{
struct ms_softc *ms;
int put, put_next;
@@ -213,8 +208,7 @@ ms_zs_rxint(cs)
}
static void
-ms_zs_txint(cs)
- struct zs_chanstate *cs;
+ms_zs_txint(struct zs_chanstate *cs)
{
struct ms_softc *ms;
@@ -226,9 +220,7 @@ ms_zs_txint(cs)
}
static void
-ms_zs_stint(cs, force)
- struct zs_chanstate *cs;
- int force;
+ms_zs_stint(struct zs_chanstate *cs, int force)
{
struct ms_softc *ms;
int rr0;
@@ -254,8 +246,7 @@ ms_zs_stint(cs, force)
}
static void
-ms_zs_softint(cs)
- struct zs_chanstate *cs;
+ms_zs_softint(struct zs_chanstate *cs)
{
struct ms_softc *ms;
int get, c, s;
@@ -287,7 +278,7 @@ ms_zs_softint(cs)
intr_flags |= INTR_RX_OVERRUN;
if (ring_data & (ZSRR1_FE | ZSRR1_PE)) {
log(LOG_ERR, "%s: input error (0x%x)\n",
- ms->ms_dev.dv_xname, ring_data);
+ device_xname(ms->ms_dev), ring_data);
c = -1; /* signal input error */
}
@@ -296,7 +287,7 @@ ms_zs_softint(cs)
}
if (intr_flags & INTR_RX_OVERRUN) {
log(LOG_ERR, "%s: input overrun\n",
- ms->ms_dev.dv_xname);
+ device_xname(ms->ms_dev));
}
ms->ms_rbget = get;
@@ -305,7 +296,7 @@ ms_zs_softint(cs)
* Transmit done. (Not expected.)
*/
log(LOG_ERR, "%s: transmit interrupt?\n",
- ms->ms_dev.dv_xname);
+ device_xname(ms->ms_dev));
}
if (intr_flags & INTR_ST_CHECK) {
@@ -313,7 +304,7 @@ ms_zs_softint(cs)
* Status line change. (Not expected.)
*/
log(LOG_ERR, "%s: status interrupt?\n",
- ms->ms_dev.dv_xname);
+ device_xname(ms->ms_dev));
cs->cs_rr0_delta = 0;
}
diff --git a/sys/dev/sun/msvar.h b/sys/dev/sun/msvar.h
index a427441356e..32138b7290b 100644
--- a/sys/dev/sun/msvar.h
+++ b/sys/dev/sun/msvar.h
@@ -1,4 +1,4 @@
-/* $NetBSD: msvar.h,v 1.7 2005/12/11 12:23:56 christos Exp $ */
+/* $NetBSD: msvar.h,v 1.8 2008/03/29 19:15:36 tsutsui Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -69,8 +69,13 @@
* us sync up with the mouse after an error.)
*/
struct ms_softc {
- struct device ms_dev; /* required first: base device */
- struct zs_chanstate *ms_cs;
+ device_t ms_dev; /* required first: base device */
+ union {
+ void *msu_priv;
+ struct zs_chanstate *msu_cs;
+ } ms_u;
+#define ms_priv ms_u.msu_priv
+#define ms_cs ms_u.msu_cs
/*
* The deviopen and deviclose routines are provided
diff --git a/sys/dev/sun/sunkbd.c b/sys/dev/sun/sunkbd.c
index bdb34807197..ea12500ea16 100644
--- a/sys/dev/sun/sunkbd.c
+++ b/sys/dev/sun/sunkbd.c
@@ -1,4 +1,4 @@
-/* $NetBSD: sunkbd.c,v 1.26 2007/11/10 18:00:11 ad Exp $ */
+/* $NetBSD: sunkbd.c,v 1.27 2008/03/29 19:15:36 tsutsui Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -51,7 +51,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sunkbd.c,v 1.26 2007/11/10 18:00:11 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunkbd.c,v 1.27 2008/03/29 19:15:36 tsutsui Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -81,10 +81,10 @@ __KERNEL_RCSID(0, "$NetBSD: sunkbd.c,v 1.26 2007/11/10 18:00:11 ad Exp $");
* Interface to the lower layer (ttycc)
****************************************************************/
-static int sunkbd_match(struct device *, struct cfdata *, void *);
-static void sunkbd_attach(struct device *, struct device *, void *);
+static int sunkbd_match(device_t, cfdata_t, void *);
+static void sunkbd_attach(device_t, device_t, void *);
static void sunkbd_write_data(struct kbd_sun_softc *, int);
-static int sunkbdiopen(struct device *, int mode);
+static int sunkbdiopen(device_t, int mode);
#if NWSKBD > 0
void kbd_wskbd_attach(struct kbd_softc *k, int isconsole);
@@ -96,7 +96,7 @@ int sunkbdstart(struct tty *);
/* Default keyboard baud rate */
int sunkbd_bps = KBD_DEFAULT_BPS;
-CFATTACH_DECL(kbd_tty, sizeof(struct kbd_sun_softc),
+CFATTACH_DECL_NEW(kbd_tty, sizeof(struct kbd_sun_softc),
sunkbd_match, sunkbd_attach, NULL, NULL);
struct linesw sunkbd_disc = {
@@ -117,29 +117,26 @@ struct linesw sunkbd_disc = {
* sunkbd_match: how is this tty channel configured?
*/
int
-sunkbd_match(parent, cf, aux)
- struct device *parent;
- struct cfdata *cf;
- void *aux;
+sunkbd_match(device_t parent, cfdata_t cf, void *aux)
{
struct kbd_ms_tty_attach_args *args = aux;
if (strcmp(args->kmta_name, "keyboard") == 0)
- return (1);
+ return 1;
return 0;
}
void
-sunkbd_attach(parent, self, aux)
- struct device *parent, *self;
- void *aux;
+sunkbd_attach(device_t parent, device_t self, void *aux)
{
struct kbd_sun_softc *k = device_private(self);
struct kbd_ms_tty_attach_args *args = aux;
struct tty *tp = args->kmta_tp;
struct cons_channel *cc;
+ k->k_kbd.k_dev = self;
+
/* Set up the proper line discipline. */
if (ttyldisc_attach(&sunkbd_disc) != 0)
panic("sunkbd_attach: sunkbd_disc");
@@ -151,7 +148,7 @@ sunkbd_attach(parent, self, aux)
/* link the structures together. */
k->k_priv = tp;
- tp->t_sc = (void *)k;
+ tp->t_sc = k;
/* provide our middle layer with a link to the lower layer (i.e. us) */
k->k_deviopen = sunkbdiopen;
@@ -178,7 +175,7 @@ sunkbd_attach(parent, self, aux)
/* Tell our parent what the console should be. */
args->kmta_consdev = cn_tab;
k->k_kbd.k_isconsole = 1;
- printf(" (console input)");
+ aprint_normal(" (console input)");
/* Set magic to "L1-A" */
magic[0] = KBD_L1;
@@ -192,7 +189,7 @@ sunkbd_attach(parent, self, aux)
}
- printf("\n");
+ aprint_normal("\n");
#if NWSKBD > 0
kbd_wskbd_attach(&k->k_kbd, args->kmta_consdev != NULL);
@@ -212,12 +209,10 @@ sunkbd_attach(parent, self, aux)
* mechanism.
*/
int
-sunkbdiopen(dev, flags)
- struct device *dev;
- int flags;
+sunkbdiopen(device_t dev, int flags)
{
- struct kbd_sun_softc *k = (void *) dev;
- struct tty *tp = (struct tty *)k->k_priv;
+ struct kbd_sun_softc *k = device_private(dev);
+ struct tty *tp = k->k_priv;
struct lwp *l = curlwp ? curlwp : &lwp0;
struct termios t;
int error;
@@ -241,15 +236,12 @@ sunkbdiopen(dev, flags)
* TTY interface to handle input.
*/
int
-sunkbdinput(c, tp)
- int c;
- struct tty *tp;
+sunkbdinput(int c, struct tty *tp)
{
- struct kbd_sun_softc *k = (void *) tp->t_sc;
+ struct kbd_sun_softc *k = tp->t_sc;
u_char *cc;
int error;
-
cc = tp->t_cc;
/*
@@ -261,7 +253,7 @@ sunkbdinput(c, tp)
* send a reset to resync key translation.
*/
log(LOG_ERR, "%s: input error (0x%x)\n",
- k->k_kbd.k_dev.dv_xname, c);
+ device_xname(k->k_kbd.k_dev), c);
c &= TTY_CHARMASK;
if (!k->k_txflags & K_TXBUSY) {
ttyflush(tp, FREAD | FWRITE);
@@ -274,7 +266,7 @@ sunkbdinput(c, tp)
*/
if (tp->t_rawq.c_cc + tp->t_canq.c_cc >= TTYHOG) {
log(LOG_ERR, "%s: input overrun\n",
- k->k_kbd.k_dev.dv_xname);
+ device_xname(k->k_kbd.k_dev));
goto send_reset;
}
@@ -289,10 +281,9 @@ send_reset:
}
int
-sunkbdstart(tp)
- struct tty *tp;
+sunkbdstart(struct tty *tp)
{
- struct kbd_sun_softc *k = (void *) tp->t_sc;
+ struct kbd_sun_softc *k = tp->t_sc;
/*
* Transmit done. Try to send more, or
@@ -307,11 +298,9 @@ sunkbdstart(tp)
* used by kbd_sun_start_tx();
*/
void
-sunkbd_write_data(k, c)
- struct kbd_sun_softc *k;
- int c;
+sunkbd_write_data(struct kbd_sun_softc *k, int c)
{
- struct tty *tp = (struct tty *)k->k_priv;
+ struct tty *tp = k->k_priv;
mutex_spin_enter(&tty_lock);
ttyoutput(c, tp);
diff --git a/sys/dev/sun/sunms.c b/sys/dev/sun/sunms.c
index 2dab460ef19..752e954e8c8 100644
--- a/sys/dev/sun/sunms.c
+++ b/sys/dev/sun/sunms.c
@@ -1,4 +1,4 @@
-/* $NetBSD: sunms.c,v 1.27 2007/07/09 21:01:23 ad Exp $ */
+/* $NetBSD: sunms.c,v 1.28 2008/03/29 19:15:36 tsutsui Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -52,7 +52,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sunms.c,v 1.27 2007/07/09 21:01:23 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunms.c,v 1.28 2008/03/29 19:15:36 tsutsui Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -88,12 +88,12 @@ int sunms_bps = SUN_MS_BPS;
int sunms_bps = MS_DEFAULT_BPS;
#endif
-static int sunms_match(struct device *, struct cfdata *, void *);
-static void sunms_attach(struct device *, struct device *, void *);
+static int sunms_match(device_t, cfdata_t, void *);
+static void sunms_attach(device_t, device_t, void *);
static int sunmsiopen(struct device *, int mode);
int sunmsinput(int, struct tty *);
-CFATTACH_DECL(ms_tty, sizeof(struct ms_softc),
+CFATTACH_DECL_NEW(ms_tty, sizeof(struct ms_softc),
sunms_match, sunms_attach, NULL, NULL);
struct linesw sunms_disc = {
@@ -123,10 +123,7 @@ const struct wsmouse_accessops sunms_accessops = {
* ms_match: how is this zs channel configured?
*/
int
-sunms_match(parent, cf, aux)
- struct device *parent;
- struct cfdata *cf;
- void *aux;
+sunms_match(device_t parent, cfdata_t cf, void *aux)
{
struct kbd_ms_tty_attach_args *args = aux;
@@ -140,10 +137,7 @@ sunms_match(parent, cf, aux)
}
void
-sunms_attach(parent, self, aux)
- struct device *parent, *self;
- void *aux;
-
+sunms_attach(device_t parent, device_t self, void *aux)
{
struct ms_softc *ms = device_private(self);
struct kbd_ms_tty_attach_args *args = aux;
@@ -154,15 +148,16 @@ sunms_attach(parent, self, aux)
struct wsmousedev_attach_args a;
#endif
- cf = device_cfdata(&ms->ms_dev);
- ms_unit = device_unit(&ms->ms_dev);
+ ms->ms_dev = self;
+ cf = device_cfdata(self);
+ ms_unit = device_unit(self);
tp->t_sc = ms;
tp->t_dev = args->kmta_dev;
- ms->ms_cs = (struct zs_chanstate *)tp;
- ms->ms_deviopen = sunmsiopen;
- ms->ms_deviclose = NULL;
+ ms->ms_priv = tp;
+ ms->ms_deviopen = sunmsiopen;
+ ms->ms_deviclose = NULL;
- printf("\n");
+ aprint_normal("\n");
/* Initialize the speed, etc. */
if (ttyldisc_attach(&sunms_disc) != 0)
@@ -192,12 +187,10 @@ sunms_attach(parent, self, aux)
* mechanism.
*/
int
-sunmsiopen(dev, flags)
- struct device *dev;
- int flags;
+sunmsiopen(device_t dev, int flags)
{
- struct ms_softc *ms = (void *) dev;
- struct tty *tp = (struct tty *)ms->ms_cs;
+ struct ms_softc *ms = device_private(dev);
+ struct tty *tp = ms->ms_priv;
struct lwp *l = curlwp ? curlwp : &lwp0;
struct termios t;
int error;
@@ -218,11 +211,9 @@ sunmsiopen(dev, flags)
}
int
-sunmsinput(c, tp)
- int c;
- struct tty *tp;
+sunmsinput(int c, struct tty *tp)
{
- struct ms_softc *ms = (struct ms_softc *)tp->t_sc;
+ struct ms_softc *ms = tp->t_sc;
if (c & TTY_ERRORMASK) c = -1;
else c &= TTY_CHARMASK;
@@ -233,12 +224,7 @@ sunmsinput(c, tp)
}
int
-sunms_ioctl(v, cmd, data, flag, l)
- void *v;
- u_long cmd;
- void *data;
- int flag;
- struct lwp *l;
+sunms_ioctl(void *v, u_long cmd, void *data, int flag, struct lwp *l)
{
/* struct ms_softc *sc = v; */
@@ -254,8 +240,7 @@ sunms_ioctl(v, cmd, data, flag, l)
}
int
-sunms_enable(v)
- void *v;
+sunms_enable(void *v)
{
struct ms_softc *ms = v;
int err;
@@ -276,8 +261,7 @@ sunms_enable(v)
}
void
-sunms_disable(v)
- void *v;
+sunms_disable(void *v)
{
struct ms_softc *ms = v;
int s;
diff --git a/sys/dev/tc/zs_ioasic.c b/sys/dev/tc/zs_ioasic.c
index 96758c62b2f..3f831ec7e1c 100644
--- a/sys/dev/tc/zs_ioasic.c
+++ b/sys/dev/tc/zs_ioasic.c
@@ -1,4 +1,4 @@
-/* $NetBSD: zs_ioasic.c,v 1.35 2007/11/09 00:05:38 ad Exp $ */
+/* $NetBSD: zs_ioasic.c,v 1.36 2008/03/29 19:15:36 tsutsui Exp $ */
/*-
* Copyright (c) 1996, 1998 The NetBSD Foundation, Inc.
@@ -48,7 +48,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: zs_ioasic.c,v 1.35 2007/11/09 00:05:38 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: zs_ioasic.c,v 1.36 2008/03/29 19:15:36 tsutsui Exp $");
#include "opt_ddb.h"
#include "opt_kgdb.h"
@@ -127,9 +127,9 @@ struct zshan {
u_int sc_pad1;
#endif
#if defined(pmax)
- volatile u_int16_t zc_csr; /* ctrl,status, and indirect access */
+ volatile uint16_t zc_csr; /* ctrl,status, and indirect access */
unsigned : 16;
- volatile u_int16_t zc_data; /* data */
+ volatile uint16_t zc_data; /* data */
unsigned : 16;
#endif
};
@@ -186,13 +186,13 @@ zs_ioasic_get_chan_addr(tc_addr_t zsaddr, int channel)
****************************************************************/
/* Definition of the driver for autoconfig. */
-static int zs_ioasic_match(struct device *, struct cfdata *, void *);
-static void zs_ioasic_attach(struct device *, struct device *, void *);
+static int zs_ioasic_match(device_t, cfdata_t, void *);
+static void zs_ioasic_attach(device_t, device_t, void *);
static int zs_ioasic_print(void *, const char *name);
-static int zs_ioasic_submatch(struct device *, struct cfdata *,
+static int zs_ioasic_submatch(device_t, struct cfdata *,
const int *, void *);
-CFATTACH_DECL(zsc_ioasic, sizeof(struct zsc_softc),
+CFATTACH_DECL_NEW(zsc_ioasic, sizeof(struct zsc_softc),
zs_ioasic_match, zs_ioasic_attach, NULL, NULL);
/* Interrupt handlers. */
@@ -203,7 +203,7 @@ static void zs_ioasic_softintr(void *);
* Is the zs chip present?
*/
static int
-zs_ioasic_match(struct device *parent, struct cfdata *cf, void *aux)
+zs_ioasic_match(device_t parent, cfdata_t cf, void *aux)
{
struct ioasicdev_attach_args *d = aux;
tc_addr_t zs_addr;
@@ -229,7 +229,7 @@ zs_ioasic_match(struct device *parent, struct cfdata *cf, void *aux)
* Attach a found zs.
*/
static void
-zs_ioasic_attach(struct device *parent, struct device *self, void *aux)
+zs_ioasic_attach(device_t parent, device_t self, void *aux)
{
struct zsc_softc *zs = device_private(self);
struct zsc_attach_args zs_args;
@@ -240,7 +240,8 @@ zs_ioasic_attach(struct device *parent, struct device *self, void *aux)
u_long zflg;
int locs[ZSCCF_NLOCS];
- printf("\n");
+ zs->zsc_dev = self;
+ aprint_normal("\n");
/*
* Initialize software state for each channel.
@@ -259,12 +260,12 @@ zs_ioasic_attach(struct device *parent, struct device *self, void *aux)
zc = zs_ioasic_get_chan_addr(d->iada_addr, channel);
cs->cs_reg_csr = (volatile void *)&zc->zc_csr;
- bcopy(zs_ioasic_init_reg, cs->cs_creg, 16);
- bcopy(zs_ioasic_init_reg, cs->cs_preg, 16);
+ memcpy(cs->cs_creg, zs_ioasic_init_reg, 16);
+ memcpy(cs->cs_preg, zs_ioasic_init_reg, 16);
cs->cs_defcflag = zs_def_cflag;
cs->cs_defspeed = 9600; /* XXX */
- (void) zs_set_modes(cs, cs->cs_defcflag);
+ (void)zs_set_modes(cs, cs->cs_defcflag);
}
zs->zsc_cs[channel] = cs;
@@ -317,8 +318,8 @@ zs_ioasic_attach(struct device *parent, struct device *self, void *aux)
if (config_found_sm_loc(self, "zsc", locs, (void *)&zs_args,
zs_ioasic_print, zs_ioasic_submatch) == NULL) {
/* No sub-driver. Just reset it. */
- u_char reset = (channel == 0) ?
- ZSWR9_A_RESET : ZSWR9_B_RESET;
+ uint8_t reset = (channel == 0) ?
+ ZSWR9_A_RESET : ZSWR9_B_RESET;
s = splhigh();
zs_write_reg(cs, 9, reset);
splx(s);
@@ -333,7 +334,7 @@ zs_ioasic_attach(struct device *parent, struct device *self, void *aux)
zs->zsc_sih = softint_establish(SOFTINT_SERIAL,
zs_ioasic_softintr, zs);
if (zs->zsc_sih == NULL)
- panic("zs_ioasic_attach: unable to register softintr");
+ panic("%s: unable to register softintr", __func__);
/*
* Set the master interrupt enable and interrupt vector. The
@@ -372,10 +373,9 @@ zs_ioasic_print(void *aux, const char *name)
}
static int
-zs_ioasic_submatch(struct device *parent, struct cfdata *cf, const int *locs,
- void *aux)
+zs_ioasic_submatch(device_t parent, cfdata_t cf, const int *locs, void *aux)
{
- struct zsc_softc *zs = (void *)parent;
+ struct zsc_softc *zs = device_private(parent);
struct zsc_attach_args *pa = aux;
const char *defname = "";
@@ -446,7 +446,7 @@ zs_ioasic_softintr(void *arg)
int s;
s = spltty();
- (void) zsc_intr_soft(zsc);
+ (void)zsc_intr_soft(zsc);
splx(s);
}
@@ -628,7 +628,7 @@ zs_write_data(struct zs_chanstate *cs, u_int val)
void
zs_abort(struct zs_chanstate *cs)
{
- int rr0;
+ u_int rr0;
/* Wait for end of break. */
/* XXX - Limit the wait? */
@@ -651,7 +651,8 @@ zs_abort(struct zs_chanstate *cs)
int
zs_getc(struct zs_chanstate *cs)
{
- int s, c, rr0;
+ int s, c;
+ u_int rr0;
s = splhigh();
/* Wait for a character to arrive. */
@@ -675,7 +676,8 @@ zs_getc(struct zs_chanstate *cs)
static void
zs_putc(struct zs_chanstate *cs, int c)
{
- register int s, rr0;
+ int s;
+ u_int rr0;
s = splhigh();
/* Wait for transmitter to become ready. */
diff --git a/sys/dev/tc/zskbd.c b/sys/dev/tc/zskbd.c
index 7b3ac15aad8..63e5801110d 100644
--- a/sys/dev/tc/zskbd.c
+++ b/sys/dev/tc/zskbd.c
@@ -1,4 +1,4 @@
-/* $NetBSD: zskbd.c,v 1.15 2007/03/04 06:02:47 christos Exp $ */
+/* $NetBSD: zskbd.c,v 1.16 2008/03/29 19:15:36 tsutsui Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -45,7 +45,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: zskbd.c,v 1.15 2007/03/04 06:02:47 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: zskbd.c,v 1.16 2008/03/29 19:15:36 tsutsui Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -93,7 +93,7 @@ struct zskbd_internal {
static struct zskbd_internal zskbd_console_internal;
struct zskbd_softc {
- struct device zskbd_dev; /* required first: base device */
+ device_t zskbd_dev; /* required first: base device */
struct zskbd_internal *sc_itl;
@@ -120,10 +120,10 @@ static struct zsops zsops_zskbd;
static void zskbd_input(struct zskbd_softc *, int);
-static int zskbd_match(struct device *, struct cfdata *, void *);
-static void zskbd_attach(struct device *, struct device *, void *);
+static int zskbd_match(device_t, cfdata_t, void *);
+static void zskbd_attach(device_t, device_t, void *);
-CFATTACH_DECL(zskbd, sizeof(struct zskbd_softc),
+CFATTACH_DECL_NEW(zskbd, sizeof(struct zskbd_softc),
zskbd_match, zskbd_attach, NULL, NULL);
static int zskbd_enable(void *, int);
@@ -161,7 +161,7 @@ int zskbd_cnattach(struct zs_chanstate *); /* EXPORTED */
* kbd_match: how is this zs channel configured?
*/
static int
-zskbd_match(struct device *parent, struct cfdata *cf, void *aux)
+zskbd_match(device_t parent, cfdata_t cf, void *aux)
{
struct zsc_attach_args *args = aux;
@@ -177,7 +177,7 @@ zskbd_match(struct device *parent, struct cfdata *cf, void *aux)
}
static void
-zskbd_attach(struct device *parent, struct device *self, void *aux)
+zskbd_attach(device_t parent, device_t self, void *aux)
{
struct zsc_softc *zsc = device_private(parent);
struct zskbd_softc *zskbd = device_private(self);
@@ -187,6 +187,8 @@ zskbd_attach(struct device *parent, struct device *self, void *aux)
struct wskbddev_attach_args a;
int s, isconsole;
+ zskbd->zskbd_dev = self;
+
cs = zsc->zsc_cs[args->channel];
cs->cs_private = zskbd;
cs->cs_ops = &zsops_zskbd;
@@ -204,7 +206,7 @@ zskbd_attach(struct device *parent, struct device *self, void *aux)
}
zskbd->sc_itl = zsi;
- printf("\n");
+ aprint_normal("\n");
/* Initialize the speed, etc. */
s = splzs();
@@ -293,7 +295,7 @@ zskbd_cnpollc(void *v, int on)
static void
zskbd_set_leds(void *v, int leds)
{
- struct zskbd_softc *sc = (struct zskbd_softc *)v;
+ struct zskbd_softc *sc = v;
lk201_set_leds(&sc->sc_itl->zsi_ks, leds);
}
@@ -301,7 +303,7 @@ zskbd_set_leds(void *v, int leds)
static int
zskbd_ioctl(void *v, u_long cmd, void *data, int flag, struct lwp *l)
{
- struct zskbd_softc *sc = (struct zskbd_softc *)v;
+ struct zskbd_softc *sc = v;
switch (cmd) {
case WSKBDIO_GTYPE:
@@ -465,7 +467,7 @@ zskbd_softint(struct zs_chanstate *cs)
if (ring_data & (ZSRR1_FE | ZSRR1_PE)) {
#if 0 /* XXX */
log(LOG_ERR, "%s: input error (0x%x)\n",
- zskbd->zskbd_dev.dv_xname, ring_data);
+ device_xname(zskbd->zskbd_dev), ring_data);
c = -1; /* signal input error */
#endif
}
@@ -476,7 +478,7 @@ zskbd_softint(struct zs_chanstate *cs)
if (intr_flags & INTR_RX_OVERRUN) {
#if 0 /* XXX */
log(LOG_ERR, "%s: input overrun\n",
- zskbd->zskbd_dev.dv_xname);
+ device_xname(zskbd->zskbd_dev));
#endif
}
zskbd->zskbd_rbget = get;
@@ -487,7 +489,7 @@ zskbd_softint(struct zs_chanstate *cs)
*/
#if 0
log(LOG_ERR, "%s: transmit interrupt?\n",
- zskbd->zskbd_dev.dv_xname);
+ device_xname(zskbd->zskbd_dev));
#endif
}
@@ -496,7 +498,7 @@ zskbd_softint(struct zs_chanstate *cs)
* Status line change. (Not expected.)
*/
log(LOG_ERR, "%s: status interrupt?\n",
- zskbd->zskbd_dev.dv_xname);
+ device_xname(zskbd->zskbd_dev));
cs->cs_rr0_delta = 0;
}
diff --git a/sys/dev/tc/zsms.c b/sys/dev/tc/zsms.c
index dc0e7b1b5d7..1861ff41390 100644
--- a/sys/dev/tc/zsms.c
+++ b/sys/dev/tc/zsms.c
@@ -1,4 +1,4 @@
-/* $NetBSD: zsms.c,v 1.16 2007/03/04 06:02:47 christos Exp $ */
+/* $NetBSD: zsms.c,v 1.17 2008/03/29 19:15:36 tsutsui Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -45,7 +45,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: zsms.c,v 1.16 2007/03/04 06:02:47 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: zsms.c,v 1.17 2008/03/29 19:15:36 tsutsui Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -82,7 +82,7 @@ __KERNEL_RCSID(0, "$NetBSD: zsms.c,v 1.16 2007/03/04 06:02:47 christos Exp $");
#define ZSMS_BPS 4800
struct zsms_softc { /* driver status information */
- struct device zsms_dev; /* required first: base device */
+ device_t zsms_dev; /* required first: base device */
struct zs_chanstate *zsms_cs;
/* Flags to communicate with zsms_softintr() */
@@ -110,11 +110,11 @@ struct zsms_softc { /* driver status information */
static struct zsops zsops_zsms;
-static int zsms_match(struct device *, struct cfdata *, void *);
-static void zsms_attach(struct device *, struct device *, void *);
+static int zsms_match(device_t, cfdata_t, void *);
+static void zsms_attach(device_t, device_t, void *);
static void zsms_input(void *, int);
-CFATTACH_DECL(zsms, sizeof(struct zsms_softc),
+CFATTACH_DECL_NEW(zsms, sizeof(struct zsms_softc),
zsms_match, zsms_attach, NULL, NULL);
static int zsms_enable(void *);
@@ -128,7 +128,7 @@ static const struct wsmouse_accessops zsms_accessops = {
};
static int
-zsms_match(struct device *parent, struct cfdata *cf, void *aux)
+zsms_match(device_t parent, cfdata_t cf, void *aux)
{
struct zsc_attach_args *args = aux;
@@ -144,7 +144,7 @@ zsms_match(struct device *parent, struct cfdata *cf, void *aux)
}
static void
-zsms_attach(struct device *parent, struct device *self, void *aux)
+zsms_attach(device_t parent, device_t self, void *aux)
{
struct zsc_softc *zsc = device_private(parent);
struct zsms_softc *zsms = device_private(self);
@@ -153,12 +153,13 @@ zsms_attach(struct device *parent, struct device *self, void *aux)
struct wsmousedev_attach_args a;
int s;
+ zsms->zsms_dev = self;
cs = zsc->zsc_cs[args->channel];
cs->cs_private = zsms;
cs->cs_ops = &zsops_zsms;
zsms->zsms_cs = cs;
- printf("\n");
+ aprint_normal("\n");
/* Initialize the speed, etc. */
s = splzs();
@@ -287,7 +288,7 @@ zsms_rxint(struct zs_chanstate *cs)
{
struct zsms_softc *zsms;
int put, put_next;
- u_char c, rr1;
+ uint8_t c, rr1;
zsms = cs->cs_private;
put = zsms->zsms_rbput;
@@ -395,7 +396,7 @@ zsms_softint(struct zs_chanstate *cs)
intr_flags |= INTR_RX_OVERRUN;
if (ring_data & (ZSRR1_FE | ZSRR1_PE)) {
log(LOG_ERR, "%s: input error (0x%x)\n",
- zsms->zsms_dev.dv_xname, ring_data);
+ device_xname(zsms->zsms_dev), ring_data);
c = -1; /* signal input error */
}
@@ -404,7 +405,7 @@ zsms_softint(struct zs_chanstate *cs)
}
if (intr_flags & INTR_RX_OVERRUN) {
log(LOG_ERR, "%s: input overrun\n",
- zsms->zsms_dev.dv_xname);
+ device_xname(zsms->zsms_dev));
}
zsms->zsms_rbget = get;
@@ -413,7 +414,7 @@ zsms_softint(struct zs_chanstate *cs)
* Transmit done. (Not expected.)
*/
log(LOG_ERR, "%s: transmit interrupt?\n",
- zsms->zsms_dev.dv_xname);
+ device_xname(zsms->zsms_dev));
}
if (intr_flags & INTR_ST_CHECK) {
@@ -421,7 +422,7 @@ zsms_softint(struct zs_chanstate *cs)
* Status line change. (Not expected.)
*/
log(LOG_ERR, "%s: status interrupt?\n",
- zsms->zsms_dev.dv_xname);
+ device_xname(zsms->zsms_dev));
cs->cs_rr0_delta = 0;
}