On Thu, 18 Sep 2025 11:24:32 +0200, Cryolitia PukNgae via B4 Relay wrote: > > From: Cryolitia PukNgae <cryoli...@uniontech.com> > > For apply and unapply quirk flags more flexibly though param > > Co-developed-by: Takashi Iwai <ti...@suse.de> > Signed-off-by: Cryolitia PukNgae <cryoli...@uniontech.com> > --- > sound/usb/card.c | 9 ++-- > sound/usb/quirks.c | 119 > ++++++++++++++++++++++++++++++++++++++++++++++++++- > sound/usb/quirks.h | 3 +- > sound/usb/usbaudio.h | 3 ++ > 4 files changed, 126 insertions(+), 8 deletions(-) > > diff --git a/sound/usb/card.c b/sound/usb/card.c > index > 0265206a8e8cf31133e8463c98fe0497d8ace89e..5837677effa1787ef9d7d02714c3ae43b1a8bc79 > 100644 > --- a/sound/usb/card.c > +++ b/sound/usb/card.c > @@ -73,8 +73,8 @@ static bool lowlatency = true; > static char *quirk_alias[SNDRV_CARDS]; > static char *delayed_register[SNDRV_CARDS]; > static bool implicit_fb[SNDRV_CARDS]; > -static unsigned int quirk_flags[SNDRV_CARDS]; > > +char *quirk_flags[SNDRV_CARDS];
My preference is to keep this static, but pass the string value to a function. That is, define snd_usb_init_quirk_flags() in main.c: static void snd_usb_init_quirk_flags(struct snd_usb_audio *chip, int indx) { /* old style option found: the position-based integer value */ if (quirk_flags[idx] && !kstrtou32(quirk_flags[idx], 0, &chip->quirk_flags)) { usb_audio_dbg(chip, "Set quirk flags 0x%x from param based on position %d for device %04x:%04x\n", chip->quirk_flags, idx, USB_ID_VENDOR(chip->usb_id), USB_ID_PRODUCT(chip->usb_id)); return; } /* take the default quirk from the quirk table */ snd_usb_init_quirk_flags_table(chip); /* add or correct quirk bits from options */ for (i = 0; i < ARRAY_SIZE(quirk_flags); i++) { char *val __free(kfree) = NULL; if (!quirk_flags[i] || !*quirk_flags[i]) continue; val = kstrdup(quirk_flags[i], GFP_KERNEL); if (!val) return; snd_usb_parse_quirk_string(chip, val); } } static int snd_usb_audio_create(....) { .... snd_usb_init_quirk_flags(chip, idx); .... } The function snd_usb_parse_quirk_string() is defined in quirks.c, void snd_usb_parse_quirk_string(struct snd_usb_audio *chip, char *val) { for (p = val; p && *p;) { /* Each entry consists of VID:PID:flags */ field = strsep(&p, ":"); if (!field) break; ..... } } thanks, Takashi