From 4f81d6205e1efe6cd79e74b6a3d56855485fea5c Mon Sep 17 00:00:00 2001 From: Prasad Kumpatla Date: Tue, 23 Aug 2022 16:15:39 +0530 Subject: [PATCH] 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 --- asoc/codecs/wcd-mbhc-adc.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/asoc/codecs/wcd-mbhc-adc.c b/asoc/codecs/wcd-mbhc-adc.c index bf2418058a..9691074e04 100644 --- a/asoc/codecs/wcd-mbhc-adc.c +++ b/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__);