]> git.hungrycats.org Git - linux/commitdiff
ASoC: nau8821: Cancel pending work before suspend
authorCristian Ciocaltea <cristian.ciocaltea@collabora.com>
Wed, 31 Dec 2025 20:04:17 +0000 (22:04 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 2 Sep 2026 12:31:47 +0000 (14:31 +0200)
[ Upstream commit 7786b10688ac0ebeaff655923cbb2c7d34a98995 ]

A jack detection work that is unscheduled or in progress while executing
the suspend handler could trigger a race condition.

Ensure state consistency by cancelling any pending work or wait for its
execution to complete before processing the suspend.  Since driver
(re)enables both insert and eject interrupts on resume, there is no risk
to miss the related jack events.  Therefore, flush_delayed_work() is not
required here.

Fixes: aab1ad11d69f ("ASoC: nau8821: new driver")
Fixes: ee70bacef1c6 ("ASoC: nau8821: Avoid unnecessary blocking in IRQ handler")
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
Link: https://patch.msgid.link/20251231-nau8821-cleanup-v1-3-6b0b76cbbb64@collabora.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
sound/soc/codecs/nau8821.c

index 8228cd396b9b327fbb5bc9b5df83a763ac925aa1..53a38eb4eb0e129f9a44cec5c4d29463e596f66e 100644 (file)
@@ -1611,6 +1611,10 @@ static int __maybe_unused nau8821_suspend(struct snd_soc_component *component)
 
        if (nau8821->irq)
                disable_irq(nau8821->irq);
+
+       if (nau8821->jdet_active)
+               cancel_delayed_work_sync(&nau8821->jdet_work);
+
        snd_soc_component_force_bias_level(component, SND_SOC_BIAS_OFF);
        /* Power down codec power; don't support button wakeup */
        snd_soc_component_disable_pin(component, "MICBIAS");