]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - sound/core/seq/seq_midi.c
ALSA: Kill snd_assert() in sound/core/*
[linux-2.6-omap-h63xx.git] / sound / core / seq / seq_midi.c
index 9caa1372bece852749bce58dfc373af4a3691b57..4d26146a62ccd8fd2fff0c73ea25507ff4a6550f 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *   Generic MIDI synth driver for ALSA sequencer
  *   Copyright (c) 1998 by Frank van de Pol <fvdpol@coil.demon.nl>
- *                         Jaroslav Kysela <perex@suse.cz>
+ *                         Jaroslav Kysela <perex@perex.cz>
  *
  *   This program is free software; you can redistribute it and/or modify
  *   it under the terms of the GNU General Public License as published by
@@ -26,7 +26,6 @@ Possible options for midisynth module:
 */
 
 
-#include <sound/driver.h>
 #include <linux/init.h>
 #include <linux/slab.h>
 #include <linux/errno.h>
@@ -40,7 +39,7 @@ Possible options for midisynth module:
 #include <sound/seq_midi_event.h>
 #include <sound/initval.h>
 
-MODULE_AUTHOR("Frank van de Pol <fvdpol@coil.demon.nl>, Jaroslav Kysela <perex@suse.cz>");
+MODULE_AUTHOR("Frank van de Pol <fvdpol@coil.demon.nl>, Jaroslav Kysela <perex@perex.cz>");
 MODULE_DESCRIPTION("Advanced Linux Sound Architecture sequencer MIDI synth.");
 MODULE_LICENSE("GPL");
 static int output_buffer_size = PAGE_SIZE;
@@ -117,7 +116,8 @@ static int dump_midi(struct snd_rawmidi_substream *substream, const char *buf, i
        struct snd_rawmidi_runtime *runtime;
        int tmp;
 
-       snd_assert(substream != NULL || buf != NULL, return -EINVAL);
+       if (snd_BUG_ON(!substream || !buf))
+               return -EINVAL;
        runtime = substream->runtime;
        if ((tmp = runtime->avail) < count) {
                snd_printd("warning, output event was lost (count = %i, available = %i)\n", count, tmp);
@@ -136,7 +136,8 @@ static int event_process_midi(struct snd_seq_event *ev, int direct,
        struct snd_rawmidi_substream *substream;
        int len;
 
-       snd_assert(msynth != NULL, return -EINVAL);
+       if (snd_BUG_ON(!msynth))
+               return -EINVAL;
        substream = msynth->output_rfile.output;
        if (substream == NULL)
                return -ENODEV;
@@ -211,7 +212,8 @@ static int midisynth_unsubscribe(void *private_data, struct snd_seq_port_subscri
        int err;
        struct seq_midisynth *msynth = private_data;
 
-       snd_assert(msynth->input_rfile.input != NULL, return -EINVAL);
+       if (snd_BUG_ON(!msynth->input_rfile.input))
+               return -EINVAL;
        err = snd_rawmidi_kernel_release(&msynth->input_rfile);
        return err;
 }
@@ -248,7 +250,8 @@ static int midisynth_unuse(void *private_data, struct snd_seq_port_subscribe *in
        struct seq_midisynth *msynth = private_data;
        unsigned char buf = 0xff; /* MIDI reset */
 
-       snd_assert(msynth->output_rfile.output != NULL, return -EINVAL);
+       if (snd_BUG_ON(!msynth->output_rfile.output))
+               return -EINVAL;
        /* sending single MIDI reset message to shut the device up */
        snd_rawmidi_kernel_write(msynth->output_rfile.output, &buf, 1);
        snd_rawmidi_drain_output(msynth->output_rfile.output);
@@ -278,6 +281,7 @@ snd_seq_midisynth_register_port(struct snd_seq_device *dev)
        struct seq_midisynth *msynth, *ms;
        struct snd_seq_port_info *port;
        struct snd_rawmidi_info *info;
+       struct snd_rawmidi *rmidi = dev->private_data;
        int newclient = 0;
        unsigned int p, ports;
        struct snd_seq_port_callback pcallbacks;
@@ -285,7 +289,8 @@ snd_seq_midisynth_register_port(struct snd_seq_device *dev)
        int device = dev->device;
        unsigned int input_count = 0, output_count = 0;
 
-       snd_assert(card != NULL && device >= 0 && device < SNDRV_RAWMIDI_DEVICES, return -EINVAL);
+       if (snd_BUG_ON(!card || device < 0 || device >= SNDRV_RAWMIDI_DEVICES))
+               return -EINVAL;
        info = kmalloc(sizeof(*info), GFP_KERNEL);
        if (! info)
                return -ENOMEM;
@@ -320,8 +325,8 @@ snd_seq_midisynth_register_port(struct snd_seq_device *dev)
                }
                client->seq_client =
                        snd_seq_create_kernel_client(
-                               card, 0, "%s", info->name[0] ?
-                               (const char *)info->name : "External MIDI");
+                               card, 0, "%s", card->shortname[0] ?
+                               (const char *)card->shortname : "External MIDI");
                if (client->seq_client < 0) {
                        kfree(client);
                        mutex_unlock(&register_mutex);
@@ -376,7 +381,9 @@ snd_seq_midisynth_register_port(struct snd_seq_device *dev)
                if ((port->capability & (SNDRV_SEQ_PORT_CAP_WRITE|SNDRV_SEQ_PORT_CAP_READ)) == (SNDRV_SEQ_PORT_CAP_WRITE|SNDRV_SEQ_PORT_CAP_READ) &&
                    info->flags & SNDRV_RAWMIDI_INFO_DUPLEX)
                        port->capability |= SNDRV_SEQ_PORT_CAP_DUPLEX;
-               port->type = SNDRV_SEQ_PORT_TYPE_MIDI_GENERIC;
+               port->type = SNDRV_SEQ_PORT_TYPE_MIDI_GENERIC
+                       | SNDRV_SEQ_PORT_TYPE_HARDWARE
+                       | SNDRV_SEQ_PORT_TYPE_PORT;
                port->midi_channels = 16;
                memset(&pcallbacks, 0, sizeof(pcallbacks));
                pcallbacks.owner = THIS_MODULE;
@@ -387,6 +394,8 @@ snd_seq_midisynth_register_port(struct snd_seq_device *dev)
                pcallbacks.unuse = midisynth_unuse;
                pcallbacks.event_input = event_process_midi;
                port->kernel = &pcallbacks;
+               if (rmidi->ops && rmidi->ops->get_port_info)
+                       rmidi->ops->get_port_info(rmidi, p, port);
                if (snd_seq_kernel_client_ctl(client->seq_client, SNDRV_SEQ_IOCTL_CREATE_PORT, port)<0)
                        goto __nomem;
                ms->seq_client = client->seq_client;