Skip to content

Commit 6e54919

Browse files
cristiccbroonie
authored andcommitted
ASoC: nau8821: Cancel jdet_work before handling jack ejection
The microphone detection work scheduled by a prior jack insertion interrupt may still be in a pending state or under execution when a jack ejection interrupt has been fired. This might lead to a racing condition or nau8821_jdet_work() completing after nau8821_eject_jack(), which will override the currently disconnected state of the jack and incorrectly report the headphone or the headset as being connected. Cancel any pending jdet_work or wait for its execution to finish before attempting to handle the ejection interrupt. Proceed similarly before launching the eject handler as a consequence of detecting an invalid insert interrupt. Fixes: aab1ad1 ("ASoC: nau8821: new driver") Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com> Link: https://patch.msgid.link/20251003-nau8821-jdet-fixes-v1-1-f7b0e2543f09@collabora.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 3a86608 commit 6e54919

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

sound/soc/codecs/nau8821.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1185,6 +1185,7 @@ static irqreturn_t nau8821_interrupt(int irq, void *data)
11851185

11861186
if ((active_irq & NAU8821_JACK_EJECT_IRQ_MASK) ==
11871187
NAU8821_JACK_EJECT_DETECTED) {
1188+
cancel_work_sync(&nau8821->jdet_work);
11881189
regmap_update_bits(regmap, NAU8821_R71_ANALOG_ADC_1,
11891190
NAU8821_MICDET_MASK, NAU8821_MICDET_DIS);
11901191
nau8821_eject_jack(nau8821);
@@ -1199,11 +1200,11 @@ static irqreturn_t nau8821_interrupt(int irq, void *data)
11991200
clear_irq = NAU8821_KEY_RELEASE_IRQ;
12001201
} else if ((active_irq & NAU8821_JACK_INSERT_IRQ_MASK) ==
12011202
NAU8821_JACK_INSERT_DETECTED) {
1203+
cancel_work_sync(&nau8821->jdet_work);
12021204
regmap_update_bits(regmap, NAU8821_R71_ANALOG_ADC_1,
12031205
NAU8821_MICDET_MASK, NAU8821_MICDET_EN);
12041206
if (nau8821_is_jack_inserted(regmap)) {
12051207
/* detect microphone and jack type */
1206-
cancel_work_sync(&nau8821->jdet_work);
12071208
schedule_work(&nau8821->jdet_work);
12081209
/* Turn off insertion interruption at manual mode */
12091210
regmap_update_bits(regmap,

0 commit comments

Comments
 (0)