Autoconfiguration cleanup for arcvideo(4):

- Use device_t and cfdata_t rather than explicit structure pointers.
- Use device_private() rather than a cast to convert device_t to a softc.
- Use device_*() to get at the innards of device_t.
device/softc split not done yet because of worrying about bootstrap console
stuff.
This commit is contained in:
bjh21 2009-01-07 23:14:40 +00:00
parent a3551a3ce2
commit 583bfaa708
1 changed files with 16 additions and 18 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: arcvideo.c,v 1.12 2007/03/05 15:40:28 he Exp $ */
/* $NetBSD: arcvideo.c,v 1.13 2009/01/07 23:14:40 bjh21 Exp $ */
/*-
* Copyright (c) 1998, 2000 Ben Harris
* All rights reserved.
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: arcvideo.c,v 1.12 2007/03/05 15:40:28 he Exp $");
__KERNEL_RCSID(0, "$NetBSD: arcvideo.c,v 1.13 2009/01/07 23:14:40 bjh21 Exp $");
#include <sys/param.h>
#include <sys/device.h>
@ -64,12 +64,11 @@ __KERNEL_RCSID(0, "$NetBSD: arcvideo.c,v 1.12 2007/03/05 15:40:28 he Exp $");
#include <arch/acorn26/vidc/vidcreg.h>
#include <arch/acorn26/vidc/arcvideovar.h>
static int arcvideo_match(struct device *parent, struct cfdata *cf, void *aux);
static void arcvideo_attach(struct device *parent, struct device *self,
void *aux);
static int arcvideo_match(device_t parent, cfdata_t cf, void *aux);
static void arcvideo_attach(device_t parent, device_t self, void *aux);
#if 0
static int arcvideo_setmode(struct device *self, struct arcvideo_mode *mode);
static void arcvideo_await_vsync(struct device *self);
static int arcvideo_setmode(device_t self, struct arcvideo_mode *mode);
static void arcvideo_await_vsync(device_t self);
#endif
static int arcvideo_intr(void *cookie);
static int arcvideo_ioctl(void *cookie, void *vs, u_long cmd, void *data,
@ -100,7 +99,7 @@ struct arcvideo_softc {
CFATTACH_DECL(arcvideo, sizeof(struct arcvideo_softc),
arcvideo_match, arcvideo_attach, NULL, NULL);
struct device *the_arcvideo;
device_t the_arcvideo;
static struct rasops_info arccons_ri;
@ -114,7 +113,7 @@ static struct wsdisplay_accessops arcvideo_accessops = {
static int arcvideo_isconsole = 0;
static int
arcvideo_match(struct device *parent, struct cfdata *cf, void *aux)
arcvideo_match(device_t parent, cfdata_t cf, void *aux)
{
/* A system can't sensibly have more than one VIDC. */
@ -124,12 +123,12 @@ arcvideo_match(struct device *parent, struct cfdata *cf, void *aux)
}
static void
arcvideo_attach(struct device *parent, struct device *self, void *aux)
arcvideo_attach(device_t parent, device_t self, void *aux)
{
struct wsemuldisplaydev_attach_args da;
struct wsscreen_list scrdata;
const struct wsscreen_descr *screenp;
struct arcvideo_softc *sc = (void *)self;
struct arcvideo_softc *sc = device_private(self);
the_arcvideo = self;
if (!arcvideo_isconsole) {
@ -143,14 +142,13 @@ arcvideo_attach(struct device *parent, struct device *self, void *aux)
/* Find IRQ */
evcnt_attach_dynamic(&sc->sc_intrcnt, EVCNT_TYPE_INTR, NULL,
sc->sc_dev.dv_xname, "vsync intr");
device_xname(&sc->sc_dev), "vsync intr");
sc->sc_irq = irq_establish(IOC_IRQ_IR, IPL_TTY, arcvideo_intr, self,
&sc->sc_intrcnt);
if (bootverbose)
printf(": VSYNC interrupts at %s", irq_string(sc->sc_irq));
aprint_verbose(": VSYNC interrupts at %s", irq_string(sc->sc_irq));
irq_disable(sc->sc_irq);
printf("\n");
aprint_normal("\n");
scrdata.nscreens = 1;
scrdata.screens = &screenp;
@ -166,9 +164,9 @@ arcvideo_attach(struct device *parent, struct device *self, void *aux)
#if 0
static int
arcvideo_setmode(struct device *self, struct arcvideo_mode *mode)
arcvideo_setmode(device_t self, struct arcvideo_mode *mode)
{
struct arcvideo_softc *sc = (void *)self;
struct arcvideo_softc *sc = device_private(self);
u_int32_t newctl, ctlmask;
u_int32_t newhswr, newhbsr, newhdsr, newhder, newhber, newhcr, newhir;
u_int32_t newvswr, newvbsr, newvdsr, newvder, newvber, newvcr;
@ -269,7 +267,7 @@ arcvideo_setmode(struct device *self, struct arcvideo_mode *mode)
}
static void
arcvideo_await_vsync(struct device *self)
arcvideo_await_vsync(device_t self)
{
panic("arcvideo_await_vsync not implemented");