Re: [PATCH v2 4/8] ALSA: usb-audio: Support string-descriptor-based quirk table entry

From: Takashi Iwai

Date: Tue Mar 03 2026 - 01:37:44 EST


On Mon, 02 Mar 2026 19:58:55 +0100,
Rong Zhang wrote:
>
> Some quirky devices do not have a unique VID/PID. Matching them using
> DEVICE_FLG() or VENDOR_FLG() may result in conflicts.
>
> Add two new macros DEVICE_STRING_FLG() and VENDOR_STRING_FLG() to match
> USB string descriptors (manufacturer and/or product) in addition to VID
> and/or PID, so that we can deconflict these devices safely.
>
> No functional change intended.
>
> Signed-off-by: Rong Zhang <i@xxxxxxxx>
> ---
> Changes in v2:
> - Alloc string buffers with kmalloc() instead of on stack (thanks
> Takashi Iwai)
> - Get string descriptors in a neater way (ditto)
> - Tiny differences compared to Takashi's sugeestion:
> - Use `IS_ERR_OR_NULL() || strcmp()' instead of `!IS_ERR_OR_NULL() &&
> strcmp()', so failure in getting the string descriptor won't
> resulting in quirk flags being applied to irrelevant devices
> - Use trivial goto cleanup patterns instead of `__free(kfree)' as the
> latter can't handle ERR_PTR()

__free(kfree) can handle ERR_PTR() gracefully :)
In linux/slab.h, it's defined as:
DEFINE_FREE(kfree, void *, if (!IS_ERR_OR_NULL(_T)) kfree(_T))


Takashi