summaryrefslogtreecommitdiffstats
path: root/sys/dev/sound/isa
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/sound/isa')
-rw-r--r--sys/dev/sound/isa/emu8000.c24
-rw-r--r--sys/dev/sound/isa/gusmidi.c19
-rw-r--r--sys/dev/sound/isa/mpu.c14
-rw-r--r--sys/dev/sound/isa/opl.c34
-rw-r--r--sys/dev/sound/isa/uartsio.c14
5 files changed, 15 insertions, 90 deletions
diff --git a/sys/dev/sound/isa/emu8000.c b/sys/dev/sound/isa/emu8000.c
index 25f1802..0efb05c 100644
--- a/sys/dev/sound/isa/emu8000.c
+++ b/sys/dev/sound/isa/emu8000.c
@@ -723,7 +723,7 @@ emu_attach(device_t dev)
emu_writehwcf3(scp, 0x0004);
/* Fill the softc for this unit. */
- scp->devinfo = devinfo = &midi_info[unit];
+ scp->devinfo = devinfo = create_mididev_info_unit(&unit, MDT_SYNTH);
bcopy(&emu_synthinfo, &scp->synthinfo, sizeof(emu_synthinfo));
/* Fill the midi info. */
@@ -741,9 +741,6 @@ emu_attach(device_t dev)
midibuf_init(&devinfo->midi_dbuf_in);
midibuf_init(&devinfo->midi_dbuf_out);
- /* Increase the number of the synthesizers. */
- nsynth++;
-
DEB(printf("emu%d: attached.\n", unit));
return (0);
@@ -776,11 +773,6 @@ emu_read(dev_t i_dev, struct uio *buf, int flag)
unit = MIDIUNIT(i_dev);
- if (unit >= nmidi + nsynth) {
- DEB(printf("emu_read: unit %d does not exist.\n", unit));
- return (ENXIO);
- }
-
devinfo = get_mididev_info(i_dev, &unit);
if (devinfo == NULL) {
DEB(printf("emu_read: unit %d is not configured.\n", unit));
@@ -807,11 +799,6 @@ emu_write(dev_t i_dev, struct uio *buf, int flag)
unit = MIDIUNIT(i_dev);
- if (unit >= nmidi + nsynth) {
- DEB(printf("emu_write: unit %d does not exist.\n", unit));
- return (ENXIO);
- }
-
devinfo = get_mididev_info(i_dev, &unit);
if (devinfo == NULL) {
DEB(printf("emu_write: unit %d is not configured.\n", unit));
@@ -843,11 +830,6 @@ emu_ioctl(dev_t i_dev, u_long cmd, caddr_t arg, int mode, struct proc *p)
DEB(printf("emu%d: ioctlling, cmd 0x%x.\n", unit, (int)cmd));
- if (unit >= nmidi + nsynth) {
- DEB(printf("emu_ioctl: unit %d does not exist.\n", unit));
- return (ENXIO);
- }
-
devinfo = get_mididev_info(i_dev, &unit);
if (devinfo == NULL) {
DEB(printf("emu_ioctl: unit %d is not configured.\n", unit));
@@ -858,7 +840,7 @@ emu_ioctl(dev_t i_dev, u_long cmd, caddr_t arg, int mode, struct proc *p)
switch (cmd) {
case SNDCTL_SYNTH_INFO:
synthinfo = (struct synth_info *)arg;
- if (synthinfo->device >= nmidi + nsynth || synthinfo->device != unit)
+ if (synthinfo->device != unit)
return (ENXIO);
bcopy(&scp->synthinfo, synthinfo, sizeof(scp->synthinfo));
synthinfo->device = unit;
@@ -866,7 +848,7 @@ emu_ioctl(dev_t i_dev, u_long cmd, caddr_t arg, int mode, struct proc *p)
break;
case SNDCTL_MIDI_INFO:
midiinfo = (struct midi_info *)arg;
- if (midiinfo->device >= nmidi + nsynth || midiinfo->device != unit)
+ if (midiinfo->device != unit)
return (ENXIO);
bcopy(&emu_midiinfo, midiinfo, sizeof(emu_midiinfo));
strcpy(midiinfo->name, scp->synthinfo.name);
diff --git a/sys/dev/sound/isa/gusmidi.c b/sys/dev/sound/isa/gusmidi.c
index 11644f8..d95c75f 100644
--- a/sys/dev/sound/isa/gusmidi.c
+++ b/sys/dev/sound/isa/gusmidi.c
@@ -199,7 +199,7 @@ gusmidi_init(device_t dev)
/* Fill the softc. */
scp->dev = dev;
- scp->devinfo = devinfo = &midi_info[unit];
+ scp->devinfo = devinfo = create_mididev_info_unit(&unit, MDT_MIDI);
/* Fill the midi info. */
bcopy(&gusmidi_op_desc, devinfo, sizeof(gusmidi_op_desc));
@@ -222,9 +222,6 @@ gusmidi_init(device_t dev)
bus_setup_intr(dev, scp->irq, INTR_TYPE_TTY, gusmidi_intr, scp,
&scp->ih);
- /* Increase the number of midi devices. */
- nmidi++;
-
return (0);
}
@@ -237,11 +234,6 @@ gusmidi_open(dev_t i_dev, int flags, int mode, struct proc *p)
unit = MIDIUNIT(i_dev);
- if (unit >= nmidi + nsynth) {
- DEB(printf("gusmidi_open: unit %d does not exist.\n", unit));
- return (ENXIO);
- }
-
devinfo = get_mididev_info(i_dev, &unit);
if (devinfo == NULL) {
DEB(printf("gusmidi_open: unit %d is not configured.\n", unit));
@@ -268,11 +260,6 @@ gusmidi_ioctl(dev_t i_dev, u_long cmd, caddr_t arg, int mode, struct proc *p)
unit = MIDIUNIT(i_dev);
- if (unit >= nmidi + nsynth) {
- DEB(printf("gusmidi_ioctl: unit %d does not exist.\n", unit));
- return (ENXIO);
- }
-
devinfo = get_mididev_info(i_dev, &unit);
if (devinfo == NULL) {
DEB(printf("gusmidi_ioctl: unit %d is not configured.\n", unit));
@@ -283,7 +270,7 @@ gusmidi_ioctl(dev_t i_dev, u_long cmd, caddr_t arg, int mode, struct proc *p)
switch (cmd) {
case SNDCTL_SYNTH_INFO:
synthinfo = (struct synth_info *)arg;
- if (synthinfo->device > nmidi + nsynth || synthinfo->device != unit)
+ if (synthinfo->device != unit)
return (ENXIO);
bcopy(&gusmidi_synthinfo, synthinfo, sizeof(gusmidi_synthinfo));
synthinfo->device = unit;
@@ -291,7 +278,7 @@ gusmidi_ioctl(dev_t i_dev, u_long cmd, caddr_t arg, int mode, struct proc *p)
break;
case SNDCTL_MIDI_INFO:
midiinfo = (struct midi_info *)arg;
- if (midiinfo->device > nmidi + nsynth || midiinfo->device != unit)
+ if (midiinfo->device != unit)
return (ENXIO);
bcopy(&gusmidi_midiinfo, midiinfo, sizeof(gusmidi_midiinfo));
midiinfo->device = unit;
diff --git a/sys/dev/sound/isa/mpu.c b/sys/dev/sound/isa/mpu.c
index 2ed93c1..4adb80d 100644
--- a/sys/dev/sound/isa/mpu.c
+++ b/sys/dev/sound/isa/mpu.c
@@ -379,7 +379,7 @@ mpu_attach(device_t dev)
/* Fill the softc. */
scp->dev = dev;
- scp->devinfo = devinfo = &midi_info[unit];
+ scp->devinfo = devinfo = create_mididev_info_unit(&unit, MDT_MIDI);
callout_handle_init(&scp->dh);
/* Fill the midi info. */
@@ -399,9 +399,6 @@ mpu_attach(device_t dev)
midibuf_init(&devinfo->midi_dbuf_in);
midibuf_init(&devinfo->midi_dbuf_out);
- /* Increase the number of midi devices. */
- nmidi++;
-
/* Now we can handle the interrupts. */
if (scp->irq != NULL)
bus_setup_intr(dev, scp->irq, INTR_TYPE_TTY, mpu_intr, scp,
@@ -437,11 +434,6 @@ mpu_ioctl(dev_t i_dev, u_long cmd, caddr_t arg, int mode, struct proc *p)
unit = MIDIUNIT(i_dev);
- if (unit >= nmidi + nsynth) {
- DEB(printf("mpu_ioctl: unit %d does not exist.\n", unit));
- return (ENXIO);
- }
-
devinfo = get_mididev_info(i_dev, &unit);
if (devinfo == NULL) {
DEB(printf("mpu_ioctl: unit %d is not configured.\n", unit));
@@ -452,7 +444,7 @@ mpu_ioctl(dev_t i_dev, u_long cmd, caddr_t arg, int mode, struct proc *p)
switch (cmd) {
case SNDCTL_SYNTH_INFO:
synthinfo = (struct synth_info *)arg;
- if (synthinfo->device > nmidi + nsynth || synthinfo->device != unit)
+ if (synthinfo->device != unit)
return (ENXIO);
bcopy(&mpu_synthinfo, synthinfo, sizeof(mpu_synthinfo));
synthinfo->device = unit;
@@ -460,7 +452,7 @@ mpu_ioctl(dev_t i_dev, u_long cmd, caddr_t arg, int mode, struct proc *p)
break;
case SNDCTL_MIDI_INFO:
midiinfo = (struct midi_info *)arg;
- if (midiinfo->device > nmidi + nsynth || midiinfo->device != unit)
+ if (midiinfo->device != unit)
return (ENXIO);
bcopy(&mpu_midiinfo, midiinfo, sizeof(mpu_midiinfo));
midiinfo->device = unit;
diff --git a/sys/dev/sound/isa/opl.c b/sys/dev/sound/isa/opl.c
index ab433c5..2d41321 100644
--- a/sys/dev/sound/isa/opl.c
+++ b/sys/dev/sound/isa/opl.c
@@ -654,7 +654,7 @@ opl_attach(device_t dev)
/* Fill the softc for this unit. */
scp->dev = dev;
- scp->devinfo = devinfo = &midi_info[unit];
+ scp->devinfo = devinfo = create_mididev_info_unit(&unit, MDT_SYNTH);
/* Allocate other resources. */
if (opl_allocres(scp, dev)) {
@@ -761,9 +761,6 @@ opl_attach(device_t dev)
midibuf_init(&devinfo->midi_dbuf_in);
midibuf_init(&devinfo->midi_dbuf_out);
- /* Increase the number of the synthesizers. */
- nsynth++;
-
DEB(printf("opl%d: attached.\n", unit));
DEB(printf("opl%d: the chip is OPL%d.\n", unit, scp->model));
@@ -787,11 +784,6 @@ opl_open(dev_t i_dev, int flags, int mode, struct proc *p)
DEB(printf("opl%d: opening.\n", unit));
- if (unit >= nmidi + nsynth) {
- DEB(printf("opl_open: unit %d does not exist.\n", unit));
- return (ENXIO);
- }
-
devinfo = get_mididev_info(i_dev, &unit);
if (devinfo == NULL) {
DEB(printf("opl_open: unit %d is not configured.\n", unit));
@@ -828,11 +820,6 @@ opl_close(dev_t i_dev, int flags, int mode, struct proc *p)
DEB(printf("opl%d: closing.\n", unit));
- if (unit >= nmidi + nsynth) {
- DEB(printf("opl_close: unit %d does not exist.\n", unit));
- return (ENXIO);
- }
-
devinfo = get_mididev_info(i_dev, &unit);
if (devinfo == NULL) {
DEB(printf("opl_close: unit %d is not configured.\n", unit));
@@ -862,11 +849,6 @@ opl_read(dev_t i_dev, struct uio *buf, int flag)
unit = MIDIUNIT(i_dev);
- if (unit >= nmidi + nsynth) {
- DEB(printf("opl_read: unit %d does not exist.\n", unit));
- return (ENXIO);
- }
-
devinfo = get_mididev_info(i_dev, &unit);
if (devinfo == NULL) {
DEB(printf("opl_read: unit %d is not configured.\n", unit));
@@ -894,11 +876,6 @@ opl_write(dev_t i_dev, struct uio *buf, int flag)
unit = MIDIUNIT(i_dev);
- if (unit >= nmidi + nsynth) {
- DEB(printf("opl_write: unit %d does not exist.\n", unit));
- return (ENXIO);
- }
-
devinfo = get_mididev_info(i_dev, &unit);
if (devinfo == NULL) {
DEB(printf("opl_write: unit %d is not configured.\n", unit));
@@ -932,11 +909,6 @@ opl_ioctl(dev_t i_dev, u_long cmd, caddr_t arg, int mode, struct proc *p)
DEB(printf("opl%d: ioctlling, cmd 0x%x.\n", unit, (int)cmd));
- if (unit >= nmidi + nsynth) {
- DEB(printf("opl_ioctl: unit %d does not exist.\n", unit));
- return (ENXIO);
- }
-
devinfo = get_mididev_info(i_dev, &unit);
if (devinfo == NULL) {
DEB(printf("opl_ioctl: unit %d is not configured.\n", unit));
@@ -947,7 +919,7 @@ opl_ioctl(dev_t i_dev, u_long cmd, caddr_t arg, int mode, struct proc *p)
switch (cmd) {
case SNDCTL_SYNTH_INFO:
synthinfo = (struct synth_info *)arg;
- if (synthinfo->device >= nmidi + nsynth || synthinfo->device != unit)
+ if (synthinfo->device != unit)
return (ENXIO);
bcopy(&scp->synthinfo, synthinfo, sizeof(scp->synthinfo));
synthinfo->device = unit;
@@ -959,7 +931,7 @@ opl_ioctl(dev_t i_dev, u_long cmd, caddr_t arg, int mode, struct proc *p)
break;
case SNDCTL_MIDI_INFO:
midiinfo = (struct midi_info *)arg;
- if (midiinfo->device >= nmidi + nsynth || midiinfo->device != unit)
+ if (midiinfo->device != unit)
return (ENXIO);
bcopy(&opl_midiinfo, midiinfo, sizeof(opl_midiinfo));
strcpy(midiinfo->name, scp->synthinfo.name);
diff --git a/sys/dev/sound/isa/uartsio.c b/sys/dev/sound/isa/uartsio.c
index 56b4e5d..5f56e36 100644
--- a/sys/dev/sound/isa/uartsio.c
+++ b/sys/dev/sound/isa/uartsio.c
@@ -228,7 +228,7 @@ uartsio_attach(device_t dev)
/* Fill the softc. */
scp->dev = dev;
- scp->devinfo = devinfo = &midi_info[unit];
+ scp->devinfo = devinfo = create_mididev_info_unit(&unit, MDT_MIDI);
/* Fill the midi info. */
bcopy(&uartsio_op_desc, devinfo, sizeof(uartsio_op_desc));
@@ -262,9 +262,6 @@ uartsio_attach(device_t dev)
uartsio_readport(scp, com_iir);
uartsio_readport(scp, com_data);
- /* Increase the number of midi devices. */
- nmidi++;
-
/* Now we can handle the interrupts. */
bus_setup_intr(dev, scp->irq, INTR_TYPE_TTY, uartsio_intr, scp, &scp->ih);
@@ -284,11 +281,6 @@ uartsio_ioctl(dev_t i_dev, u_long cmd, caddr_t arg, int mode, struct proc *p)
unit = MIDIUNIT(i_dev);
- if (unit >= nmidi + nsynth) {
- DEB(printf("uartsio_ioctl: unit %d does not exist.\n", unit));
- return (ENXIO);
- }
-
devinfo = get_mididev_info(i_dev, &unit);
if (devinfo == NULL) {
DEB(printf("uartsio_ioctl: unit %d is not configured.\n", unit));
@@ -299,7 +291,7 @@ uartsio_ioctl(dev_t i_dev, u_long cmd, caddr_t arg, int mode, struct proc *p)
switch (cmd) {
case SNDCTL_SYNTH_INFO:
synthinfo = (struct synth_info *)arg;
- if (synthinfo->device > nmidi + nsynth || synthinfo->device != unit)
+ if (synthinfo->device != unit)
return (ENXIO);
bcopy(&uartsio_synthinfo, synthinfo, sizeof(uartsio_synthinfo));
synthinfo->device = unit;
@@ -307,7 +299,7 @@ uartsio_ioctl(dev_t i_dev, u_long cmd, caddr_t arg, int mode, struct proc *p)
break;
case SNDCTL_MIDI_INFO:
midiinfo = (struct midi_info *)arg;
- if (midiinfo->device > nmidi + nsynth || midiinfo->device != unit)
+ if (midiinfo->device != unit)
return (ENXIO);
bcopy(&uartsio_midiinfo, midiinfo, sizeof(uartsio_midiinfo));
midiinfo->device = unit;
OpenPOWER on IntegriCloud