Source-Changes-HG archive

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

[src/trunk]: src/sys Combine the midi and sequencer modules into a single mid...



details:   https://anonhg.NetBSD.org/src/rev/69d82798e24d
branches:  trunk
changeset: 366640:69d82798e24d
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Sat Jun 04 03:31:10 2022 +0000

description:
Combine the midi and sequencer modules into a single midi_seq module
to avoid a circular dependency as noted in kern/56772.  Retain minimal
modules of the original names to accomodate auto-loading upon access
to the /dev/xxx nodes.

diffstat:

 sys/dev/files.audio                    |    8 +-
 sys/dev/files.dev                      |    3 +-
 sys/dev/midi.c                         |   47 +------------
 sys/dev/midi_mod.c                     |   63 ++++++++++++++++
 sys/dev/midi_seq_mod.c                 |  123 +++++++++++++++++++++++++++++++++
 sys/dev/sequencer.c                    |   66 +-----------------
 sys/dev/sequencer_mod.c                |   63 ++++++++++++++++
 sys/modules/Makefile                   |    3 +-
 sys/modules/midi/Makefile              |   12 +--
 sys/modules/midi/midi.ioconf           |    9 --
 sys/modules/midi_seq/Makefile          |   23 ++++++
 sys/modules/midi_seq/midi_seq.ioconf   |   11 ++
 sys/modules/sequencer/Makefile         |   10 +--
 sys/modules/sequencer/sequencer.ioconf |    9 --
 14 files changed, 300 insertions(+), 150 deletions(-)

diffs (truncated from 610 to 300 lines):

diff -r f63786c6a349 -r 69d82798e24d sys/dev/files.audio
--- a/sys/dev/files.audio       Fri Jun 03 21:43:37 2022 +0000
+++ b/sys/dev/files.audio       Sat Jun 04 03:31:10 2022 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.audio,v 1.14 2020/01/25 19:22:05 jmcneill Exp $
+#      $NetBSD: files.audio,v 1.15 2022/06/04 03:31:10 pgoyette Exp $
 
 defparam opt_audio.h   AUDIO_BLK_MS
 
@@ -23,7 +23,11 @@
 file   dev/audio/audio.c               audio                   needs-flag
 file   dev/audio/audiobell.c           spkr_audio              needs-flag
 file   dev/audio/mulaw.c               audio
-file   dev/midi.c                      midi                    needs-flag
+file   dev/midi.c                      midi | sequencer        needs-flag
+file   dev/midi_mod.c                  midi | sequencer        needs-flag
+file   dev/midi_seq_mod.c              midi | sequencer        needs-flag
 file   dev/midictl.c                   midisyn
 file   dev/midisyn.c                   midisyn
+file   dev/sequencer.c                 midi | sequencer        needs-flag
+file   dev/sequencer_mod.c             midi | sequencer        needs-flag
 file   dev/spkr_audio.c                spkr_audio              needs-flag
diff -r f63786c6a349 -r 69d82798e24d sys/dev/files.dev
--- a/sys/dev/files.dev Fri Jun 03 21:43:37 2022 +0000
+++ b/sys/dev/files.dev Sat Jun 04 03:31:10 2022 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.dev,v 1.8 2021/10/10 13:03:09 jmcneill Exp $
+#      $NetBSD: files.dev,v 1.9 2022/06/04 03:31:10 pgoyette Exp $
 
 file   dev/bio.c                       bio                     needs-flag
 file   dev/ccd.c                       ccd
@@ -22,7 +22,6 @@
 file   dev/nullcons_subr.c             nullcons                needs-flag
 file   dev/radio.c                     radio                   needs-flag
 file   dev/random.c                    rnd                     needs-flag
-file   dev/sequencer.c                 sequencer               needs-flag
 file   dev/video.c                     video                   needs-flag
 file   dev/vnd.c                       vnd
 file   dev/ipmi.c                      ipmi                    needs-flag
diff -r f63786c6a349 -r 69d82798e24d sys/dev/midi.c
--- a/sys/dev/midi.c    Fri Jun 03 21:43:37 2022 +0000
+++ b/sys/dev/midi.c    Sat Jun 04 03:31:10 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: midi.c,v 1.97 2022/05/22 11:27:35 andvar Exp $ */
+/*     $NetBSD: midi.c,v 1.98 2022/06/04 03:31:10 pgoyette Exp $       */
 
 /*
  * Copyright (c) 1998, 2008 The NetBSD Foundation, Inc.
@@ -31,11 +31,10 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: midi.c,v 1.97 2022/05/22 11:27:35 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: midi.c,v 1.98 2022/06/04 03:31:10 pgoyette Exp $");
 
 #ifdef _KERNEL_OPT
 #include "midi.h"
-#include "sequencer.h"
 #endif
 
 #include <sys/param.h>
@@ -1900,45 +1899,3 @@
 }
 
 #endif /* NMIDI > 0 || NMIDIBUS > 0 */
