Skip to content

Commit

Permalink
ALSA: usb-audio: Trim superfluous "MIDI" suffix from UMP EP name
Browse files Browse the repository at this point in the history
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 <perex@perex.cz>
Link: https://lore.kernel.org/r/20230523075358.9672-12-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
  • Loading branch information
Takashi Iwai committed May 23, 2023
1 parent 06cf3bf commit 5170140
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions sound/usb/midi2.c
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,14 @@ static int set_altset(struct snd_usb_midi2_interface *umidi)
static void fill_ump_ep_name(struct snd_ump_endpoint *ump,
struct usb_device *dev, int id)
{
int len;

usb_string(dev, id, ump->info.name, sizeof(ump->info.name));

/* trim superfluous "MIDI" suffix */
len = strlen(ump->info.name);
if (len > 5 && !strcmp(ump->info.name + len - 5, " MIDI"))
ump->info.name[len - 5] = 0;
}

/* fill the fallback name string for each rawmidi instance */
Expand Down

0 comments on commit 5170140

Please sign in to comment.