Skip to content

Commit 777d32a

Browse files
chadmedjannau
authored andcommitted
ASoC: cs42l84: rearrange tip sense interrupt handler
Check and set the plug state only once so that we can guard the entire handler. This allows us to more easily add ring sense interrupt handling. Signed-off-by: James Calligeros <jcalligeros99@gmail.com>
1 parent 42f990b commit 777d32a

1 file changed

Lines changed: 9 additions & 16 deletions

File tree

sound/soc/codecs/cs42l84.c

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -834,10 +834,10 @@ static irqreturn_t cs42l84_irq_thread(int irq, void *data)
834834
(CS42L84_TS_PLUG | CS42L84_TS_UNPLUG)) >>
835835
CS42L84_TS_PLUG_SHIFT;
836836

837-
switch (current_plug_status) {
838-
case CS42L84_PLUG:
839-
if (cs42l84->plug_state != CS42L84_PLUG) {
840-
cs42l84->plug_state = CS42L84_PLUG;
837+
if (current_plug_status != cs42l84->plug_state) {
838+
cs42l84->plug_state = current_plug_status;
839+
switch (current_plug_status) {
840+
case CS42L84_PLUG:
841841
dev_dbg(cs42l84->dev, "Plug event\n");
842842

843843
cs42l84_detect_hs(cs42l84);
@@ -858,26 +858,19 @@ static irqreturn_t cs42l84_irq_thread(int irq, void *data)
858858
cs42l84->plug_state = CS42L84_UNPLUG;
859859
cs42l84_revert_hs(cs42l84);
860860
}
861-
}
862-
break;
863-
864-
case CS42L84_UNPLUG:
865-
if (cs42l84->plug_state != CS42L84_UNPLUG) {
866-
cs42l84->plug_state = CS42L84_UNPLUG;
861+
break;
862+
case CS42L84_UNPLUG:
867863
dev_dbg(cs42l84->dev, "Unplug event\n");
868864

869865
cs42l84_revert_hs(cs42l84);
870866
cs42l84->hs_type = 0;
871867
snd_soc_jack_report(cs42l84->jack, 0,
872868
SND_JACK_HEADSET);
869+
break;
870+
default:
871+
break;
873872
}
874-
break;
875-
876-
default:
877-
if (cs42l84->plug_state != CS42L84_TRANS)
878-
cs42l84->plug_state = CS42L84_TRANS;
879873
}
880-
}
881874
mutex_unlock(&cs42l84->irq_lock);
882875

883876
return IRQ_HANDLED;

0 commit comments

Comments
 (0)