int client; /* Client for this port */
int port; /* The port number */
- int max_channels; /* Size of the channels array */
- struct snd_midi_channel *channels;
-
unsigned char midi_mode; /* MIDI operating mode */
unsigned char gs_master_volume; /* SYSEX master volume: 0-127 */
unsigned char gs_chorus_mode;
unsigned char gs_reverb_mode;
+ int max_channels; /* Size of the channels array */
+ struct snd_midi_channel channels[] __counted_by(max_channels);
+
};
struct snd_midi_op {
pr_debug("ALSA: seq_midi_emul: ev or chanbase NULL (snd_midi_process_event)\n");
return;
}
- if (chanset->channels == NULL)
- return;
-
if (snd_seq_ev_is_channel_type(ev)) {
dest_channel = ev->data.note.channel;
if (dest_channel >= chanset->max_channels) {
p->drum_channel = 1; /* Default ch 10 as drums */
}
-/*
- * Allocate and initialise a set of midi channel control blocks.
- */
-static struct snd_midi_channel *snd_midi_channel_init_set(int n)
-{
- struct snd_midi_channel *chan;
- int i;
-
- chan = kmalloc_objs(struct snd_midi_channel, n);
- if (chan) {
- for (i = 0; i < n; i++)
- snd_midi_channel_init(chan+i, i);
- }
-
- return chan;
-}
-
/*
* reset all midi channels
*/
struct snd_midi_channel_set *snd_midi_channel_alloc_set(int n)
{
struct snd_midi_channel_set *chset;
+ int i;
+
+ chset = kmalloc_flex(*chset, channels, n);
+ if (!chset)
+ return NULL;
+
+ chset->max_channels = n;
+ chset->private_data = NULL;
+
+ for (i = 0; i < n; i++)
+ snd_midi_channel_init(&chset->channels[i], i);
- chset = kmalloc_obj(*chset);
- if (chset) {
- chset->channels = snd_midi_channel_init_set(n);
- chset->private_data = NULL;
- chset->max_channels = n;
- }
return chset;
}
EXPORT_SYMBOL(snd_midi_channel_alloc_set);
{
if (chset == NULL)
return;
- kfree(chset->channels);
kfree(chset);
}
EXPORT_SYMBOL(snd_midi_channel_free_set);
int i, type, cap;
/* Allocate structures for this channel */
- p = kzalloc_obj(*p);
+ p = kzalloc_flex(*p, chset.channels, max_channels);
if (!p)
return NULL;
- p->chset.channels = kzalloc_objs(*p->chset.channels, max_channels);
- if (!p->chset.channels) {
- kfree(p);
- return NULL;
- }
+ p->chset.max_channels = max_channels;
+
for (i = 0; i < max_channels; i++)
p->chset.channels[i].number = i;
p->chset.private_data = p;
- p->chset.max_channels = max_channels;
p->emu = emu;
p->chset.client = emu->client;
#ifdef SNDRV_EMUX_USE_RAW_EFFECT
#ifdef SNDRV_EMUX_USE_RAW_EFFECT
snd_emux_delete_effect(p);
#endif
- kfree(p->chset.channels);
kfree(p);
}
}