Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev Tidy up a little, the way that midi attachment code ...



details:   https://anonhg.NetBSD.org/src/rev/18d10d133f8f
branches:  trunk
changeset: 778704:18d10d133f8f
user:      plunky <plunky%NetBSD.org@localhost>
date:      Mon Apr 09 10:18:16 2012 +0000

description:
Tidy up a little, the way that midi attachment code works

- change midi_attach() to omit the 'parent' arg (there are
  only two callers of this and it is not used)

- change midisyn_attach() to midisyn_init(), so not needing a midi_softc,
  and fix the midi_pcppi driver to set hw_if and hw_hdl directly in
  its midi_softc before calling midi_attach()

- add a device_t to opl_softc structure, change opl drivers to store
  the device 'self' in opl_softc and fix opl_attach() to use this
  opl_softc->dev field directly rather than a field in an otherwise
  unused midi_softc

- remove unnecessary midi_softc from opl and cms drivers (child device
  provides that)

reviewed by mrg

diffstat:

 sys/dev/ic/opl.c         |  15 +++++++--------
 sys/dev/ic/oplvar.h      |   4 ++--
 sys/dev/isa/cms.c        |  20 ++++++--------------
 sys/dev/isa/midi_pcppi.c |  16 +++++++++-------
 sys/dev/isa/opl_ess.c    |   6 +++---
 sys/dev/isa/opl_isa.c    |   6 +++---
 sys/dev/isa/opl_sb.c     |   6 +++---
 sys/dev/isa/opl_wss.c    |   6 +++---
 sys/dev/isa/opl_ym.c     |   6 +++---
 sys/dev/midi.c           |  16 ++++++----------
 sys/dev/midi_if.h        |   4 ++--
 sys/dev/midisyn.c        |  19 ++++++-------------
 sys/dev/midisynvar.h     |   6 ++----
 sys/dev/pci/opl_cmpci.c  |   6 +++---
 sys/dev/pci/opl_eso.c    |   6 +++---
 sys/dev/pci/opl_fms.c    |   6 +++---
 sys/dev/pci/opl_sv.c     |   6 +++---
 sys/dev/pci/opl_yds.c    |   6 +++---
 sys/dev/sequencer.c      |   5 ++---
 19 files changed, 72 insertions(+), 93 deletions(-)

diffs (truncated from 635 to 300 lines):

diff -r 8acfe1241dac -r 18d10d133f8f sys/dev/ic/opl.c
--- a/sys/dev/ic/opl.c  Mon Apr 09 08:10:30 2012 +0000
+++ b/sys/dev/ic/opl.c  Mon Apr 09 10:18:16 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: opl.c,v 1.38 2011/11/23 23:07:32 jmcneill Exp $        */
+/*     $NetBSD: opl.c,v 1.39 2012/04/09 10:18:16 plunky Exp $  */
 
 /*
  * Copyright (c) 1998, 2008 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: opl.c,v 1.38 2011/11/23 23:07:32 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: opl.c,v 1.39 2012/04/09 10:18:16 plunky Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -142,9 +142,8 @@
 {
        int i;
 
-       if (sc->lock == NULL) {
-               panic("opl_attach: no lock");
-       }
+       KASSERT(sc->dev != NULL);
+       KASSERT(sc->lock != NULL);
 
        mutex_enter(sc->lock);
        i = opl_find(sc);
@@ -164,7 +163,7 @@
        sc->syn.data = sc;
        sc->syn.nvoice = sc->model == OPL_2 ? OPL2_NVOICE : OPL3_NVOICE;
        sc->syn.lock = sc->lock;
-       midisyn_attach(&sc->mididev, &sc->syn);
+       midisyn_init(&sc->syn);
 
        /* Set up voice table */
        for (i = 0; i < OPL3_NVOICE; i++)
@@ -176,7 +175,7 @@
        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->dev)->cf_flags & OPL_FLAGS_SWAP_LR) {
                sc->panl = OPL_VOICE_TO_RIGHT;
                sc->panr = OPL_VOICE_TO_LEFT;
                aprint_normal(": LR swapped");
@@ -186,7 +185,7 @@
        aprint_naive("\n");
 
        sc->sc_mididev =
-           midi_attach_mi(&midisyn_hw_if, &sc->syn, sc->mididev.dev);
+           midi_attach_mi(&midisyn_hw_if, &sc->syn, sc->dev);
 }
 
 int
