Skip to content

Commit 228a953

Browse files
tiwaigregkh
authored andcommitted
usb: gadget: midi2: Fix the response for FB info with block 0xff
When the block number 0xff is given to Function Block Discovery message, the device should return the information of all Function Blocks, but currently the gadget driver treats it as an error. Implement the proper behavior for the block 0xff instead. Fixes: 8b64592 ("usb: gadget: Add support for USB MIDI 2.0 function driver") Cc: [email protected] Signed-off-by: Takashi Iwai <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 16d7318 commit 228a953

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

drivers/usb/gadget/function/f_midi2.c

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -642,12 +642,21 @@ static void process_ump_stream_msg(struct f_midi2_ep *ep, const u32 *data)
642642
if (format)
643643
return; // invalid
644644
blk = (*data >> 8) & 0xff;
645-
if (blk >= ep->num_blks)
646-
return;
647-
if (*data & UMP_STREAM_MSG_REQUEST_FB_INFO)
648-
reply_ump_stream_fb_info(ep, blk);
649-
if (*data & UMP_STREAM_MSG_REQUEST_FB_NAME)
650-
reply_ump_stream_fb_name(ep, blk);
645+
if (blk == 0xff) {
646+
/* inquiry for all blocks */
647+
for (blk = 0; blk < ep->num_blks; blk++) {
648+
if (*data & UMP_STREAM_MSG_REQUEST_FB_INFO)
649+
reply_ump_stream_fb_info(ep, blk);
650+
if (*data & UMP_STREAM_MSG_REQUEST_FB_NAME)
651+
reply_ump_stream_fb_name(ep, blk);
652+
}
653+
} else if (blk < ep->num_blks) {
654+
/* only the specified block */
655+
if (*data & UMP_STREAM_MSG_REQUEST_FB_INFO)
656+
reply_ump_stream_fb_info(ep, blk);
657+
if (*data & UMP_STREAM_MSG_REQUEST_FB_NAME)
658+
reply_ump_stream_fb_name(ep, blk);
659+
}
651660
return;
652661
}
653662
}

0 commit comments

Comments
 (0)