[v3] ASoC: rt5645: Check if codec is initialized in workqueue handler
diff mbox

Message ID 1437017458-19476-1-git-send-email-drinkcat@chromium.org
State New
Headers show

Commit Message

Nicolas Boichat July 16, 2015, 3:30 a.m. UTC
rt5645_jack_detect_work needs rt5645->codec to be initialized to
setup dapm pins. Also, reporting jack events is useless, as the
jacks cannot be set before the codec is ready.

Since we manually call the interrupt handler in
rt5645_set_jack_detect, the initial jack state will be reported
correctly, and dapm pins will be setup at that time.

Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
 sound/soc/codecs/rt5645.c | 3 +++
 1 file changed, 3 insertions(+)

diff mbox

diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c
index 093a41d..ff75d04 100644
--- a/sound/soc/codecs/rt5645.c
+++ b/sound/soc/codecs/rt5645.c
@@ -2918,6 +2918,9 @@  static void rt5645_jack_detect_work(struct work_struct *work)
 		container_of(work, struct rt5645_priv, jack_detect_work.work);
 	int val, btn_type, gpio_state = 0, report = 0;
+	if (!rt5645->codec)
+		return;
 	switch (rt5645->pdata.jd_mode) {
 	case 0: /* Not using rt5645 JD */
 		if (rt5645->gpiod_hp_det) {