-
-#ifdef _MODULE
-#include "ioconf.c"
-
-devmajor_t midi_bmajor = -1, midi_cmajor = -1;
-#endif
-
-MODULE(MODULE_CLASS_DRIVER, midi, "audio");
-
-static int
-midi_modcmd(modcmd_t cmd, void *arg)
-{
-       int error = 0;
-
-#ifdef _MODULE
-       switch (cmd) {
-       case MODULE_CMD_INIT:
-               error = devsw_attach(midi_cd.cd_name, NULL, &midi_bmajor,
-                   &midi_cdevsw, &midi_cmajor);
-               if (error)
-                       break;
-
-               error = config_init_component(cfdriver_ioconf_midi,
-                   cfattach_ioconf_midi, cfdata_ioconf_midi);
-               if (error) {
-                       devsw_detach(NULL, &midi_cdevsw);
-               }
-               break;
-       case MODULE_CMD_FINI:
-               error = config_fini_component(cfdriver_ioconf_midi,
-                  cfattach_ioconf_midi, cfdata_ioconf_midi);
-               if (error == 0)
-                       devsw_detach(NULL, &midi_cdevsw);
-               break;
-       default:
-               error = ENOTTY;
-               break;
-       }
-#endif
-
-       return error;
-}
diff -r f63786c6a349 -r 69d82798e24d sys/dev/midi_mod.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/dev/midi_mod.c        Sat Jun 04 03:31:10 2022 +0000
@@ -0,0 +1,63 @@
+/*     $NetBSD: midi_mod.c,v 1.1 2022/06/04 03:31:10 pgoyette Exp $ */
+
+/*
+ * Copyright (c) 2022 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Paul Goyette
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: midi_mod.c,v 1.1 2022/06/04 03:31:10 pgoyette Exp $");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/module.h>
+
+/*
+ * The midi module itself doesn't do anything.  It exists only to
+ * ensure that the combo-module for midi-plus-sequencer is loaded.
+ * This allows us to have both midi and sequencer code to refer
+ * to each other, avoiding a circular module dependency.
+ */
+
+MODULE(MODULE_CLASS_DRIVER, midi, "midi_seq");
+
+static int
+midi_modcmd(modcmd_t cmd, void *arg)
+{
+       int error = 0;
+
+       switch (cmd) {
+       case MODULE_CMD_INIT:
+       case MODULE_CMD_FINI:
+               break;
+       default:
+               error = ENOTTY;
+               break;
+       }
+       return error;
+}
diff -r f63786c6a349 -r 69d82798e24d sys/dev/midi_seq_mod.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/dev/midi_seq_mod.c    Sat Jun 04 03:31:10 2022 +0000
@@ -0,0 +1,123 @@
+/*     $NetBSD: midi_seq_mod.c,v 1.1 2022/06/04 03:31:10 pgoyette Exp $        */
+
+/*
+ * Copyright (c) 1998, 2008 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Lennart Augustsson (augustss%NetBSD.org@localhost), (MIDI FST and Active
+ * Sense handling) Chapman Flack (chap%NetBSD.org@localhost), and Andrew Doran.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: midi_seq_mod.c,v 1.1 2022/06/04 03:31:10 pgoyette Exp $");
+
+#ifdef _KERNEL_OPT
+#include "midi.h"
+#endif
+
+#include <sys/param.h>
+#include <sys/ioctl.h>
+#include <sys/fcntl.h>
+#include <sys/vnode.h>
+#include <sys/select.h>
+#include <sys/poll.h>
+#include <sys/proc.h>
+#include <sys/systm.h>
+#include <sys/callout.h>
+#include <sys/syslog.h>
+#include <sys/kernel.h>
+#include <sys/signalvar.h>
+#include <sys/conf.h>
+#include <sys/audioio.h>
+#include <sys/midiio.h>
+#include <sys/device.h>
+#include <sys/intr.h>
+#include <sys/module.h>
+
+#include <dev/audio/audio_if.h>
+#include <dev/midi_if.h>
+#include <dev/midivar.h>
+
+#include "ioconf.h"
+
+extern struct cfdriver sequencer_cd;
+extern struct cdevsw midi_cdevsw;
+extern struct cdevsw sequencer_cdevsw;
+
+#ifdef _MODULE
+#include "ioconf.c"
+
+CFDRIVER_DECL(sequencer, DV_DULL, NULL);
+
+devmajor_t midi_bmajor = -1, midi_cmajor = -1;
+devmajor_t sequencer_bmajor = -1, sequencer_cmajor = -1;
+#endif
+
+MODULE(MODULE_CLASS_DRIVER, midi_seq, "audio");
+
+static int
+midi_seq_modcmd(modcmd_t cmd, void *arg)
+{
+       int error = 0;
+
+#ifdef _MODULE
+       switch (cmd) {
+       case MODULE_CMD_INIT:
+               error = devsw_attach(midi_cd.cd_name, NULL, &midi_bmajor,
+                   &midi_cdevsw, &midi_cmajor);
+               if (error)
+                       break;
+
+               error = devsw_attach(sequencer_cd.cd_name,
+                   NULL, &sequencer_bmajor,
+                   &sequencer_cdevsw, &sequencer_cmajor);
+               if (error) {
+                       devsw_detach(NULL, &midi_cdevsw);
+                       break;
+               }
+
+               error = config_init_component(cfdriver_ioconf_midi_seq,
+                   cfattach_ioconf_midi_seq, cfdata_ioconf_midi_seq);
+               if (error) {
+                       devsw_detach(NULL, &sequencer_cdevsw);
+                       devsw_detach(NULL, &midi_cdevsw);
+               }
+               break;
+       case MODULE_CMD_FINI:
+               error = config_fini_component(cfdriver_ioconf_midi_seq,
+                  cfattach_ioconf_midi_seq, cfdata_ioconf_midi_seq);
+               if (error == 0) {
+                       devsw_detach(NULL, &sequencer_cdevsw);
+                       devsw_detach(NULL, &midi_cdevsw);
+               }
+               break;
+       default:
+               error = ENOTTY;
+               break;
+       }
+#endif
+
+       return error;



Home | Main Index | Thread Index | Old Index