Browse Source

asoc: mbhc: add null check before accessing the pa_enable()

add null check before accessing the pa_enable fucn.

Change-Id: I5f86f8e6ea847b0f5e0eb69f531328e2358d7352
Signed-off-by: Prasad Kumpatla <[email protected]>
Prasad Kumpatla 2 years ago
parent
commit
4f81d6205e
1 changed files with 10 additions and 5 deletions
  1. 10 5
      asoc/codecs/wcd-mbhc-adc.c

+ 10 - 5
asoc/codecs/wcd-mbhc-adc.c

@@ -134,9 +134,12 @@ static int wcd_measure_adc_once(struct wcd_mbhc *mbhc, int mux_ctl)
 
 	if (mbhc->mbhc_cb->hph_pa_on_status) {
 		if (mbhc->mbhc_cb->hph_pa_on_status(mbhc->component)) {
-			mbhc->mbhc_cb->hph_pa_enable(mbhc->component, 0);
-			is_pa_on = true;
-			pr_debug("%s: pa is on before detection,so disable pa and read adc \n", __func__);
+			if (mbhc->mbhc_cb->hph_pa_enable) {
+				mbhc->mbhc_cb->hph_pa_enable(mbhc->component, 0);
+				is_pa_on = true;
+				pr_debug("%s: pa is on before detection,so disable pa and read adc \n",
+						 __func__);
+			}
 		}
 	}
 
@@ -189,8 +192,10 @@ static int wcd_measure_adc_once(struct wcd_mbhc *mbhc, int mux_ctl)
 	}
 
 	if (is_pa_on) {
-		mbhc->mbhc_cb->hph_pa_enable(mbhc->component, 1);
-		pr_debug("%s: restore pa \n", __func__);
+		if (mbhc->mbhc_cb->hph_pa_enable) {
+			mbhc->mbhc_cb->hph_pa_enable(mbhc->component, 1);
+			pr_debug("%s: restore pa \n", __func__);
+		}
 	}
 
 	pr_debug("%s: leave\n", __func__);