]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ALSA: usb-audio: Use strings in struct usb_dev for manufacturer & co
authorTakashi Iwai <tiwai@suse.de>
Thu, 5 Mar 2026 13:04:25 +0000 (14:04 +0100)
committerTakashi Iwai <tiwai@suse.de>
Thu, 5 Mar 2026 14:53:13 +0000 (15:53 +0100)
The USB core already prepares the strings for manufacturer, product
and serial number, and we don't have to extract the string at each
time.  Replace the manual usb_string() calls with the corresponding
pointers in struct usb_dev as a code cleanup.

Link: https://patch.msgid.link/20260305130426.975604-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/usb/card.c
sound/usb/midi2.c

index 270dad84d825e31264d910e79ffe5d4b7f56edd2..fd81f32a66fbd738a68d971e9987fc6dd0c5bbdb 100644 (file)
@@ -631,9 +631,9 @@ static void usb_audio_make_shortname(struct usb_device *dev,
        }
 
        /* retrieve the device string as shortname */
-       if (!dev->descriptor.iProduct ||
-           usb_string(dev, dev->descriptor.iProduct,
-                      card->shortname, sizeof(card->shortname)) <= 0) {
+       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",
@@ -668,15 +668,11 @@ static void usb_audio_make_longname(struct usb_device *dev,
        else if (quirk && quirk->vendor_name)
                s = quirk->vendor_name;
        *card->longname = 0;
-       if (s && *s) {
-               strscpy(card->longname, s, sizeof(card->longname));
-       } else {
-               /* retrieve the vendor and device strings as longname */
-               if (dev->descriptor.iManufacturer)
-                       usb_string(dev, dev->descriptor.iManufacturer,
-                                  card->longname, sizeof(card->longname));
-               /* we don't really care if there isn't any vendor string */
-       }
+       if (s && *s)
+               strscpy(card->longname, s);
+       else if (dev->manufacturer && *dev->manufacturer)
+               strscpy(card->longname, dev->manufacturer);
+
        if (*card->longname) {
                strim(card->longname);
                if (*card->longname)
index ef602e81576d9e06b03db5dc7def44746e5bd654..3546ba926cb3107351afbeb339f138f897931560 100644 (file)
@@ -1057,10 +1057,8 @@ static void set_fallback_rawmidi_names(struct snd_usb_midi2_interface *umidi)
                        strscpy(ump->core.name, ump->info.name,
                                sizeof(ump->core.name));
                /* use serial number string as unique UMP product id */
-               if (!*ump->info.product_id && dev->descriptor.iSerialNumber)
-                       usb_string(dev, dev->descriptor.iSerialNumber,
-                                  ump->info.product_id,
-                                  sizeof(ump->info.product_id));
+               if (!*ump->info.product_id && dev->serial && *dev->serial)
+                       strscpy(ump->info.product_id, dev->serial);
        }
 }