Skip to content

Commit 98b5427

Browse files
Cryolitiatiwai
authored andcommitted
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>
1 parent ffd5861 commit 98b5427

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

sound/usb/card.c

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,32 @@ module_param_array(delayed_register, charp, NULL, 0444);
103103
MODULE_PARM_DESC(delayed_register, "Quirk for delayed registration, given by id:iface, e.g. 0123abcd:4.");
104104
module_param_array(implicit_fb, bool, NULL, 0444);
105105
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.");
108106
module_param_named(use_vmalloc, snd_usb_use_vmalloc, bool, 0444);
109107
MODULE_PARM_DESC(use_vmalloc, "Use vmalloc for PCM intermediate buffers (default: yes).");
110108
module_param_named(skip_validation, snd_usb_skip_validation, bool, 0444);
111109
MODULE_PARM_DESC(skip_validation, "Skip unit descriptor validation (default: no).");
112110

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");
131+
113132
/*
114133
* we keep the snd_usb_audio_t instances by ourselves for merging
115134
* the all interfaces on the same card as one sound device.
@@ -696,6 +715,8 @@ static void snd_usb_init_quirk_flags(int idx, struct snd_usb_audio *chip)
696715
{
697716
size_t i;
698717

718+
guard(mutex)(&quirk_flags_mutex);
719+
699720
/* old style option found: the position-based integer value */
700721
if (quirk_flags[idx] &&
701722
!kstrtou32(quirk_flags[idx], 0, &chip->quirk_flags)) {

0 commit comments

Comments
 (0)