Split device_t/softc, as following parents in sys/dev/sun.

This commit is contained in:
tsutsui 2008-04-07 13:31:15 +00:00
parent a699245e9a
commit a109378b55
2 changed files with 32 additions and 30 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: kbd_pckbport.c,v 1.3 2005/11/16 01:39:27 uwe Exp $ */
/* $NetBSD: kbd_pckbport.c,v 1.4 2008/04/07 13:31:15 tsutsui Exp $ */
/*
* Copyright (c) 2002 Valeriy E. Ushakov
@ -97,7 +97,7 @@
* @(#)pccons.c 5.11 (Berkeley) 5/21/91
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kbd_pckbport.c,v 1.3 2005/11/16 01:39:27 uwe Exp $");
__KERNEL_RCSID(0, "$NetBSD: kbd_pckbport.c,v 1.4 2008/04/07 13:31:15 tsutsui Exp $");
/*
* Serve JavaStation-1 PS/2 keyboard as a Type5 keyboard with US101A
@ -150,10 +150,10 @@ struct kbd_pckbport_softc {
int sc_extended1;
};
static int kbd_pckbport_match(struct device *, struct cfdata *, void *);
static void kbd_pckbport_attach(struct device *, struct device *, void *);
static int kbd_pckbport_match(device_t, cfdata_t, void *);
static void kbd_pckbport_attach(device_t, device_t, void *);
CFATTACH_DECL(kbd_pckbport, sizeof(struct kbd_pckbport_softc),
CFATTACH_DECL_NEW(kbd_pckbport, sizeof(struct kbd_pckbport_softc),
kbd_pckbport_match, kbd_pckbport_attach, NULL, NULL);
@ -187,7 +187,7 @@ static int kbd_pckbport_decode(struct kbd_pckbport_softc *, int, int *);
*/
static int
kbd_pckbport_match(struct device *parent, struct cfdata *cf, void *aux)
kbd_pckbport_match(device_t parent, cfdata_t cf, void *aux)
{
struct pckbport_attach_args *pa = aux;
@ -199,9 +199,9 @@ kbd_pckbport_match(struct device *parent, struct cfdata *cf, void *aux)
static void
kbd_pckbport_attach(struct device *parent, struct device *self, void *aux)
kbd_pckbport_attach(device_t parent, device_t self, void *aux)
{
struct kbd_pckbport_softc *sc = (void *)self;
struct kbd_pckbport_softc *sc = device_private(self);
struct pckbport_attach_args *pa = aux;
struct kbd_softc *kbd = &sc->sc_kbd;
@ -210,6 +210,7 @@ kbd_pckbport_attach(struct device *parent, struct device *self, void *aux)
sc->sc_kbcslot = pa->pa_slot;
/* provide upper layer a link to our middle layer */
kbd->k_dev = self;
kbd->k_ops = &kbd_ops_pckbport;
/* pre-fill keyboard type/layout */
@ -228,10 +229,10 @@ kbd_pckbport_attach(struct device *parent, struct device *self, void *aux)
kd_attach_input(cc); /* XXX ???? */
kbd->k_isconsole = 1;
printf(": console input");
aprint_normal(": console input");
}
printf("\n");
aprint_normal("\n");
kbd_pckbport_set_xtscancode(sc->sc_kbctag, sc->sc_kbcslot);
@ -245,15 +246,14 @@ kbd_pckbport_attach(struct device *parent, struct device *self, void *aux)
res = pckbport_poll_cmd(sc->sc_kbctag, sc->sc_kbcslot,
cmd, 2, 0, NULL, 0);
if (res) {
printf("%s: set typematic failed, error %d\n",
kbd->k_dev.dv_xname, res);
aprint_error_dev(self,
"set typematic failed, error %d\n", res);
}
}
/* register our callback with pckbport interrupt handler */
pckbport_set_inputhandler(sc->sc_kbctag, sc->sc_kbcslot,
kbd_pckbport_input, sc,
kbd->k_dev.dv_xname);
kbd_pckbport_input, sc, device_xname(self));
}
@ -382,7 +382,7 @@ kbd_pckbport_do_cmd(struct kbd_softc *kbd, int suncmd, int isioctl)
case KBD_CMD_NOCLICK:
/* not supported, do nothing */
DPRINTF(("%s: ignoring KIOCCMD 0x%02x\n",
kbd->k_dev.dv_xname, suncmd));
device_xname(kbd->k_dev), suncmd));
break;
default:
@ -462,7 +462,7 @@ kbd_pckbport_decode(struct kbd_pckbport_softc *sc, int data, int *sundata)
int sunkey;
/* XXX: DEBUG*/
DPRINTF(("%s: %02x", sc->sc_kbd.k_dev.dv_xname, data));
DPRINTF(("%s: %02x", device_xname(sc->sc_kbd.k_dev), data));
if (data == KBR_EXTENDED0) {
sc->sc_extended = 1;

View File

@ -1,4 +1,4 @@
/* $NetBSD: ms_pckbport.c,v 1.3 2006/06/07 22:38:49 kardel Exp $ */
/* $NetBSD: ms_pckbport.c,v 1.4 2008/04/07 13:31:15 tsutsui Exp $ */
/*
* Copyright (c) 2002 Valeriy E. Ushakov
@ -27,7 +27,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ms_pckbport.c,v 1.3 2006/06/07 22:38:49 kardel Exp $");
__KERNEL_RCSID(0, "$NetBSD: ms_pckbport.c,v 1.4 2008/04/07 13:31:15 tsutsui Exp $");
/*
* Attach PS/2 mouse at pckbport aux port
@ -67,10 +67,10 @@ struct ms_pckbport_softc {
int sc_enabled; /* input enabled? */
};
static int ms_pckbport_match(struct device *, struct cfdata *, void *);
static void ms_pckbport_attach(struct device *, struct device *, void *);
static int ms_pckbport_match(device_t, cfdata_t, void *);
static void ms_pckbport_attach(device_t, device_t, void *);
CFATTACH_DECL(ms_pckbport, sizeof(struct ms_pckbport_softc),
CFATTACH_DECL_NEW(ms_pckbport, sizeof(struct ms_pckbport_softc),
ms_pckbport_match, ms_pckbport_attach, NULL, NULL);
@ -80,7 +80,7 @@ static void ms_pckbport_input(void *, int);
static int
ms_pckbport_match(struct device *parent, struct cfdata *cf, void *aux)
ms_pckbport_match(device_t parent, cfdata_t cf, void *aux)
{
struct pckbport_attach_args *pa = aux;
@ -89,15 +89,17 @@ ms_pckbport_match(struct device *parent, struct cfdata *cf, void *aux)
static void
ms_pckbport_attach(struct device *parent, struct device *self, void *aux)
ms_pckbport_attach(device_t parent, device_t self, void *aux)
{
struct ms_pckbport_softc *sc = (struct ms_pckbport_softc *)self;
struct ms_pckbport_softc *sc = device_private(self);
struct ms_softc *ms = &sc->sc_ms;
struct pckbport_attach_args *pa = aux;
u_char cmd[1], resp[2];
int res;
ms->ms_dev = self;
/* save our pckbport attachment */
sc->sc_kbctag = pa->pa_tag;
sc->sc_kbcslot = pa->pa_slot;
@ -106,7 +108,7 @@ ms_pckbport_attach(struct device *parent, struct device *self, void *aux)
ms->ms_deviopen = ms_pckbport_iopen;
ms->ms_deviclose = ms_pckbport_iclose;
printf("\n");
aprint_normal("\n");
/* reset the device */
cmd[0] = PMS_RESET;
@ -114,20 +116,20 @@ ms_pckbport_attach(struct device *parent, struct device *self, void *aux)
cmd, 1, 2, resp, 1);
#ifdef DIAGNOSTIC
if (res || resp[0] != PMS_RSTDONE || resp[1] != 0) {
printf("ms_pckbport_attach: reset error\n");
aprint_error("%s: reset error\n", __func__);
/* return; */
}
#endif
pckbport_set_inputhandler(sc->sc_kbctag, sc->sc_kbcslot,
ms_pckbport_input, sc, ms->ms_dev.dv_xname);
ms_pckbport_input, sc, device_xname(self));
/* no interrupts until device is actually opened */
cmd[0] = PMS_DEV_DISABLE;
res = pckbport_poll_cmd(sc->sc_kbctag, sc->sc_kbcslot, cmd,
1, 0, 0, 0);
if (res)
printf("ms_pckbport_attach: failed to disable interrupts\n");
aprint_error("%s: failed to disable interrupts\n", __func__);
pckbport_slot_enable(sc->sc_kbctag, sc->sc_kbcslot, 0);
}
@ -135,7 +137,7 @@ ms_pckbport_attach(struct device *parent, struct device *self, void *aux)
static int
ms_pckbport_iopen(struct device *self, int flags)
{
struct ms_pckbport_softc *sc = (struct ms_pckbport_softc *)self;
struct ms_pckbport_softc *sc = device_private(self);
struct ms_softc *ms = &sc->sc_ms;
u_char cmd[1];
int res;
@ -162,7 +164,7 @@ ms_pckbport_iopen(struct device *self, int flags)
static int
ms_pckbport_iclose(struct device *self, int flags)
{
struct ms_pckbport_softc *sc = (struct ms_pckbport_softc *)self;
struct ms_pckbport_softc *sc = device_private(self);
u_char cmd[1];
int res;