diff -r 8acfe1241dac -r 18d10d133f8f sys/dev/ic/oplvar.h
--- a/sys/dev/ic/oplvar.h       Mon Apr 09 08:10:30 2012 +0000
+++ b/sys/dev/ic/oplvar.h       Mon Apr 09 10:18:16 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: oplvar.h,v 1.16 2011/11/23 23:07:32 jmcneill Exp $     */
+/*     $NetBSD: oplvar.h,v 1.17 2012/04/09 10:18:16 plunky Exp $       */
 
 /*
  * Copyright (c) 1998, 2008 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
 };
 
 struct opl_softc {
-       struct midi_softc mididev;
+       device_t dev;
        bus_space_tag_t iot;
        bus_space_handle_t ioh;
        kmutex_t *lock;
diff -r 8acfe1241dac -r 18d10d133f8f sys/dev/isa/cms.c
--- a/sys/dev/isa/cms.c Mon Apr 09 08:10:30 2012 +0000
+++ b/sys/dev/isa/cms.c Mon Apr 09 10:18:16 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cms.c,v 1.20 2011/11/24 16:11:02 jakllsch Exp $ */
+/* $NetBSD: cms.c,v 1.21 2012/04/09 10:18:16 plunky Exp $ */
 
 /*
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cms.c,v 1.20 2011/11/24 16:11:02 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cms.c,v 1.21 2012/04/09 10:18:16 plunky Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -58,8 +58,6 @@
 #endif
 
 struct cms_softc {
-       struct midi_softc sc_mididev;
-
        kmutex_t sc_lock;
 
        bus_space_tag_t sc_iot;
@@ -165,9 +163,7 @@
        bus_space_tag_t iot;
        bus_space_handle_t ioh;
        midisyn *ms;
-       struct audio_attach_args arg;
 
-       sc->sc_mididev.dev = self;
        mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_AUDIO);
 
        aprint_normal("\n");
@@ -187,21 +183,17 @@
        /* now let's reset the chips */
        cms_reset(sc);
 
+       /* init the synthesiser */
        ms = &sc->sc_midisyn;
        ms->mets = &midi_cms_hw;
        strcpy(ms->name, "Creative Music System");
        ms->nvoice = CMS_NVOICES;
        ms->data = sc;
        ms->lock = &sc->sc_lock;
-
-       /* use the synthesiser */
-       midisyn_attach(&sc->sc_mididev, ms);
+       midisyn_init(ms);
 
-       /* now attach the midi device to the synthesiser */
-       arg.type = AUDIODEV_TYPE_MIDI;
-       arg.hwif = sc->sc_mididev.hw_if;
-       arg.hdl = sc->sc_mididev.hw_hdl;
-       config_found(self, &arg, 0);
+       /* and attach the midi device with the synthesiser */
+       midi_attach_mi(&midisyn_hw_if, ms, self);
 }
 
 
