Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ALSA: usb-audio: make param quirk_flags change-able in runtime

Change its permision from 0644 to 0444, and add runtime processing.

Developers now can change it during sysfs, without rebooting, for
debugging new buggy devices.

Co-developed-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Cryolitia PukNgae <cryolitia@uniontech.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>

authored by

Cryolitia PukNgae and committed by
Takashi Iwai
98b5427b ffd58612

+23 -2
+23 -2
sound/usb/card.c
··· 103 103 MODULE_PARM_DESC(delayed_register, "Quirk for delayed registration, given by id:iface, e.g. 0123abcd:4."); 104 104 module_param_array(implicit_fb, bool, NULL, 0444); 105 105 MODULE_PARM_DESC(implicit_fb, "Apply generic implicit feedback sync mode."); 106 - module_param_array(quirk_flags, charp, NULL, 0444); 107 - MODULE_PARM_DESC(quirk_flags, "Driver quirk bit flags."); 108 106 module_param_named(use_vmalloc, snd_usb_use_vmalloc, bool, 0444); 109 107 MODULE_PARM_DESC(use_vmalloc, "Use vmalloc for PCM intermediate buffers (default: yes)."); 110 108 module_param_named(skip_validation, snd_usb_skip_validation, bool, 0444); 111 109 MODULE_PARM_DESC(skip_validation, "Skip unit descriptor validation (default: no)."); 110 + 111 + /* protects quirk_flags */ 112 + static DEFINE_MUTEX(quirk_flags_mutex); 113 + 114 + static int param_set_quirkp(const char *val, 115 + const struct kernel_param *kp) 116 + { 117 + guard(mutex)(&quirk_flags_mutex); 118 + return param_set_charp(val, kp); 119 + } 120 + 121 + static const struct kernel_param_ops param_ops_quirkp = { 122 + .set = param_set_quirkp, 123 + .get = param_get_charp, 124 + .free = param_free_charp, 125 + }; 126 + 127 + #define param_check_quirkp param_check_charp 128 + 129 + module_param_array(quirk_flags, quirkp, NULL, 0644); 130 + MODULE_PARM_DESC(quirk_flags, "Add/modify USB audio quirks"); 112 131 113 132 /* 114 133 * we keep the snd_usb_audio_t instances by ourselves for merging ··· 714 695 static void snd_usb_init_quirk_flags(int idx, struct snd_usb_audio *chip) 715 696 { 716 697 size_t i; 698 + 699 + guard(mutex)(&quirk_flags_mutex); 717 700 718 701 /* old style option found: the position-based integer value */ 719 702 if (quirk_flags[idx] &&