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

greybus: audio: Avoid reporting spurious button events

Now jack-button are registered to snd framework based on capabilities
populated by codec module's topology data. Thus, valid ids for button
events can also vary for different modules. This patch modifies existing
button reporting mechanism to avoid reporting spurious button events for
invalid button ids.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>

authored by

Vaibhav Agarwal and committed by
Greg Kroah-Hartman
6a57ddc9 cec89df4

+8 -5
+8 -5
drivers/staging/greybus/audio_module.c
··· 92 92 } 93 93 94 94 report = module->button_status & module->button_mask; 95 + soc_button_id = 0; 95 96 96 97 switch (req->button_id) { 97 98 case 1: 98 - soc_button_id = SND_JACK_BTN_0; 99 + soc_button_id = SND_JACK_BTN_0 & module->button_mask; 99 100 break; 100 101 101 102 case 2: 102 - soc_button_id = SND_JACK_BTN_1; 103 + soc_button_id = SND_JACK_BTN_1 & module->button_mask; 103 104 break; 104 105 105 106 case 3: 106 - soc_button_id = SND_JACK_BTN_2; 107 + soc_button_id = SND_JACK_BTN_2 & module->button_mask; 107 108 break; 108 109 109 110 case 4: 110 - soc_button_id = SND_JACK_BTN_3; 111 + soc_button_id = SND_JACK_BTN_3 & module->button_mask; 111 112 break; 112 - default: 113 + } 114 + 115 + if (!soc_button_id) { 113 116 dev_err_ratelimited(module->dev, 114 117 "Invalid button request received\n"); 115 118 return -EINVAL;