Skip to content

Commit 5170140

Browse files
committed
ALSA: usb-audio: Trim superfluous "MIDI" suffix from UMP EP name
A single USB audio device may have multiple interfaces for different purposes (e.g. audio, MIDI and HID), where the iInterface descriptor of each interface may contain an own suffix, e.g. "MIDI" for a MIDI interface. as such a suffix is superfluous as a rawmidi and UMP Endpoint name, this patch trims the superfluous "MIDI" suffix from the name string. Reviewed-by: Jaroslav Kysela <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent 06cf3bf commit 5170140

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

sound/usb/midi2.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -896,7 +896,14 @@ static int set_altset(struct snd_usb_midi2_interface *umidi)
896896
static void fill_ump_ep_name(struct snd_ump_endpoint *ump,
897897
struct usb_device *dev, int id)
898898
{
899+
int len;
900+
899901
usb_string(dev, id, ump->info.name, sizeof(ump->info.name));
902+
903+
/* trim superfluous "MIDI" suffix */
904+
len = strlen(ump->info.name);
905+
if (len > 5 && !strcmp(ump->info.name + len - 5, " MIDI"))
906+
ump->info.name[len - 5] = 0;
900907
}
901908

902909
/* fill the fallback name string for each rawmidi instance */

0 commit comments

Comments
 (0)