On Wed, 29 Jan 2025 17:05:19 +0100, John Keeping wrote: > > In the two loops before setting the MIDIStreaming descriptors, > ms_in_desc.baAssocJackID[] has entries written for "in_ports" values and > ms_out_desc.baAssocJackID[] has entries written for "out_ports" values. > But the counts and lengths are set the other way round in the > descriptors. > > Fix the descriptors so that the bNumEmbMIDIJack values and the > descriptor lengths match the number of entries populated in the trailing > arrays. Are you sure that it's a correct change? IIUC, the in_ports and out_ports parameters are for external IN and OUT jacks, where an external OUT jack is connected to an embedded IN jack, and an external IN jack is connected to an embedded OUT jack. thanks, Takashi > > Cc: stable@xxxxxxxxxxxxxxx > Fixes: c8933c3f79568 ("USB: gadget: f_midi: allow a dynamic number of input and output ports") > Signed-off-by: John Keeping <jkeeping@xxxxxxxxxxxxxxxxx> > --- > drivers/usb/gadget/function/f_midi.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/drivers/usb/gadget/function/f_midi.c b/drivers/usb/gadget/function/f_midi.c > index 837fcdfa3840f..6cc3d86cb4774 100644 > --- a/drivers/usb/gadget/function/f_midi.c > +++ b/drivers/usb/gadget/function/f_midi.c > @@ -1000,11 +1000,11 @@ static int f_midi_bind(struct usb_configuration *c, struct usb_function *f) > } > > /* configure the endpoint descriptors ... */ > - ms_out_desc.bLength = USB_DT_MS_ENDPOINT_SIZE(midi->in_ports); > - ms_out_desc.bNumEmbMIDIJack = midi->in_ports; > + ms_out_desc.bLength = USB_DT_MS_ENDPOINT_SIZE(midi->out_ports); > + ms_out_desc.bNumEmbMIDIJack = midi->out_ports; > > - ms_in_desc.bLength = USB_DT_MS_ENDPOINT_SIZE(midi->out_ports); > - ms_in_desc.bNumEmbMIDIJack = midi->out_ports; > + ms_in_desc.bLength = USB_DT_MS_ENDPOINT_SIZE(midi->in_ports); > + ms_in_desc.bNumEmbMIDIJack = midi->in_ports; > > /* ... and add them to the list */ > endpoint_descriptor_index = i; > -- > 2.48.1 > >