From 01afb3998739e34061c4512173e125d98a8778cd Mon Sep 17 00:00:00 2001 From: Cosmin-Gabriel Samoila Date: Tue, 13 Nov 2018 14:34:36 +0200 Subject: [PATCH] MLK-20308 sound:asoc: fix re-enablement bug When hwvad is enabled, if you try to re-enable it again, it should fail. However, we were also double setting state to OFF on fail, which is wrong because it resets the state and allows the second retry to enable even if it wasn't disabled before. Now we only return EBUSY. Reviewed-by: Daniel Baluta Signed-off-by: Cosmin-Gabriel Samoila (cherry picked from commit 1ef8c4696c0b0c1e4a0f384dd7300d4dab293f3b) --- sound/soc/fsl/fsl_micfil.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/sound/soc/fsl/fsl_micfil.c b/sound/soc/fsl/fsl_micfil.c index 18f97d974362..a61c4d680643 100644 --- a/sound/soc/fsl/fsl_micfil.c +++ b/sound/soc/fsl/fsl_micfil.c @@ -1998,7 +1998,7 @@ static int enable_hwvad(struct device *dev, bool sync) */ if (sync && state == MICFIL_HWVAD_ON) { dev_err(dev, "hwvad already on\n"); - ret = -EINVAL; + ret = -EBUSY; goto enable_error; } @@ -2139,10 +2139,8 @@ static ssize_t micfil_hwvad_handler(struct kobject *kobj, if (vad_channel <= 7) { micfil->vad_channel = vad_channel; ret = enable_hwvad(dev, true); - if (ret) { + if (ret) dev_err(dev, "Failed to enable hwvad"); - atomic_set(&micfil->hwvad_state, MICFIL_HWVAD_OFF); - } } else { micfil->vad_channel = -1; ret = disable_hwvad(dev, true); -- 2.17.1