summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorcube <cube@NetBSD.org>2008-03-04 21:56:11 +0000
committercube <cube@NetBSD.org>2008-03-04 21:56:11 +0000
commit14218c181b1d4a1a6069d46ddbbcd4a9b85d5e46 (patch)
treedd10cf1d127569f08d8480bd13eb0210e562e76b /sys/dev
parent935753c81129dd9c2256641389e700f84dd5d095 (diff)
Split device_t/softc for midi(4), and other related cosmetic changes.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/ic/opl.c8
-rw-r--r--sys/dev/midi.c81
-rw-r--r--sys/dev/midi_if.h7
-rw-r--r--sys/dev/midivar.h4
-rw-r--r--sys/dev/sequencer.c6
5 files changed, 52 insertions, 54 deletions
diff --git a/sys/dev/ic/opl.c b/sys/dev/ic/opl.c
index 8ed23a16189..6069ddee61f 100644
--- a/sys/dev/ic/opl.c
+++ b/sys/dev/ic/opl.c
@@ -1,4 +1,4 @@
-/* $NetBSD: opl.c,v 1.32 2007/10/19 11:59:58 ad Exp $ */
+/* $NetBSD: opl.c,v 1.33 2008/03/04 21:56:11 cube Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -42,7 +42,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: opl.c,v 1.32 2007/10/19 11:59:58 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: opl.c,v 1.33 2008/03/04 21:56:11 cube Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -174,7 +174,7 @@ opl_attach(sc)
sc->panl = OPL_VOICE_TO_LEFT;
sc->panr = OPL_VOICE_TO_RIGHT;
if (sc->model == OPL_3 &&
- device_cfdata(&sc->mididev.dev)->cf_flags & OPL_FLAGS_SWAP_LR) {
+ device_cfdata(sc->mididev.dev)->cf_flags & OPL_FLAGS_SWAP_LR) {
sc->panl = OPL_VOICE_TO_RIGHT;
sc->panr = OPL_VOICE_TO_LEFT;
printf(": LR swapped");
@@ -183,7 +183,7 @@ opl_attach(sc)
printf("\n");
sc->sc_mididev =
- midi_attach_mi(&midisyn_hw_if, &sc->syn, &sc->mididev.dev);
+ midi_attach_mi(&midisyn_hw_if, &sc->syn, sc->mididev.dev);
}
int
diff --git a/sys/dev/midi.c b/sys/dev/midi.c
index b5f162a62b7..221d0be4204 100644
--- a/sys/dev/midi.c
+++ b/sys/dev/midi.c
@@ -1,4 +1,4 @@
-/* $NetBSD: midi.c,v 1.60 2008/03/01 14:16:50 rmind Exp $ */
+/* $NetBSD: midi.c,v 1.61 2008/03/04 21:56:11 cube Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: midi.c,v 1.60 2008/03/01 14:16:50 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: midi.c,v 1.61 2008/03/04 21:56:11 cube Exp $");
#include "midi.h"
#include "sequencer.h"
@@ -106,10 +106,10 @@ void midi_rcv_asense(void *);
void midi_softintr_rd(void *);
void midi_softintr_wr(void *);
-int midiprobe(struct device *, struct cfdata *, void *);
-void midiattach(struct device *, struct device *, void *);
-int mididetach(struct device *, int);
-int midiactivate(struct device *, enum devact);
+int midiprobe(device_t, cfdata_t, void *);
+void midiattach(device_t, device_t, void *);
+int mididetach(device_t, int);
+int midiactivate(device_t, enum devact);
dev_type_open(midiopen);
dev_type_close(midiclose);
@@ -124,7 +124,7 @@ const struct cdevsw midi_cdevsw = {
nostop, notty, midipoll, nommap, midikqfilter, D_OTHER,
};
-CFATTACH_DECL(midi, sizeof(struct midi_softc),
+CFATTACH_DECL_NEW(midi, sizeof(struct midi_softc),
midiprobe, midiattach, mididetach, midiactivate);
#define MIDI_XMT_ASENSE_PERIOD mstohz(275)
@@ -133,8 +133,7 @@ CFATTACH_DECL(midi, sizeof(struct midi_softc),
extern struct cfdriver midi_cd;
int
-midiprobe(struct device *parent, struct cfdata *match,
- void *aux)
+midiprobe(device_t parent, cfdata_t match, void *aux)
{
struct audio_attach_args *sa = aux;
@@ -144,9 +143,9 @@ midiprobe(struct device *parent, struct cfdata *match,
}
void
-midiattach(struct device *parent, struct device *self, void *aux)
+midiattach(device_t parent, device_t self, void *aux)
{
- struct midi_softc *sc = (void *)self;
+ struct midi_softc *sc = device_private(self);
struct audio_attach_args *sa = aux;
const struct midi_hw_if *hwp = sa->hwif;
void *hdlp = sa->hdl;
@@ -176,9 +175,9 @@ midiattach(struct device *parent, struct device *self, void *aux)
}
int
-midiactivate(struct device *self, enum devact act)
+midiactivate(device_t self, enum devact act)
{
- struct midi_softc *sc = (struct midi_softc *)self;
+ struct midi_softc *sc = device_private(self);
switch (act) {
case DVACT_ACTIVATE:
@@ -192,9 +191,9 @@ midiactivate(struct device *self, enum devact act)
}
int
-mididetach(struct device *self, int flags)
+mididetach(device_t self, int flags)
{
- struct midi_softc *sc = (struct midi_softc *)self;
+ struct midi_softc *sc = device_private(self);
int maj, mn;
DPRINTFN(2,("midi_detach: sc=%p flags=%d\n", sc, flags));
@@ -235,7 +234,7 @@ mididetach(struct device *self, int flags)
}
void
-midi_attach(struct midi_softc *sc, struct device *parent)
+midi_attach(struct midi_softc *sc, device_t parent)
{
struct midi_info mi;
int s;
@@ -267,18 +266,18 @@ midi_attach(struct midi_softc *sc, struct device *parent)
if ( !(sc->props & MIDI_PROP_NO_OUTPUT) ) {
evcnt_attach_dynamic(&sc->xmt.bytesDiscarded,
EVCNT_TYPE_MISC, NULL,
- sc->dev.dv_xname, "xmt bytes discarded");
+ device_xname(sc->dev), "xmt bytes discarded");
evcnt_attach_dynamic(&sc->xmt.incompleteMessages,
EVCNT_TYPE_MISC, NULL,
- sc->dev.dv_xname, "xmt incomplete msgs");
+ device_xname(sc->dev), "xmt incomplete msgs");
}
if ( sc->props & MIDI_PROP_CAN_INPUT ) {
evcnt_attach_dynamic(&sc->rcv.bytesDiscarded,
EVCNT_TYPE_MISC, NULL,
- sc->dev.dv_xname, "rcv bytes discarded");
+ device_xname(sc->dev), "rcv bytes discarded");
evcnt_attach_dynamic(&sc->rcv.incompleteMessages,
EVCNT_TYPE_MISC, NULL,
- sc->dev.dv_xname, "rcv incomplete msgs");
+ device_xname(sc->dev), "rcv incomplete msgs");
}
aprint_normal(": %s%s\n", mi.name,
@@ -820,7 +819,7 @@ midiopen(dev_t dev, int flags, int ifmt, struct lwp *l)
const struct midi_hw_if *hw;
int error;
- sc = device_lookup(&midi_cd, MIDIUNIT(dev));
+ sc = device_private(device_lookup(&midi_cd, MIDIUNIT(dev)));
if (sc == NULL)
return (ENXIO);
if (sc->dying)
@@ -882,8 +881,8 @@ int
midiclose(dev_t dev, int flags, int ifmt,
struct lwp *l)
{
- int unit = MIDIUNIT(dev);
- struct midi_softc *sc = midi_cd.cd_devs[unit];
+ struct midi_softc *sc =
+ device_private(device_lookup(&midi_cd, MIDIUNIT(dev)));
const struct midi_hw_if *hw = sc->hw_if;
int s, error;
@@ -912,8 +911,8 @@ midiclose(dev_t dev, int flags, int ifmt,
int
midiread(dev_t dev, struct uio *uio, int ioflag)
{
- int unit = MIDIUNIT(dev);
- struct midi_softc *sc = midi_cd.cd_devs[unit];
+ struct midi_softc *sc =
+ device_private(device_lookup(&midi_cd, MIDIUNIT(dev)));
struct midi_buffer *mb = &sc->inbuf;
int error;
int s;
@@ -1240,8 +1239,7 @@ midi_poll_out(struct midi_softc *sc)
ioerror:
#if defined(AUDIO_DEBUG) || defined(DIAGNOSTIC)
- printf("%s: midi_poll_output error %d\n",
- sc->dev.dv_xname, error);
+ aprint_error_dev(sc->dev, "midi_poll_output error %d\n", error);
#endif
MIDI_OUT_LOCK(sc,s);
MIDI_BUF_CONSUMER_WBACK(mb,idx);
@@ -1317,8 +1315,8 @@ midi_intr_out(struct midi_softc *sc)
#if defined(AUDIO_DEBUG) || defined(DIAGNOSTIC)
if ( error )
- printf("%s: midi_intr_output error %d\n",
- sc->dev.dv_xname, error);
+ aprint_error_dev(sc->dev, "midi_intr_output error %d\n",
+ error);
#endif
return error;
}
@@ -1440,8 +1438,8 @@ real_writebytes(struct midi_softc *sc, u_char *ibuf, int cc)
int
midiwrite(dev_t dev, struct uio *uio, int ioflag)
{
- int unit = MIDIUNIT(dev);
- struct midi_softc *sc = midi_cd.cd_devs[unit];
+ struct midi_softc *sc =
+ device_private(device_lookup(&midi_cd, MIDIUNIT(dev)));
struct midi_buffer *mb = &sc->outbuf;
int error;
u_char inp[256];
@@ -1562,7 +1560,8 @@ locked_exit:
int
midi_writebytes(int unit, u_char *bf, int cc)
{
- struct midi_softc *sc = midi_cd.cd_devs[unit];
+ struct midi_softc *sc =
+ device_private(device_lookup(&midi_cd, unit));
DPRINTFN(7, ("midi_writebytes: %p, unit=%d, cc=%d %#02x %#02x %#02x\n",
sc, unit, cc, bf[0], bf[1], bf[2]));
@@ -1572,8 +1571,8 @@ midi_writebytes(int unit, u_char *bf, int cc)
int
midiioctl(dev_t dev, u_long cmd, void *addr, int flag, struct lwp *l)
{
- int unit = MIDIUNIT(dev);
- struct midi_softc *sc = midi_cd.cd_devs[unit];
+ struct midi_softc *sc =
+ device_private(device_lookup(&midi_cd, MIDIUNIT(dev)));
const struct midi_hw_if *hw = sc->hw_if;
int error;
int s;
@@ -1647,8 +1646,8 @@ midiioctl(dev_t dev, u_long cmd, void *addr, int flag, struct lwp *l)
int
midipoll(dev_t dev, int events, struct lwp *l)
{
- int unit = MIDIUNIT(dev);
- struct midi_softc *sc = midi_cd.cd_devs[unit];
+ struct midi_softc *sc =
+ device_private(device_lookup(&midi_cd, MIDIUNIT(dev)));
int revents = 0;
int s;
MIDI_BUF_DECLARE(idx);
@@ -1753,8 +1752,8 @@ static const struct filterops midiwrite_filtops =
int
midikqfilter(dev_t dev, struct knote *kn)
{
- int unit = MIDIUNIT(dev);
- struct midi_softc *sc = midi_cd.cd_devs[unit];
+ struct midi_softc *sc =
+ device_private(device_lookup(&midi_cd, MIDIUNIT(dev)));
struct klist *klist;
int s;
@@ -1787,7 +1786,7 @@ midi_getinfo(dev_t dev, struct midi_info *mi)
{
struct midi_softc *sc;
- sc = device_lookup(&midi_cd, MIDIUNIT(dev));
+ sc = device_private(device_lookup(&midi_cd, MIDIUNIT(dev)));
if (sc == NULL)
return;
if (sc->dying)
@@ -1807,8 +1806,8 @@ void midi_register_hw_if_ext(struct midi_hw_if_ext *exthw) { /* stub */
int audioprint(void *, const char *);
-struct device *
-midi_attach_mi(const struct midi_hw_if *mhwp, void *hdlp, struct device *dev)
+device_t
+midi_attach_mi(const struct midi_hw_if *mhwp, void *hdlp, device_t dev)
{
struct audio_attach_args arg;
diff --git a/sys/dev/midi_if.h b/sys/dev/midi_if.h
index 212af778c2d..62f92f20a68 100644
--- a/sys/dev/midi_if.h
+++ b/sys/dev/midi_if.h
@@ -1,4 +1,4 @@
-/* $NetBSD: midi_if.h,v 1.19 2007/03/04 06:01:42 christos Exp $ */
+/* $NetBSD: midi_if.h,v 1.20 2008/03/04 21:56:11 cube Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -90,9 +90,8 @@ struct midi_hw_if_ext {
};
void midi_register_hw_if_ext(struct midi_hw_if_ext *);
-void midi_attach(struct midi_softc *, struct device *);
-struct device *midi_attach_mi(const struct midi_hw_if *, void *,
- struct device *);
+void midi_attach(struct midi_softc *, device_t);
+device_t midi_attach_mi(const struct midi_hw_if *, void *, device_t);
int midi_unit_count(void);
void midi_getinfo(dev_t, struct midi_info *);
diff --git a/sys/dev/midivar.h b/sys/dev/midivar.h
index 069fefd4ddd..8475d8c4766 100644
--- a/sys/dev/midivar.h
+++ b/sys/dev/midivar.h
@@ -1,4 +1,4 @@
-/* $NetBSD: midivar.h,v 1.14 2008/01/04 21:17:49 ad Exp $ */
+/* $NetBSD: midivar.h,v 1.15 2008/03/04 21:56:11 cube Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -187,7 +187,7 @@ struct midi_state {
};
struct midi_softc {
- struct device dev;
+ device_t dev;
void *hw_hdl; /* Hardware driver handle */
const struct midi_hw_if *hw_if; /* Hardware interface */
const struct midi_hw_if_ext *hw_if_ext; /* see midi_if.h */
diff --git a/sys/dev/sequencer.c b/sys/dev/sequencer.c
index 96d8444c4f4..4e028e7ded8 100644
--- a/sys/dev/sequencer.c
+++ b/sys/dev/sequencer.c
@@ -1,4 +1,4 @@
-/* $NetBSD: sequencer.c,v 1.44 2008/03/01 14:16:50 rmind Exp $ */
+/* $NetBSD: sequencer.c,v 1.45 2008/03/04 21:56:11 cube Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sequencer.c,v 1.44 2008/03/01 14:16:50 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sequencer.c,v 1.45 2008/03/04 21:56:11 cube Exp $");
#include "sequencer.h"
@@ -1189,7 +1189,7 @@ midiseq_open(int unit, int flags)
error = cdev_open(dev, flags, 0, 0);
if (error)
return (0);
- sc = midi_cd.cd_devs[unit];
+ sc = device_private(midi_cd.cd_devs[unit]);
sc->seqopen = 1;
md = malloc(sizeof *md, M_DEVBUF, M_WAITOK|M_ZERO);
sc->seq_md = md;