Split device_t/softc.

This commit is contained in:
tsutsui 2010-10-17 14:13:44 +00:00
parent 5b17090754
commit 07d8ce4981
8 changed files with 123 additions and 119 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: maple.c,v 1.40 2008/10/19 14:05:49 mjf Exp $ */ /* $NetBSD: maple.c,v 1.41 2010/10/17 14:13:44 tsutsui Exp $ */
/*- /*-
* Copyright (c) 2002 The NetBSD Foundation, Inc. * Copyright (c) 2002 The NetBSD Foundation, Inc.
@ -62,7 +62,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: maple.c,v 1.40 2008/10/19 14:05:49 mjf Exp $"); __KERNEL_RCSID(0, "$NetBSD: maple.c,v 1.41 2010/10/17 14:13:44 tsutsui Exp $");
#include <sys/param.h> #include <sys/param.h>
#include <sys/device.h> #include <sys/device.h>
@ -107,8 +107,8 @@ __KERNEL_RCSID(0, "$NetBSD: maple.c,v 1.40 2008/10/19 14:05:49 mjf Exp $");
/* /*
* Function declarations. * Function declarations.
*/ */
static int maplematch(struct device *, struct cfdata *, void *); static int maplematch(device_t, cfdata_t, void *);
static void mapleattach(struct device *, struct device *, void *); static void mapleattach(device_t, device_t, void *);
static void maple_scanbus(struct maple_softc *); static void maple_scanbus(struct maple_softc *);
static char * maple_unit_name(char *, int port, int subunit); static char * maple_unit_name(char *, int port, int subunit);
static void maple_begin_txbuf(struct maple_softc *); static void maple_begin_txbuf(struct maple_softc *);
@ -157,7 +157,7 @@ void maple_free_dma(paddr_t, size_t);
*/ */
int maple_polling; /* Are we polling? (Debugger mode) */ int maple_polling; /* Are we polling? (Debugger mode) */
CFATTACH_DECL(maple, sizeof(struct maple_softc), CFATTACH_DECL_NEW(maple, sizeof(struct maple_softc),
maplematch, mapleattach, NULL, NULL); maplematch, mapleattach, NULL, NULL);
extern struct cfdriver maple_cd; extern struct cfdriver maple_cd;
@ -172,14 +172,14 @@ const struct cdevsw maple_cdevsw = {
}; };
static int static int
maplematch(struct device *parent, struct cfdata *cf, void *aux) maplematch(device_t parent, cfdata_t cf, void *aux)
{ {
return 1; return 1;
} }
static void static void
mapleattach(struct device *parent, struct device *self, void *aux) mapleattach(device_t parent, device_t self, void *aux)
{ {
struct maple_softc *sc; struct maple_softc *sc;
struct maple_unit *u; struct maple_unit *u;
@ -188,13 +188,14 @@ mapleattach(struct device *parent, struct device *self, void *aux)
uint32_t *p; uint32_t *p;
int port, subunit, f; int port, subunit, f;
sc = (struct maple_softc *)self; sc = device_private(self);
sc->sc_dev = self;
printf(": %s\n", sysasic_intr_string(IRL_MAPLE)); printf(": %s\n", sysasic_intr_string(IRL_MAPLE));
if (maple_alloc_dma(MAPLE_DMABUF_SIZE, &dmabuffer, &dmabuffer_phys)) { if (maple_alloc_dma(MAPLE_DMABUF_SIZE, &dmabuffer, &dmabuffer_phys)) {
printf("%s: unable to allocate DMA buffers.\n", printf("%s: unable to allocate DMA buffers.\n",
sc->sc_dev.dv_xname); device_xname(self));
return; return;
} }
@ -246,10 +247,10 @@ mapleattach(struct device *parent, struct device *self, void *aux)
config_pending_incr(); /* create thread before mounting root */ config_pending_incr(); /* create thread before mounting root */
if (kthread_create(PRI_NONE, 0, NULL, maple_event_thread, sc, if (kthread_create(PRI_NONE, 0, NULL, maple_event_thread, sc,
&sc->event_thread, "%s", sc->sc_dev.dv_xname) == 0) &sc->event_thread, "%s", device_xname(self)) == 0)
return; return;
panic("%s: unable to create event thread", sc->sc_dev.dv_xname); panic("%s: unable to create event thread", device_xname(self));
} }
/* /*
@ -304,13 +305,13 @@ maple_scanbus(struct maple_softc *sc)
} }
void void
maple_run_polling(struct device *dev) maple_run_polling(device_t dev)
{ {
struct maple_softc *sc; struct maple_softc *sc;
int port, subunit; int port, subunit;
int i; int i;
sc = (struct maple_softc *)dev; sc = device_private(dev);
/* /*
* first, make sure polling works * first, make sure polling works
@ -672,10 +673,10 @@ maple_attach_unit(struct maple_softc *sc, struct maple_unit *u)
ma.ma_basedevinfo = &sc->sc_unit[u->port][0].devinfo; ma.ma_basedevinfo = &sc->sc_unit[u->port][0].devinfo;
func = be32toh(ma.ma_devinfo->di_func); func = be32toh(ma.ma_devinfo->di_func);
maple_print_unit(&ma, sc->sc_dev.dv_xname); maple_print_unit(&ma, device_xname(sc->sc_dev));
printf("\n"); printf("\n");
strcpy(oldxname, sc->sc_dev.dv_xname); strcpy(oldxname, device_xname(sc->sc_dev));
maple_unit_name(sc->sc_dev.dv_xname, u->port, u->subunit); maple_unit_name(sc->sc_dev->dv_xname, u->port, u->subunit);
for (f = 0; f < MAPLE_NFUNC; f++) { for (f = 0; f < MAPLE_NFUNC; f++) {
u->u_func[f].f_callback = NULL; u->u_func[f].f_callback = NULL;
@ -684,7 +685,7 @@ maple_attach_unit(struct maple_softc *sc, struct maple_unit *u)
u->u_func[f].f_dev = NULL; u->u_func[f].f_dev = NULL;
if (func & MAPLE_FUNC(f)) { if (func & MAPLE_FUNC(f)) {
ma.ma_function = f; ma.ma_function = f;
u->u_func[f].f_dev = config_found_sm_loc(&sc->sc_dev, u->u_func[f].f_dev = config_found_sm_loc(sc->sc_dev,
"maple", NULL, &ma, mapleprint, maplesubmatch); "maple", NULL, &ma, mapleprint, maplesubmatch);
u->u_ping_func = f; /* XXX using largest func */ u->u_ping_func = f; /* XXX using largest func */
} }
@ -702,7 +703,7 @@ maple_attach_unit(struct maple_softc *sc, struct maple_unit *u)
u->u_ping_stat = MAPLE_PING_NORMAL; u->u_ping_stat = MAPLE_PING_NORMAL;
} }
#endif #endif
strcpy(sc->sc_dev.dv_xname, oldxname); strcpy(sc->sc_dev->dv_xname, oldxname);
sc->sc_port_units[u->port] |= 1 << u->subunit; sc->sc_port_units[u->port] |= 1 << u->subunit;
} }
@ -760,11 +761,11 @@ maple_detach_unit_nofix(struct maple_softc *sc, struct maple_unit *u)
if ((error = config_detach(fn->f_dev, DETACH_FORCE))) { if ((error = config_detach(fn->f_dev, DETACH_FORCE))) {
printf("%s: failed to detach %s (func %d), errno %d\n", printf("%s: failed to detach %s (func %d), errno %d\n",
maple_unit_name(buf, port, u->subunit), maple_unit_name(buf, port, u->subunit),
fn->f_dev->dv_xname, fn->f_funcno, error); device_xname(fn->f_dev), fn->f_funcno, error);
} }
} }
maple_enable_periodic(&sc->sc_dev, u, fn->f_funcno, 0); maple_enable_periodic(sc->sc_dev, u, fn->f_funcno, 0);
fn->f_dev = NULL; fn->f_dev = NULL;
fn->f_callback = NULL; fn->f_callback = NULL;
@ -821,10 +822,10 @@ maple_detach_unit(struct maple_softc *sc, struct maple_unit *u)
* Only one command (per function) is valid at a time. * Only one command (per function) is valid at a time.
*/ */
void void
maple_command(struct device *dev, struct maple_unit *u, int func, maple_command(device_t dev, struct maple_unit *u, int func,
int command, int datalen, const void *dataaddr, int flags) int command, int datalen, const void *dataaddr, int flags)
{ {
struct maple_softc *sc = (void *) dev; struct maple_softc *sc = device_private(dev);
struct maple_func *fn; struct maple_func *fn;
int s; int s;
@ -943,11 +944,10 @@ maple_unit_probe(struct maple_softc *sc)
*/ */
/* ARGSUSED */ /* ARGSUSED */
void void
maple_enable_unit_ping(struct device *dev, struct maple_unit *u, maple_enable_unit_ping(device_t dev, struct maple_unit *u, int func, int enable)
int func, int enable)
{ {
#if 0 /* currently unused */ #if 0 /* currently unused */
struct maple_softc *sc = (void *) dev; struct maple_softc *sc = device_private(dev);
#endif #endif
if (enable) if (enable)
@ -1002,10 +1002,9 @@ maple_unit_ping(struct maple_softc *sc)
* Enable/disable periodic GETCOND (called by drivers) * Enable/disable periodic GETCOND (called by drivers)
*/ */
void void
maple_enable_periodic(struct device *dev, struct maple_unit *u, maple_enable_periodic(device_t dev, struct maple_unit *u, int func, int on)
int func, int on)
{ {
struct maple_softc *sc = (void *) dev; struct maple_softc *sc = device_private(dev);
struct maple_func *fn; struct maple_func *fn;
KASSERT(func >= 0 && func < 32); KASSERT(func >= 0 && func < 32);
@ -1422,7 +1421,7 @@ maple_event_thread(void *arg)
#ifdef MAPLE_DEBUG #ifdef MAPLE_DEBUG
printf("%s: forked event thread, pid %d\n", printf("%s: forked event thread, pid %d\n",
sc->sc_dev.dv_xname, sc->event_thread->l_proc->p_pid); device_xname(sc->sc_dev), sc->event_thread->l_proc->p_pid);
#endif #endif
/* begin first DMA cycle */ /* begin first DMA cycle */
@ -1487,7 +1486,8 @@ maple_event_thread(void *arg)
if (tsleep(&sc->sc_dmadone, PWAIT, "mdma", hz) if (tsleep(&sc->sc_dmadone, PWAIT, "mdma", hz)
== EWOULDBLOCK) { == EWOULDBLOCK) {
/* was DDB active? */ /* was DDB active? */
printf("%s: timed out\n", sc->sc_dev.dv_xname); printf("%s: timed out\n",
device_xname(sc->sc_dev));
} }
splx(s); splx(s);
@ -1506,7 +1506,7 @@ maple_event_thread(void *arg)
if (noreq) /* ignore first time */ if (noreq) /* ignore first time */
#endif #endif
printf("%s: no request %d\n", printf("%s: no request %d\n",
sc->sc_dev.dv_xname, noreq); device_xname(sc->sc_dev), noreq);
noreq++; noreq++;
} }
#endif #endif
@ -1520,7 +1520,7 @@ maple_event_thread(void *arg)
if (tsleep(&sc->sc_event, PWAIT, "mslp", hz) if (tsleep(&sc->sc_event, PWAIT, "mslp", hz)
== EWOULDBLOCK) { == EWOULDBLOCK) {
printf("%s: event timed out\n", printf("%s: event timed out\n",
sc->sc_dev.dv_xname); device_xname(sc->sc_dev));
} }
} }
@ -1558,11 +1558,11 @@ maple_callout(void *ctx)
*/ */
/* ARGSUSED */ /* ARGSUSED */
void void
maple_set_callback(struct device *dev, struct maple_unit *u, int func, maple_set_callback(device_t dev, struct maple_unit *u, int func,
void (*callback)(void *, struct maple_response *, int, int), void *arg) void (*callback)(void *, struct maple_response *, int, int), void *arg)
{ {
#if 0 /* currently unused */ #if 0 /* currently unused */
struct maple_softc *sc = (void *) dev; struct maple_softc *sc = device_private(dev);
#endif #endif
struct maple_func *fn; struct maple_func *fn;
@ -1634,10 +1634,10 @@ mapleclose(dev_t dev, int flag, int mode, struct lwp *l)
} }
int int
maple_unit_ioctl(struct device *dev, struct maple_unit *u, u_long cmd, maple_unit_ioctl(device_t dev, struct maple_unit *u, u_long cmd,
void *data, int flag, struct lwp *l) void *data, int flag, struct lwp *l)
{ {
struct maple_softc *sc = (struct maple_softc *)dev; struct maple_softc *sc = device_private(dev);
if (!(sc->sc_port_units[u->port] & (1 << u->subunit))) if (!(sc->sc_port_units[u->port] & (1 << u->subunit)))
return ENXIO; return ENXIO;
@ -1662,5 +1662,5 @@ mapleioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
sc = device_lookup_private(&maple_cd, MAPLEBUSUNIT(dev)); sc = device_lookup_private(&maple_cd, MAPLEBUSUNIT(dev));
u = &sc->sc_unit[MAPLEPORT(dev)][MAPLESUBUNIT(dev)]; u = &sc->sc_unit[MAPLEPORT(dev)][MAPLESUBUNIT(dev)];
return maple_unit_ioctl(&sc->sc_dev, u, cmd, data, flag, l); return maple_unit_ioctl(sc->sc_dev, u, cmd, data, flag, l);
} }

View File

@ -1,4 +1,4 @@
/* $NetBSD: maple.h,v 1.11 2008/04/28 20:23:16 martin Exp $ */ /* $NetBSD: maple.h,v 1.12 2010/10/17 14:13:44 tsutsui Exp $ */
/*- /*-
* Copyright (c) 2002 The NetBSD Foundation, Inc. * Copyright (c) 2002 The NetBSD Foundation, Inc.
@ -128,19 +128,19 @@ struct maple_response {
struct maple_unit; struct maple_unit;
extern void maple_set_callback(struct device *, struct maple_unit *, int, void maple_set_callback(device_t, struct maple_unit *, int,
void (*)(void *, struct maple_response *, int, int), void (*)(void *, struct maple_response *, int, int),
void *); void *);
extern void maple_enable_unit_ping(struct device *, struct maple_unit *, void maple_enable_unit_ping(device_t, struct maple_unit *,
int /*func*/, int /*enable*/); int /*func*/, int /*enable*/);
extern void maple_enable_periodic(struct device *, struct maple_unit *, void maple_enable_periodic(device_t, struct maple_unit *,
int /*func*/, int /*on*/); int /*func*/, int /*on*/);
extern void maple_command(struct device *, struct maple_unit *, void maple_command(device_t, struct maple_unit *,
int /*func*/, int /*command*/, int /*datalen*/, int /*func*/, int /*command*/, int /*datalen*/,
const void *, int /*flags*/); const void *, int /*flags*/);
extern uint32_t maple_get_function_data(struct maple_devinfo *, int); uint32_t maple_get_function_data(struct maple_devinfo *, int);
extern void maple_run_polling(struct device *); void maple_run_polling(device_t);
extern int maple_unit_ioctl(struct device *, struct maple_unit *, int maple_unit_ioctl(device_t, struct maple_unit *,
u_long, void *, int, struct lwp *); u_long, void *, int, struct lwp *);
#endif /* _DREAMCAST_DEV_MAPLE_MAPLE_H_ */ #endif /* _DREAMCAST_DEV_MAPLE_MAPLE_H_ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: maplevar.h,v 1.12 2008/04/28 20:23:16 martin Exp $ */ /* $NetBSD: maplevar.h,v 1.13 2010/10/17 14:13:44 tsutsui Exp $ */
/*- /*-
* Copyright (c) 2002 The NetBSD Foundation, Inc. * Copyright (c) 2002 The NetBSD Foundation, Inc.
@ -166,7 +166,7 @@ struct maple_unit {
}; };
struct maple_softc { struct maple_softc {
struct device sc_dev; device_t sc_dev;
callout_t maple_callout_ch; callout_t maple_callout_ch;
lwp_t *event_thread; lwp_t *event_thread;

View File

@ -1,4 +1,4 @@
/* $NetBSD: mkbd.c,v 1.27 2008/10/19 21:24:20 marcus Exp $ */ /* $NetBSD: mkbd.c,v 1.28 2010/10/17 14:13:44 tsutsui Exp $ */
/*- /*-
* Copyright (c) 2001 Marcus Comstedt * Copyright (c) 2001 Marcus Comstedt
@ -33,7 +33,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: mkbd.c,v 1.27 2008/10/19 21:24:20 marcus Exp $"); __KERNEL_RCSID(0, "$NetBSD: mkbd.c,v 1.28 2010/10/17 14:13:44 tsutsui Exp $");
#include <sys/param.h> #include <sys/param.h>
#include <sys/device.h> #include <sys/device.h>
@ -62,9 +62,9 @@ __KERNEL_RCSID(0, "$NetBSD: mkbd.c,v 1.27 2008/10/19 21:24:20 marcus Exp $");
/* /*
* Function declarations. * Function declarations.
*/ */
static int mkbdmatch(struct device *, struct cfdata *, void *); static int mkbdmatch(device_t, cfdata_t, void *);
static void mkbdattach(struct device *, struct device *, void *); static void mkbdattach(device_t, device_t, void *);
static int mkbddetach(struct device *, int); static int mkbddetach(device_t, int);
int mkbd_enable(void *, int); int mkbd_enable(void *, int);
void mkbd_set_leds(void *, int); void mkbd_set_leds(void *, int);
@ -97,11 +97,11 @@ static struct mkbd_softc *mkbd_console_softc;
static int mkbd_is_console; static int mkbd_is_console;
static int mkbd_console_initted; static int mkbd_console_initted;
CFATTACH_DECL(mkbd, sizeof(struct mkbd_softc), CFATTACH_DECL_NEW(mkbd, sizeof(struct mkbd_softc),
mkbdmatch, mkbdattach, mkbddetach, NULL); mkbdmatch, mkbdattach, mkbddetach, NULL);
static int static int
mkbdmatch(struct device *parent, struct cfdata *cf, void *aux) mkbdmatch(device_t parent, cfdata_t cf, void *aux)
{ {
struct maple_attach_args *ma = aux; struct maple_attach_args *ma = aux;
@ -109,15 +109,16 @@ mkbdmatch(struct device *parent, struct cfdata *cf, void *aux)
} }
static void static void
mkbdattach(struct device *parent, struct device *self, void *aux) mkbdattach(device_t parent, device_t self, void *aux)
{ {
struct mkbd_softc *sc = (struct mkbd_softc *) self; struct mkbd_softc *sc = device_private(self);
struct maple_attach_args *ma = aux; struct maple_attach_args *ma = aux;
#if NWSKBD > 0 #if NWSKBD > 0
struct wskbddev_attach_args a; struct wskbddev_attach_args a;
#endif #endif
uint32_t kbdtype; uint32_t kbdtype;
sc->sc_dev = self;
sc->sc_parent = parent; sc->sc_parent = parent;
sc->sc_unit = ma->ma_unit; sc->sc_unit = ma->ma_unit;
@ -168,9 +169,9 @@ mkbdattach(struct device *parent, struct device *self, void *aux)
} }
static int static int
mkbddetach(struct device *self, int flags) mkbddetach(device_t self, int flags)
{ {
struct mkbd_softc *sc = (struct mkbd_softc *) self; struct mkbd_softc *sc = device_private(self);
int rv = 0; int rv = 0;
if (sc == mkbd_console_softc) { if (sc == mkbd_console_softc) {
@ -178,7 +179,7 @@ mkbddetach(struct device *self, int flags)
* Hack to allow another Maple keyboard to be new console. * Hack to allow another Maple keyboard to be new console.
* XXX Should some other type device can be console. * XXX Should some other type device can be console.
*/ */
printf("%s: was console keyboard\n", sc->sc_dev.dv_xname); printf("%s: was console keyboard\n", device_xname(sc->sc_dev));
wskbd_cndetach(); wskbd_cndetach();
mkbd_console_softc = NULL; mkbd_console_softc = NULL;
mkbd_console_initted = 0; mkbd_console_initted = 0;

View File

@ -1,4 +1,4 @@
/* $NetBSD: mkbdvar.h,v 1.6 2005/12/11 12:17:06 christos Exp $ */ /* $NetBSD: mkbdvar.h,v 1.7 2010/10/17 14:13:44 tsutsui Exp $ */
/*- /*-
* Copyright (c) 2001 Marcus Comstedt * Copyright (c) 2001 Marcus Comstedt
@ -43,9 +43,9 @@ struct mkbd_condition {
* State info, per keyboard instance. * State info, per keyboard instance.
*/ */
struct mkbd_softc { struct mkbd_softc {
struct device sc_dev; device_t sc_dev;
struct device *sc_wskbddev; device_t sc_wskbddev;
struct device *sc_parent; device_t sc_parent;
struct maple_unit *sc_unit; struct maple_unit *sc_unit;
struct mkbd_condition sc_condition; struct mkbd_condition sc_condition;

View File

@ -1,4 +1,4 @@
/* $NetBSD: mlcd.c,v 1.12 2010/02/24 22:58:45 dyoung Exp $ */ /* $NetBSD: mlcd.c,v 1.13 2010/10/17 14:13:44 tsutsui Exp $ */
/*- /*-
* Copyright (c) 2002 The NetBSD Foundation, Inc. * Copyright (c) 2002 The NetBSD Foundation, Inc.
@ -30,7 +30,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: mlcd.c,v 1.12 2010/02/24 22:58:45 dyoung Exp $"); __KERNEL_RCSID(0, "$NetBSD: mlcd.c,v 1.13 2010/10/17 14:13:44 tsutsui Exp $");
#include <sys/param.h> #include <sys/param.h>
#include <sys/device.h> #include <sys/device.h>
@ -91,7 +91,7 @@ struct mlcd_buf {
#define MLCD_BUF_SZ(sc) (offsetof(struct mlcd_buf, lb_data) + (sc)->sc_bsize) #define MLCD_BUF_SZ(sc) (offsetof(struct mlcd_buf, lb_data) + (sc)->sc_bsize)
struct mlcd_softc { struct mlcd_softc {
struct device sc_dev; device_t sc_dev;
device_t sc_parent; device_t sc_parent;
struct maple_unit *sc_unit; struct maple_unit *sc_unit;
@ -148,7 +148,7 @@ struct mlcd_softc {
#define MLCD_UNIT(dev) (minor(dev) >> 8) #define MLCD_UNIT(dev) (minor(dev) >> 8)
#define MLCD_MINOR(unit, part) (((unit) << 8) | (part)) #define MLCD_MINOR(unit, part) (((unit) << 8) | (part))
static int mlcdmatch(device_t, struct cfdata *, void *); static int mlcdmatch(device_t, cfdata_t, void *);
static void mlcdattach(device_t, device_t, void *); static void mlcdattach(device_t, device_t, void *);
static int mlcddetach(device_t, int); static int mlcddetach(device_t, int);
static void mlcd_intr(void *, struct maple_response *, int, int); static void mlcd_intr(void *, struct maple_response *, int, int);
@ -171,7 +171,7 @@ const struct cdevsw mlcd_cdevsw = {
nostop, notty, nopoll, nommap, nokqfilter nostop, notty, nopoll, nommap, nokqfilter
}; };
CFATTACH_DECL(mlcd, sizeof(struct mlcd_softc), CFATTACH_DECL_NEW(mlcd, sizeof(struct mlcd_softc),
mlcdmatch, mlcdattach, mlcddetach, NULL); mlcdmatch, mlcdattach, mlcddetach, NULL);
extern struct cfdriver mlcd_cd; extern struct cfdriver mlcd_cd;
@ -198,7 +198,7 @@ static const char initimg48x32[192] = {
/* ARGSUSED */ /* ARGSUSED */
static int static int
mlcdmatch(device_t parent, struct cfdata *cf, void *aux) mlcdmatch(device_t parent, cfdata_t cf, void *aux)
{ {
struct maple_attach_args *ma = aux; struct maple_attach_args *ma = aux;
@ -216,6 +216,7 @@ mlcdattach(device_t parent, device_t self, void *aux)
struct mlcd_funcdef s; struct mlcd_funcdef s;
} funcdef; } funcdef;
sc->sc_dev = self;
sc->sc_parent = parent; sc->sc_parent = parent;
sc->sc_unit = ma->ma_unit; sc->sc_unit = ma->ma_unit;
sc->sc_direction = ma->ma_basedevinfo->di_connector_direction; sc->sc_direction = ma->ma_basedevinfo->di_connector_direction;
@ -223,7 +224,7 @@ mlcdattach(device_t parent, device_t self, void *aux)
funcdef.v = maple_get_function_data(ma->ma_devinfo, MAPLE_FN_LCD); funcdef.v = maple_get_function_data(ma->ma_devinfo, MAPLE_FN_LCD);
printf(": LCD display\n"); printf(": LCD display\n");
printf("%s: %d LCD, %d bytes/block, ", printf("%s: %d LCD, %d bytes/block, ",
sc->sc_dev.dv_xname, device_xname(self),
sc->sc_npt = funcdef.s.pt + 1, sc->sc_npt = funcdef.s.pt + 1,
sc->sc_bsize = (funcdef.s.bb + 1) << 5); sc->sc_bsize = (funcdef.s.bb + 1) << 5);
if ((sc->sc_wacc = funcdef.s.wa) == 0) if ((sc->sc_wacc = funcdef.s.wa) == 0)
@ -246,17 +247,17 @@ mlcdattach(device_t parent, device_t self, void *aux)
sc->sc_waccsz = sc->sc_bsize / sc->sc_wacc; sc->sc_waccsz = sc->sc_bsize / sc->sc_wacc;
if (sc->sc_bsize != sc->sc_waccsz * sc->sc_wacc) { if (sc->sc_bsize != sc->sc_waccsz * sc->sc_wacc) {
printf("%s: write access isn't equally divided\n", printf("%s: write access isn't equally divided\n",
sc->sc_dev.dv_xname); device_xname(self));
sc->sc_wacc = 0; /* no write */ sc->sc_wacc = 0; /* no write */
} else if (sc->sc_waccsz > MLCD_MAXACCSIZE) { } else if (sc->sc_waccsz > MLCD_MAXACCSIZE) {
printf("%s: write access size is too large\n", printf("%s: write access size is too large\n",
sc->sc_dev.dv_xname); device_xname(self));
sc->sc_wacc = 0; /* no write */ sc->sc_wacc = 0; /* no write */
} }
} }
if (sc->sc_wacc == 0) { if (sc->sc_wacc == 0) {
printf("%s: device doesn't support write\n", printf("%s: device doesn't support write\n",
sc->sc_dev.dv_xname); device_xname(self));
return; return;
} }
@ -265,7 +266,7 @@ mlcdattach(device_t parent, device_t self, void *aux)
M_WAITOK|M_ZERO); M_WAITOK|M_ZERO);
for (i = 0; i < sc->sc_npt; i++) { for (i = 0; i < sc->sc_npt; i++) {
sprintf(sc->sc_pt[i].pt_name, "%s.%d", sc->sc_dev.dv_xname, i); sprintf(sc->sc_pt[i].pt_name, "%s.%d", device_xname(self), i);
} }
maple_set_callback(parent, sc->sc_unit, MAPLE_FN_LCD, maple_set_callback(parent, sc->sc_unit, MAPLE_FN_LCD,
@ -324,9 +325,9 @@ mlcddetach(device_t self, int flags)
*/ */
/* ARGSUSED3 */ /* ARGSUSED3 */
static void static void
mlcd_intr(void *dev, struct maple_response *response, int sz, int flags) mlcd_intr(void *arg, struct maple_response *response, int sz, int flags)
{ {
struct mlcd_softc *sc = dev; struct mlcd_softc *sc = arg;
struct mlcd_response_media_info *rm = (void *) response->data; struct mlcd_response_media_info *rm = (void *) response->data;
struct mlcd_buf *bp; struct mlcd_buf *bp;
int part; int part;

View File

@ -1,4 +1,4 @@
/* $NetBSD: mmemcard.c,v 1.18 2009/01/13 13:35:51 yamt Exp $ */ /* $NetBSD: mmemcard.c,v 1.19 2010/10/17 14:13:44 tsutsui Exp $ */
/*- /*-
* Copyright (c) 2002 The NetBSD Foundation, Inc. * Copyright (c) 2002 The NetBSD Foundation, Inc.
@ -30,7 +30,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: mmemcard.c,v 1.18 2009/01/13 13:35:51 yamt Exp $"); __KERNEL_RCSID(0, "$NetBSD: mmemcard.c,v 1.19 2010/10/17 14:13:44 tsutsui Exp $");
#include <sys/param.h> #include <sys/param.h>
#include <sys/buf.h> #include <sys/buf.h>
@ -102,9 +102,9 @@ struct mmem_response_media_info {
}; };
struct mmem_softc { struct mmem_softc {
struct device sc_dev; device_t sc_dev;
struct device *sc_parent; device_t sc_parent;
struct maple_unit *sc_unit; struct maple_unit *sc_unit;
struct maple_devinfo *sc_devinfo; struct maple_devinfo *sc_devinfo;
@ -167,11 +167,11 @@ struct mmem_softc {
#define MMEM_DISKMINOR(unit, part, disklabel_partition) \ #define MMEM_DISKMINOR(unit, part, disklabel_partition) \
DISKMINOR(((unit) << 8) | (part), (disklabel_partition)) DISKMINOR(((unit) << 8) | (part), (disklabel_partition))
static int mmemmatch(struct device *, struct cfdata *, void *); static int mmemmatch(device_t, cfdata_t, void *);
static void mmemattach(struct device *, struct device *, void *); static void mmemattach(device_t, device_t, void *);
static void mmem_defaultlabel(struct mmem_softc *, struct mmem_pt *, static void mmem_defaultlabel(struct mmem_softc *, struct mmem_pt *,
struct disklabel *); struct disklabel *);
static int mmemdetach(struct device *, int); static int mmemdetach(device_t, int);
static void mmem_intr(void *, struct maple_response *, int, int); static void mmem_intr(void *, struct maple_response *, int, int);
static void mmem_printerror(const char *, int, int, uint32_t); static void mmem_printerror(const char *, int, int, uint32_t);
static void mmemstart(struct mmem_softc *); static void mmemstart(struct mmem_softc *);
@ -196,7 +196,7 @@ const struct cdevsw mmem_cdevsw = {
nostop, notty, nopoll, nommap, nokqfilter, D_DISK nostop, notty, nopoll, nommap, nokqfilter, D_DISK
}; };
CFATTACH_DECL(mmem, sizeof(struct mmem_softc), CFATTACH_DECL_NEW(mmem, sizeof(struct mmem_softc),
mmemmatch, mmemattach, mmemdetach, NULL); mmemmatch, mmemattach, mmemdetach, NULL);
extern struct cfdriver mmem_cd; extern struct cfdriver mmem_cd;
@ -204,7 +204,7 @@ extern struct cfdriver mmem_cd;
struct dkdriver mmemdkdriver = { mmemstrategy }; struct dkdriver mmemdkdriver = { mmemstrategy };
static int static int
mmemmatch(struct device *parent, struct cfdata *cf, void *aux) mmemmatch(device_t parent, cfdata_t cf, void *aux)
{ {
struct maple_attach_args *ma = aux; struct maple_attach_args *ma = aux;
@ -212,9 +212,9 @@ mmemmatch(struct device *parent, struct cfdata *cf, void *aux)
} }
static void static void
mmemattach(struct device *parent, struct device *self, void *aux) mmemattach(device_t parent, device_t self, void *aux)
{ {
struct mmem_softc *sc = (void *)self; struct mmem_softc *sc = device_private(self);
struct maple_attach_args *ma = aux; struct maple_attach_args *ma = aux;
int i; int i;
union { union {
@ -222,6 +222,7 @@ mmemattach(struct device *parent, struct device *self, void *aux)
struct mmem_funcdef s; struct mmem_funcdef s;
} funcdef; } funcdef;
sc->sc_dev = self;
sc->sc_parent = parent; sc->sc_parent = parent;
sc->sc_unit = ma->ma_unit; sc->sc_unit = ma->ma_unit;
sc->sc_devinfo = ma->ma_devinfo; sc->sc_devinfo = ma->ma_devinfo;
@ -229,7 +230,7 @@ mmemattach(struct device *parent, struct device *self, void *aux)
funcdef.v = maple_get_function_data(ma->ma_devinfo, MAPLE_FN_MEMCARD); funcdef.v = maple_get_function_data(ma->ma_devinfo, MAPLE_FN_MEMCARD);
printf(": Memory card\n"); printf(": Memory card\n");
printf("%s: %d part, %d bytes/block, ", printf("%s: %d part, %d bytes/block, ",
sc->sc_dev.dv_xname, device_xname(self),
sc->sc_npt = funcdef.s.pt + 1, sc->sc_npt = funcdef.s.pt + 1,
sc->sc_bsize = (funcdef.s.bb + 1) << 5); sc->sc_bsize = (funcdef.s.bb + 1) << 5);
if ((sc->sc_wacc = funcdef.s.wa) == 0) if ((sc->sc_wacc = funcdef.s.wa) == 0)
@ -252,11 +253,11 @@ mmemattach(struct device *parent, struct device *self, void *aux)
sc->sc_waccsz = sc->sc_bsize / sc->sc_wacc; sc->sc_waccsz = sc->sc_bsize / sc->sc_wacc;
if (sc->sc_bsize != sc->sc_waccsz * sc->sc_wacc) { if (sc->sc_bsize != sc->sc_waccsz * sc->sc_wacc) {
printf("%s: write access isn't equally divided\n", printf("%s: write access isn't equally divided\n",
sc->sc_dev.dv_xname); device_xname(self));
sc->sc_wacc = 0; /* no write */ sc->sc_wacc = 0; /* no write */
} else if (sc->sc_waccsz > MMEM_MAXACCSIZE) { } else if (sc->sc_waccsz > MMEM_MAXACCSIZE) {
printf("%s: write access size is too large\n", printf("%s: write access size is too large\n",
sc->sc_dev.dv_xname); device_xname(self));
sc->sc_wacc = 0; /* no write */ sc->sc_wacc = 0; /* no write */
} }
} }
@ -264,17 +265,17 @@ mmemattach(struct device *parent, struct device *self, void *aux)
sc->sc_raccsz = sc->sc_bsize / sc->sc_racc; sc->sc_raccsz = sc->sc_bsize / sc->sc_racc;
if (sc->sc_bsize != sc->sc_raccsz * sc->sc_racc) { if (sc->sc_bsize != sc->sc_raccsz * sc->sc_racc) {
printf("%s: read access isn't equally divided\n", printf("%s: read access isn't equally divided\n",
sc->sc_dev.dv_xname); device_xname(self));
sc->sc_racc = 0; /* no read */ sc->sc_racc = 0; /* no read */
} else if (sc->sc_raccsz > MMEM_MAXACCSIZE) { } else if (sc->sc_raccsz > MMEM_MAXACCSIZE) {
printf("%s: read access size is too large\n", printf("%s: read access size is too large\n",
sc->sc_dev.dv_xname); device_xname(self));
sc->sc_racc = 0; /* no read */ sc->sc_racc = 0; /* no read */
} }
} }
if (sc->sc_wacc == 0 && sc->sc_racc == 0) { if (sc->sc_wacc == 0 && sc->sc_racc == 0) {
printf("%s: device doesn't support read nor write\n", printf("%s: device doesn't support read nor write\n",
sc->sc_dev.dv_xname); device_xname(self));
return; return;
} }
@ -283,7 +284,7 @@ mmemattach(struct device *parent, struct device *self, void *aux)
M_WAITOK|M_ZERO); M_WAITOK|M_ZERO);
for (i = 0; i < sc->sc_npt; i++) { for (i = 0; i < sc->sc_npt; i++) {
sprintf(sc->sc_pt[i].pt_name, "%s.%d", sc->sc_dev.dv_xname, i); sprintf(sc->sc_pt[i].pt_name, "%s.%d", device_xname(self), i);
} }
maple_set_callback(parent, sc->sc_unit, MAPLE_FN_MEMCARD, maple_set_callback(parent, sc->sc_unit, MAPLE_FN_MEMCARD,
@ -299,9 +300,9 @@ mmemattach(struct device *parent, struct device *self, void *aux)
} }
static int static int
mmemdetach(struct device *self, int flags) mmemdetach(device_t self, int flags)
{ {
struct mmem_softc *sc = (struct mmem_softc *) self; struct mmem_softc *sc = device_private(self);
struct buf *bp; struct buf *bp;
int i; int i;
int minor_l, minor_h; int minor_l, minor_h;
@ -386,9 +387,9 @@ mmem_defaultlabel(struct mmem_softc *sc, struct mmem_pt *pt,
* called back from maple bus driver * called back from maple bus driver
*/ */
static void static void
mmem_intr(void *dev, struct maple_response *response, int sz, int flags) mmem_intr(void *arg, struct maple_response *response, int sz, int flags)
{ {
struct mmem_softc *sc = dev; struct mmem_softc *sc = arg;
struct mmem_response_read_data *r = (void *) response->data; struct mmem_response_read_data *r = (void *) response->data;
struct mmem_response_media_info *rm = (void *) response->data; struct mmem_response_media_info *rm = (void *) response->data;
struct buf *bp; struct buf *bp;

View File

@ -1,4 +1,4 @@
/* $NetBSD: mms.c,v 1.14 2008/04/28 20:23:16 martin Exp $ */ /* $NetBSD: mms.c,v 1.15 2010/10/17 14:13:44 tsutsui Exp $ */
/*- /*-
* Copyright (c) 2001 The NetBSD Foundation, Inc. * Copyright (c) 2001 The NetBSD Foundation, Inc.
@ -30,7 +30,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: mms.c,v 1.14 2008/04/28 20:23:16 martin Exp $"); __KERNEL_RCSID(0, "$NetBSD: mms.c,v 1.15 2010/10/17 14:13:44 tsutsui Exp $");
#include <sys/param.h> #include <sys/param.h>
#include <sys/device.h> #include <sys/device.h>
@ -81,9 +81,9 @@ struct mms_condition {
#define MMS_FUNCDATA_START 0x800 #define MMS_FUNCDATA_START 0x800
struct mms_softc { struct mms_softc {
struct device sc_dev; device_t sc_dev;
struct device *sc_parent; device_t sc_parent;
struct maple_unit *sc_unit; struct maple_unit *sc_unit;
uint32_t sc_oldbuttons; uint32_t sc_oldbuttons;
@ -91,11 +91,11 @@ struct mms_softc {
struct device *sc_wsmousedev; struct device *sc_wsmousedev;
}; };
int mms_match(struct device *, struct cfdata *, void *); int mms_match(device_t, cfdata_t, void *);
void mms_attach(struct device *, struct device *, void *); void mms_attach(device_t, device_t, void *);
int mms_detach(struct device *, int); int mms_detach(device_t, int);
CFATTACH_DECL(mms, sizeof(struct mms_softc), CFATTACH_DECL_NEW(mms, sizeof(struct mms_softc),
mms_match, mms_attach, mms_detach, NULL); mms_match, mms_attach, mms_detach, NULL);
int mms_enable(void *); int mms_enable(void *);
@ -111,7 +111,7 @@ const struct wsmouse_accessops mms_accessops = {
void mms_intr(void *, struct maple_response *, int, int); void mms_intr(void *, struct maple_response *, int, int);
int int
mms_match(struct device *parent, struct cfdata *cf, void *aux) mms_match(device_t parent, cfdata_t cf, void *aux)
{ {
struct maple_attach_args *ma = aux; struct maple_attach_args *ma = aux;
@ -119,22 +119,23 @@ mms_match(struct device *parent, struct cfdata *cf, void *aux)
} }
void void
mms_attach(struct device *parent, struct device *self, void *aux) mms_attach(device_t parent, device_t self, void *aux)
{ {
struct mms_softc *sc = (void *) self; struct mms_softc *sc = device_private(self);
struct maple_attach_args *ma = aux; struct maple_attach_args *ma = aux;
struct wsmousedev_attach_args a; struct wsmousedev_attach_args a;
uint32_t data; uint32_t data;
printf(": SEGA Dreamcast Mouse\n"); printf(": SEGA Dreamcast Mouse\n");
sc->sc_dev = self;
sc->sc_parent = parent; sc->sc_parent = parent;
sc->sc_unit = ma->ma_unit; sc->sc_unit = ma->ma_unit;
data = maple_get_function_data(ma->ma_devinfo, data = maple_get_function_data(ma->ma_devinfo,
MAPLE_FN_MOUSE); MAPLE_FN_MOUSE);
printf("%s: buttons:", sc->sc_dev.dv_xname); printf("%s: buttons:", device_xname(self));
if (data & MMS_FUNCDATA_A) if (data & MMS_FUNCDATA_A)
printf(" left"); printf(" left");
if (data & MMS_FUNCDATA_C) if (data & MMS_FUNCDATA_C)
@ -163,9 +164,9 @@ mms_attach(struct device *parent, struct device *self, void *aux)
} }
int int
mms_detach(struct device *self, int flags) mms_detach(device_t self, int flags)
{ {
struct mms_softc *sc = (void *) self; struct mms_softc *sc = device_private(self);
int rv = 0; int rv = 0;
if (sc->sc_wsmousedev != NULL) if (sc->sc_wsmousedev != NULL)