Linux Sound subsystem development
 help / color / mirror / Atom feed
* [PATCH 1/2] ALSA: usb-audio: Simplify usb_audio_make_shortname()
@ 2026-10-18 12:41 Thorsten Blum
  2026-10-18 12:41 ` [PATCH 2/2] ALSA: usb-audio: Simplify usb_audio_make_longname() Thorsten Blum
  2026-10-19  8:43 ` [PATCH 1/2] ALSA: usb-audio: Simplify usb_audio_make_shortname() Takashi Iwai
  0 siblings, 2 replies; 3+ messages in thread
From: Thorsten Blum @ 2026-10-18 12:41 UTC (permalink / raw)
  To: Jaroslav Kysela, Takashi Iwai, Cássio Gabriel, Cen Zhang,
	Will Porter
  Cc: Thorsten Blum, Takashi Iwai, linux-sound, linux-kernel

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@kernel.org>
---
 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,

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-10-19  8:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-18 12:41 [PATCH 1/2] ALSA: usb-audio: Simplify usb_audio_make_shortname() Thorsten Blum
2026-10-18 12:41 ` [PATCH 2/2] ALSA: usb-audio: Simplify usb_audio_make_longname() Thorsten Blum
2026-10-19  8:43 ` [PATCH 1/2] ALSA: usb-audio: Simplify usb_audio_make_shortname() Takashi Iwai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox