mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2025-01-20 01:48:28 +07:00
usb: gadget: f_midi: stash substream in gmidi_in_port structure
For every in_substream, there must be a corresponding gmidi_in_port structure so it is perfectly viable and some might argue sensible to stash pointer to the input substream in the gmidi_in_port structure. This has an added benefit that if in_ports < MAX_PORTS, the whole f_midi structure takes up less space because only in_ports number of pointers for in_substream are allocated instead of MAX_PORTS lots of them. Signed-off-by: Michal Nazarewicz <mina86@mina86.com> Signed-off-by: Felipe Balbi <balbi@kernel.org>
This commit is contained in:
parent
413489c833
commit
4111d4943a
@ -56,6 +56,7 @@ static const char f_midi_longname[] = "MIDI Gadget";
|
||||
* USB <- IN endpoint <- rawmidi
|
||||
*/
|
||||
struct gmidi_in_port {
|
||||
struct snd_rawmidi_substream *substream;
|
||||
int active;
|
||||
uint8_t cable;
|
||||
uint8_t state;
|
||||
@ -77,7 +78,6 @@ struct f_midi {
|
||||
struct snd_rawmidi *rmidi;
|
||||
u8 ms_id;
|
||||
|
||||
struct snd_rawmidi_substream *in_substream[MAX_PORTS];
|
||||
struct snd_rawmidi_substream *out_substream[MAX_PORTS];
|
||||
|
||||
unsigned long out_triggered;
|
||||
@ -520,7 +520,7 @@ static void f_midi_drop_out_substreams(struct f_midi *midi)
|
||||
|
||||
for (i = 0; i < midi->in_ports; i++) {
|
||||
struct gmidi_in_port *port = midi->in_ports_array + i;
|
||||
struct snd_rawmidi_substream *substream = midi->in_substream[i];
|
||||
struct snd_rawmidi_substream *substream = port->substream;
|
||||
if (port->active && substream)
|
||||
snd_rawmidi_drop_output(substream);
|
||||
}
|
||||
@ -554,7 +554,7 @@ static int f_midi_do_transmit(struct f_midi *midi, struct usb_ep *ep)
|
||||
|
||||
for (i = midi->in_last_port; i < midi->in_ports; ++i) {
|
||||
struct gmidi_in_port *port = midi->in_ports_array + i;
|
||||
struct snd_rawmidi_substream *substream = midi->in_substream[i];
|
||||
struct snd_rawmidi_substream *substream = port->substream;
|
||||
|
||||
if (!port->active || !substream)
|
||||
continue;
|
||||
@ -623,13 +623,15 @@ static void f_midi_in_tasklet(unsigned long data)
|
||||
static int f_midi_in_open(struct snd_rawmidi_substream *substream)
|
||||
{
|
||||
struct f_midi *midi = substream->rmidi->private_data;
|
||||
struct gmidi_in_port *port;
|
||||
|
||||
if (substream->number >= midi->in_ports)
|
||||
return -EINVAL;
|
||||
|
||||
VDBG(midi, "%s()\n", __func__);
|
||||
midi->in_substream[substream->number] = substream;
|
||||
midi->in_ports_array[substream->number].state = STATE_UNKNOWN;
|
||||
port = midi->in_ports_array + substream->number;
|
||||
port->substream = substream;
|
||||
port->state = STATE_UNKNOWN;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user