mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
ALSA: usb-audio: Use strings in struct usb_dev for manufacturer & co
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>
This commit is contained in:
parent
27b9bcad2b
commit
b364a0d23c
|
|
@ -631,9 +631,9 @@ static void usb_audio_make_shortname(struct usb_device *dev,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* retrieve the device string as shortname */
|
/* retrieve the device string as shortname */
|
||||||
if (!dev->descriptor.iProduct ||
|
if (dev->product && *dev->product) {
|
||||||
usb_string(dev, dev->descriptor.iProduct,
|
strscpy(card->shortname, dev->product);
|
||||||
card->shortname, sizeof(card->shortname)) <= 0) {
|
} else {
|
||||||
/* no name available from anywhere, so use ID */
|
/* no name available from anywhere, so use ID */
|
||||||
scnprintf(card->shortname, sizeof(card->shortname),
|
scnprintf(card->shortname, sizeof(card->shortname),
|
||||||
"USB Device %#04x:%#04x",
|
"USB Device %#04x:%#04x",
|
||||||
|
|
@ -668,15 +668,11 @@ static void usb_audio_make_longname(struct usb_device *dev,
|
||||||
else if (quirk && quirk->vendor_name)
|
else if (quirk && quirk->vendor_name)
|
||||||
s = quirk->vendor_name;
|
s = quirk->vendor_name;
|
||||||
*card->longname = 0;
|
*card->longname = 0;
|
||||||
if (s && *s) {
|
if (s && *s)
|
||||||
strscpy(card->longname, s, sizeof(card->longname));
|
strscpy(card->longname, s);
|
||||||
} else {
|
else if (dev->manufacturer && *dev->manufacturer)
|
||||||
/* retrieve the vendor and device strings as longname */
|
strscpy(card->longname, dev->manufacturer);
|
||||||
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 (*card->longname) {
|
if (*card->longname) {
|
||||||
strim(card->longname);
|
strim(card->longname);
|
||||||
if (*card->longname)
|
if (*card->longname)
|
||||||
|
|
|
||||||
|
|
@ -1057,10 +1057,8 @@ static void set_fallback_rawmidi_names(struct snd_usb_midi2_interface *umidi)
|
||||||
strscpy(ump->core.name, ump->info.name,
|
strscpy(ump->core.name, ump->info.name,
|
||||||
sizeof(ump->core.name));
|
sizeof(ump->core.name));
|
||||||
/* use serial number string as unique UMP product id */
|
/* use serial number string as unique UMP product id */
|
||||||
if (!*ump->info.product_id && dev->descriptor.iSerialNumber)
|
if (!*ump->info.product_id && dev->serial && *dev->serial)
|
||||||
usb_string(dev, dev->descriptor.iSerialNumber,
|
strscpy(ump->info.product_id, dev->serial);
|
||||||
ump->info.product_id,
|
|
||||||
sizeof(ump->info.product_id));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user