Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/dreamcast/dev/maple Split device_t/softc.
details: https://anonhg.NetBSD.org/src/rev/ec0a2746f25d
branches: trunk
changeset: 758084:ec0a2746f25d
user: tsutsui <tsutsui%NetBSD.org@localhost>
date: Sun Oct 17 14:13:44 2010 +0000
description:
Split device_t/softc.
diffstat:
sys/arch/dreamcast/dev/maple/maple.c | 74 ++++++++++++++++----------------
sys/arch/dreamcast/dev/maple/maple.h | 30 ++++++------
sys/arch/dreamcast/dev/maple/maplevar.h | 4 +-
sys/arch/dreamcast/dev/maple/mkbd.c | 25 +++++-----
sys/arch/dreamcast/dev/maple/mkbdvar.h | 8 +-
sys/arch/dreamcast/dev/maple/mlcd.c | 27 ++++++-----
sys/arch/dreamcast/dev/maple/mmemcard.c | 45 ++++++++++---------
sys/arch/dreamcast/dev/maple/mms.c | 29 ++++++------
8 files changed, 123 insertions(+), 119 deletions(-)
diffs (truncated from 793 to 300 lines):
diff -r 2ba3c6c246fb -r ec0a2746f25d sys/arch/dreamcast/dev/maple/maple.c
--- a/sys/arch/dreamcast/dev/maple/maple.c Sun Oct 17 12:45:28 2010 +0000
+++ b/sys/arch/dreamcast/dev/maple/maple.c Sun Oct 17 14:13:44 2010 +0000
@@ -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.
@@ -62,7 +62,7 @@
*/
#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/device.h>
@@ -107,8 +107,8 @@
/*
* Function declarations.
*/
-static int maplematch(struct device *, struct cfdata *, void *);
-static void mapleattach(struct device *, struct device *, void *);
+static int maplematch(device_t, cfdata_t, void *);
+static void mapleattach(device_t, device_t, void *);
static void maple_scanbus(struct maple_softc *);
static char * maple_unit_name(char *, int port, int subunit);
static void maple_begin_txbuf(struct maple_softc *);
@@ -157,7 +157,7 @@
*/
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);
extern struct cfdriver maple_cd;
@@ -172,14 +172,14 @@
};
static int
-maplematch(struct device *parent, struct cfdata *cf, void *aux)
+maplematch(device_t parent, cfdata_t cf, void *aux)
{
return 1;
}
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_unit *u;
@@ -188,13 +188,14 @@
uint32_t *p;
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));
if (maple_alloc_dma(MAPLE_DMABUF_SIZE, &dmabuffer, &dmabuffer_phys)) {
printf("%s: unable to allocate DMA buffers.\n",
- sc->sc_dev.dv_xname);
+ device_xname(self));
return;
}
@@ -246,10 +247,10 @@
config_pending_incr(); /* create thread before mounting root */
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;
- 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 @@
}
void
-maple_run_polling(struct device *dev)
+maple_run_polling(device_t dev)
{
struct maple_softc *sc;
int port, subunit;
int i;
- sc = (struct maple_softc *)dev;
+ sc = device_private(dev);
/*
* first, make sure polling works
@@ -672,10 +673,10 @@
ma.ma_basedevinfo = &sc->sc_unit[u->port][0].devinfo;
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");
- strcpy(oldxname, sc->sc_dev.dv_xname);
- maple_unit_name(sc->sc_dev.dv_xname, u->port, u->subunit);
+ strcpy(oldxname, device_xname(sc->sc_dev));
+ maple_unit_name(sc->sc_dev->dv_xname, u->port, u->subunit);
for (f = 0; f < MAPLE_NFUNC; f++) {
u->u_func[f].f_callback = NULL;
@@ -684,7 +685,7 @@
u->u_func[f].f_dev = NULL;
if (func & MAPLE_FUNC(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);
u->u_ping_func = f; /* XXX using largest func */
}
@@ -702,7 +703,7 @@
u->u_ping_stat = MAPLE_PING_NORMAL;
}
#endif
- strcpy(sc->sc_dev.dv_xname, oldxname);
+ strcpy(sc->sc_dev->dv_xname, oldxname);
sc->sc_port_units[u->port] |= 1 << u->subunit;
}
@@ -760,11 +761,11 @@
if ((error = config_detach(fn->f_dev, DETACH_FORCE))) {
printf("%s: failed to detach %s (func %d), errno %d\n",
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_callback = NULL;
@@ -821,10 +822,10 @@
* Only one command (per function) is valid at a time.
*/
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)
{
- struct maple_softc *sc = (void *) dev;
+ struct maple_softc *sc = device_private(dev);
struct maple_func *fn;
int s;
@@ -943,11 +944,10 @@
*/
/* ARGSUSED */
void
-maple_enable_unit_ping(struct device *dev, struct maple_unit *u,
- int func, int enable)
+maple_enable_unit_ping(device_t dev, struct maple_unit *u, int func, int enable)
{
#if 0 /* currently unused */
- struct maple_softc *sc = (void *) dev;
+ struct maple_softc *sc = device_private(dev);
#endif
if (enable)
@@ -1002,10 +1002,9 @@
* Enable/disable periodic GETCOND (called by drivers)
*/
void
-maple_enable_periodic(struct device *dev, struct maple_unit *u,
- int func, int on)
+maple_enable_periodic(device_t dev, struct maple_unit *u, int func, int on)
{
- struct maple_softc *sc = (void *) dev;
+ struct maple_softc *sc = device_private(dev);
struct maple_func *fn;
KASSERT(func >= 0 && func < 32);
@@ -1422,7 +1421,7 @@
#ifdef MAPLE_DEBUG
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
/* begin first DMA cycle */
@@ -1487,7 +1486,8 @@
if (tsleep(&sc->sc_dmadone, PWAIT, "mdma", hz)
== EWOULDBLOCK) {
/* 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);
@@ -1506,7 +1506,7 @@
if (noreq) /* ignore first time */
#endif
printf("%s: no request %d\n",
- sc->sc_dev.dv_xname, noreq);
+ device_xname(sc->sc_dev), noreq);
noreq++;
}
#endif
@@ -1520,7 +1520,7 @@
if (tsleep(&sc->sc_event, PWAIT, "mslp", hz)
== EWOULDBLOCK) {
printf("%s: event timed out\n",
- sc->sc_dev.dv_xname);
+ device_xname(sc->sc_dev));
}
}
@@ -1558,11 +1558,11 @@
*/
/* ARGSUSED */
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)
{
#if 0 /* currently unused */
- struct maple_softc *sc = (void *) dev;
+ struct maple_softc *sc = device_private(dev);
#endif
struct maple_func *fn;
@@ -1634,10 +1634,10 @@
}
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)
{
- 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)))
return ENXIO;
@@ -1662,5 +1662,5 @@
sc = device_lookup_private(&maple_cd, MAPLEBUSUNIT(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);
}
diff -r 2ba3c6c246fb -r ec0a2746f25d sys/arch/dreamcast/dev/maple/maple.h
--- a/sys/arch/dreamcast/dev/maple/maple.h Sun Oct 17 12:45:28 2010 +0000
+++ b/sys/arch/dreamcast/dev/maple/maple.h Sun Oct 17 14:13:44 2010 +0000
@@ -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.
@@ -128,19 +128,19 @@
struct maple_unit;
-extern void maple_set_callback(struct device *, struct maple_unit *, int,
- void (*)(void *, struct maple_response *, int, int),
- void *);
-extern void maple_enable_unit_ping(struct device *, struct maple_unit *,
- int /*func*/, int /*enable*/);
-extern void maple_enable_periodic(struct device *, struct maple_unit *,
- int /*func*/, int /*on*/);
-extern void maple_command(struct device *, struct maple_unit *,
- int /*func*/, int /*command*/, int /*datalen*/,
- const void *, int /*flags*/);
-extern uint32_t maple_get_function_data(struct maple_devinfo *, int);
-extern void maple_run_polling(struct device *);
-extern int maple_unit_ioctl(struct device *, struct maple_unit *,
- u_long, void *, int, struct lwp *);
+void maple_set_callback(device_t, struct maple_unit *, int,
+ void (*)(void *, struct maple_response *, int, int),
+ void *);
+void maple_enable_unit_ping(device_t, struct maple_unit *,
+ int /*func*/, int /*enable*/);
+void maple_enable_periodic(device_t, struct maple_unit *,
+ int /*func*/, int /*on*/);
+void maple_command(device_t, struct maple_unit *,
+ int /*func*/, int /*command*/, int /*datalen*/,
+ const void *, int /*flags*/);
+uint32_t maple_get_function_data(struct maple_devinfo *, int);
+void maple_run_polling(device_t);
+int maple_unit_ioctl(device_t, struct maple_unit *,
+ u_long, void *, int, struct lwp *);
Home |
Main Index |
Thread Index |
Old Index