diff -r 8acfe1241dac -r 18d10d133f8f sys/dev/isa/midi_pcppi.c
--- a/sys/dev/isa/midi_pcppi.c  Mon Apr 09 08:10:30 2012 +0000
+++ b/sys/dev/isa/midi_pcppi.c  Mon Apr 09 10:18:16 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: midi_pcppi.c,v 1.25 2012/04/05 20:13:35 plunky Exp $   */
+/*     $NetBSD: midi_pcppi.c,v 1.26 2012/04/09 10:18:17 plunky Exp $   */
 
 /*
  * Copyright (c) 1998, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: midi_pcppi.c,v 1.25 2012/04/05 20:13:35 plunky Exp $");
+__KERNEL_RCSID(0, "$NetBSD: midi_pcppi.c,v 1.26 2012/04/09 10:18:17 plunky Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -94,18 +94,20 @@
        struct pcppi_attach_args *pa = (struct pcppi_attach_args *)aux;
        midisyn *ms;
 
-       sc->sc_mididev.dev = self;
+       midi_pcppi_attached++;
+
        ms = &sc->sc_midisyn;
        ms->mets = &midi_pcppi_hw;
        strcpy(ms->name, "PC speaker");
        ms->nvoice = 1;
        ms->data = pa->pa_cookie;
        ms->lock = &tty_lock;
-
-       midi_pcppi_attached++;
+       midisyn_init(ms);
 
-       midisyn_attach(&sc->sc_mididev, ms);
-       midi_attach(&sc->sc_mididev, parent);
+       sc->sc_mididev.dev = self;
+       sc->sc_mididev.hw_if = &midisyn_hw_if;
+       sc->sc_mididev.hw_hdl = ms;
+       midi_attach(&sc->sc_mididev);
 }
 
 static int
diff -r 8acfe1241dac -r 18d10d133f8f sys/dev/isa/opl_ess.c
--- a/sys/dev/isa/opl_ess.c     Mon Apr 09 08:10:30 2012 +0000
+++ b/sys/dev/isa/opl_ess.c     Mon Apr 09 10:18:16 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: opl_ess.c,v 1.17 2011/11/23 23:07:32 jmcneill Exp $    */
+/*     $NetBSD: opl_ess.c,v 1.18 2012/04/09 10:18:17 plunky Exp $      */
 
 /*-
  * Copyright (c) 1999, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: opl_ess.c,v 1.17 2011/11/23 23:07:32 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: opl_ess.c,v 1.18 2012/04/09 10:18:17 plunky Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -79,7 +79,7 @@
        struct ess_softc *ssc = device_private(parent);
        struct opl_softc *sc = device_private(self);
 
-       sc->mididev.dev = self;
+       sc->dev = self;
        sc->ioh = ssc->sc_ioh;
        sc->iot = ssc->sc_iot;
        sc->offs = 0;
diff -r 8acfe1241dac -r 18d10d133f8f sys/dev/isa/opl_isa.c
--- a/sys/dev/isa/opl_isa.c     Mon Apr 09 08:10:30 2012 +0000
+++ b/sys/dev/isa/opl_isa.c     Mon Apr 09 10:18:16 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: opl_isa.c,v 1.20 2011/11/23 23:07:32 jmcneill Exp $    */
+/*     $NetBSD: opl_isa.c,v 1.21 2012/04/09 10:18:17 plunky Exp $      */
 
 /*-
  * Copyright (c) 1999, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: opl_isa.c,v 1.20 2011/11/23 23:07:32 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: opl_isa.c,v 1.21 2012/04/09 10:18:17 plunky Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -105,7 +105,7 @@
        struct opl_isa_softc *isa = device_private(self);
        struct isa_attach_args *ia = aux;
 
-       sc->mididev.dev = self;
+       sc->dev = self;
        sc->iot = ia->ia_iot;
 
        if (bus_space_map(sc->iot, ia->ia_io[0].ir_addr, OPL_SIZE,
diff -r 8acfe1241dac -r 18d10d133f8f sys/dev/isa/opl_sb.c
--- a/sys/dev/isa/opl_sb.c      Mon Apr 09 08:10:30 2012 +0000
+++ b/sys/dev/isa/opl_sb.c      Mon Apr 09 10:18:16 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: opl_sb.c,v 1.19 2011/11/23 23:07:32 jmcneill Exp $     */
+/*     $NetBSD: opl_sb.c,v 1.20 2012/04/09 10:18:17 plunky Exp $       */
 
 /*
  * Copyright (c) 1998, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: opl_sb.c,v 1.19 2011/11/23 23:07:32 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: opl_sb.c,v 1.20 2012/04/09 10:18:17 plunky Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -77,7 +77,7 @@
        struct  sbdsp_softc *ssc = device_private(parent);
        struct opl_softc *sc = device_private(self);
 
-       sc->mididev.dev = self;
+       sc->dev = self;
        sc->ioh = ssc->sc_ioh;
        sc->iot = ssc->sc_iot;
        sc->offs = 0;
diff -r 8acfe1241dac -r 18d10d133f8f sys/dev/isa/opl_wss.c
--- a/sys/dev/isa/opl_wss.c     Mon Apr 09 08:10:30 2012 +0000
+++ b/sys/dev/isa/opl_wss.c     Mon Apr 09 10:18:16 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: opl_wss.c,v 1.14 2011/12/07 17:38:50 jakllsch Exp $    */
+/*     $NetBSD: opl_wss.c,v 1.15 2012/04/09 10:18:17 plunky Exp $      */
 
 /*
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: opl_wss.c,v 1.14 2011/12/07 17:38:50 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: opl_wss.c,v 1.15 2012/04/09 10:18:17 plunky Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -77,7 +77,7 @@
        struct wss_softc *ssc = device_private(parent);
        struct opl_softc *sc = device_private(self);
 
-       sc->mididev.dev = self;
+       sc->dev = self;
        sc->ioh = ssc->sc_opl_ioh;
        sc->iot = ssc->sc_iot;
        sc->offs = 0;
diff -r 8acfe1241dac -r 18d10d133f8f sys/dev/isa/opl_ym.c
--- a/sys/dev/isa/opl_ym.c      Mon Apr 09 08:10:30 2012 +0000
+++ b/sys/dev/isa/opl_ym.c      Mon Apr 09 10:18:16 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: opl_ym.c,v 1.17 2011/12/07 17:38:50 jakllsch Exp $     */
+/*     $NetBSD: opl_ym.c,v 1.18 2012/04/09 10:18:17 plunky Exp $       */
 
 /*
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@



Home | Main Index | Thread Index | Old Index