[PATCH 1/2] ALSA: usb-audio: Simplify usb_audio_make_shortname()

From: Thorsten Blum

Date: Sun Oct 18 2026 - 08:42:32 EST


Copy the preset and quirk product names directly and remove the local
char s pointer. Return after trimming the device product name and use
the USB device ID as a fallback.

No functional change.

Signed-off-by: Thorsten Blum <blum@xxxxxxxxxx>
---
sound/usb/card.c | 22 ++++++++--------------
1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/sound/usb/card.c b/sound/usb/card.c
index 9307da95efbe..8a62e8e1c6fc 100644
--- a/sound/usb/card.c
+++ b/sound/usb/card.c
@@ -618,30 +618,24 @@ static void usb_audio_make_shortname(struct usb_device *dev,
{
struct snd_card *card = chip->card;
const struct usb_audio_device_name *preset;
- const char *s = NULL;

+ *card->shortname = 0;
preset = lookup_device_name(chip->usb_id);
if (preset && preset->product_name)
- s = preset->product_name;
+ strscpy(card->shortname, preset->product_name);
else if (quirk && quirk->product_name)
- s = quirk->product_name;
- if (s && *s) {
- strscpy(card->shortname, s, sizeof(card->shortname));
+ strscpy(card->shortname, quirk->product_name);
+ if (*card->shortname)
return;
- }

- /* retrieve the device string as shortname */
if (dev->product && *dev->product) {
strscpy(card->shortname, dev->product);
- } else {
- /* no name available from anywhere, so use ID */
- scnprintf(card->shortname, sizeof(card->shortname),
- "USB Device %#04x:%#04x",
- USB_ID_VENDOR(chip->usb_id),
- USB_ID_PRODUCT(chip->usb_id));
+ strim(card->shortname);
+ return;
}

- strim(card->shortname);
+ scnprintf(card->shortname, sizeof(card->shortname), "USB Device %#04x:%#04x",
+ USB_ID_VENDOR(chip->usb_id), USB_ID_PRODUCT(chip->usb_id));
}

static void usb_audio_make_longname(struct usb_device *dev,