ASoC: es8316: fix null pointer error
authorzhangjun <zhangjun@rock-chips.com>
Mon, 19 Dec 2016 12:49:46 +0000 (20:49 +0800)
committerHuang, Tao <huangtao@rock-chips.com>
Wed, 21 Dec 2016 09:57:37 +0000 (17:57 +0800)
due to function will be called from rk_headset_irq_hook_adc.c
when es8316 configured in defconfig file but not in device tree

Change-Id: Ie0294fff2c05b9f77c6740d81dc9445007c1b62b
Signed-off-by: zhangjun <zhangjun@rock-chips.com>
sound/soc/codecs/es8316.c

index 06d39fc9e6b995ddc6e8bb750b021398e2a9e8d4..86d0eea444c5e95c9ecdd09e732756674f8df486 100644 (file)
@@ -1003,7 +1003,12 @@ static irqreturn_t es8316_irq_handler(int irq, void *data)
  */
 int es8316_headset_detect(int jack_insert)
 {
-       struct es8316_priv *es8316 = snd_soc_codec_get_drvdata(es8316_codec);
+       struct es8316_priv *es8316;
+
+       if (!es8316_codec)
+               return -1;
+
+       es8316 = snd_soc_codec_get_drvdata(es8316_codec);
 
        es8316->hp_inserted = jack_insert;