Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b83f8c4c authored by Vatsal Bucha's avatar Vatsal Bucha Committed by Gerrit - the friendly Code Review server
Browse files

ASoC: wcd-mbhc: Check if mutex is locked before mutex destroy



Mutex destroy is called as part of wcd_mbhc_deinit during SSR
for hph pa lock when lock is taken resulting in warning. Check
if mutex is locked and unlock mutex before destroy so as to
remove warning.

Change-Id: I521903f9ab24222278d6fb3f349da18c98131c60
Signed-off-by: default avatarVatsal Bucha <vbucha@codeaurora.org>
parent fc2cd3b0
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/* Copyright (c) 2015-2020, The Linux Foundation. All rights reserved.
/* Copyright (c) 2015-2021, The Linux Foundation. All rights reserved.
 */
#include <linux/module.h>
#include <linux/init.h>
@@ -328,6 +328,7 @@ static int wcd_event_notify(struct notifier_block *self, unsigned long val,
		else
			/* Disable micbias, pullup & enable cs */
			wcd_enable_curr_micbias(mbhc, WCD_MBHC_EN_CS);
		if (mutex_is_locked(&mbhc->hphl_pa_lock))
			mutex_unlock(&mbhc->hphl_pa_lock);
		clear_bit(WCD_MBHC_ANC0_OFF_ACK, &mbhc->hph_anc_state);
		break;
@@ -348,6 +349,7 @@ static int wcd_event_notify(struct notifier_block *self, unsigned long val,
		else
			/* Disable micbias, pullup & enable cs */
			wcd_enable_curr_micbias(mbhc, WCD_MBHC_EN_CS);
		if (mutex_is_locked(&mbhc->hphr_pa_lock))
			mutex_unlock(&mbhc->hphr_pa_lock);
		clear_bit(WCD_MBHC_ANC1_OFF_ACK, &mbhc->hph_anc_state);
		break;
@@ -2067,6 +2069,10 @@ void wcd_mbhc_deinit(struct wcd_mbhc *mbhc)
		WCD_MBHC_RSC_UNLOCK(mbhc);
	}
	mutex_destroy(&mbhc->codec_resource_lock);
	if (mutex_is_locked(&mbhc->hphl_pa_lock))
		mutex_unlock(&mbhc->hphl_pa_lock);
	if (mutex_is_locked(&mbhc->hphr_pa_lock))
		mutex_unlock(&mbhc->hphr_pa_lock);
	mutex_destroy(&mbhc->hphl_pa_lock);
	mutex_destroy(&mbhc->hphr_pa_lock);
}