diff options
author | Vaibhav Agarwal <vaibhav.agarwal@linaro.org> | 2016-09-01 11:38:42 +0530 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@google.com> | 2016-09-02 14:13:39 +0200 |
commit | 6a57ddc97acb2a1d37ce94a237dc0fab2e5a3f5b (patch) | |
tree | af00489278feb104a7df3942716f8dee3448fbfb /drivers/staging/greybus/audio_module.c | |
parent | cec89df44692fa8cff2a52542b11878ee49b0d69 (diff) |
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>
Diffstat (limited to 'drivers/staging/greybus/audio_module.c')
-rw-r--r-- | drivers/staging/greybus/audio_module.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/drivers/staging/greybus/audio_module.c b/drivers/staging/greybus/audio_module.c index d3284ab1dacf..411735df2bb4 100644 --- a/drivers/staging/greybus/audio_module.c +++ b/drivers/staging/greybus/audio_module.c @@ -92,24 +92,27 @@ static int gbaudio_request_button(struct gbaudio_module_info *module, } report = module->button_status & module->button_mask; + soc_button_id = 0; switch (req->button_id) { case 1: - soc_button_id = SND_JACK_BTN_0; + soc_button_id = SND_JACK_BTN_0 & module->button_mask; break; case 2: - soc_button_id = SND_JACK_BTN_1; + soc_button_id = SND_JACK_BTN_1 & module->button_mask; break; case 3: - soc_button_id = SND_JACK_BTN_2; + soc_button_id = SND_JACK_BTN_2 & module->button_mask; break; case 4: - soc_button_id = SND_JACK_BTN_3; + soc_button_id = SND_JACK_BTN_3 & module->button_mask; break; - default: + } + + if (!soc_button_id) { dev_err_ratelimited(module->dev, "Invalid button request received\n"); return -EINVAL; |