[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <139e6867-2d29-09e0-d059-399917e5962d@linux.intel.com>
Date: Mon, 2 Aug 2021 19:03:19 -0500
From: Pierre-Louis Bossart <pierre-louis.bossart@...ux.intel.com>
To: Srinivas Kandagatla <srinivas.kandagatla@...aro.org>,
broonie@...nel.org
Cc: robh@...nel.org, alsa-devel@...a-project.org,
devicetree@...r.kernel.org, linux-kernel@...r.kernel.org,
lgirdwood@...il.com
Subject: Re: [PATCH v3 2/4] ASoC: codecs: wcd: add multi button Headset
detection support
Hi Srinivas,
cppcheck reports an issue with the use of 'hphpa_on' below
> +static irqreturn_t wcd_mbhc_adc_hs_rem_irq(int irq, void *data)
> +{
> + struct wcd_mbhc *mbhc = data;
> + unsigned long timeout;
> + int adc_threshold, output_mv, retry = 0;
> + bool hphpa_on = false;
assigned here
> +
> + mutex_lock(&mbhc->lock);
> + timeout = jiffies + msecs_to_jiffies(WCD_FAKE_REMOVAL_MIN_PERIOD_MS);
> + adc_threshold = wcd_mbhc_adc_get_hs_thres(mbhc);
> +
> + do {
> + retry++;
> + /*
> + * read output_mv every 10ms to look for
> + * any change in IN2_P
> + */
> + usleep_range(10000, 10100);
> + output_mv = wcd_measure_adc_once(mbhc, MUX_CTL_IN2P);
> +
> + /* Check for fake removal */
> + if ((output_mv <= adc_threshold) && retry > FAKE_REM_RETRY_ATTEMPTS)
> + goto exit;
> + } while (!time_after(jiffies, timeout));
> +
> + /*
> + * ADC COMPLETE and ELEC_REM interrupts are both enabled for
> + * HEADPHONE, need to reject the ADC COMPLETE interrupt which
> + * follows ELEC_REM one when HEADPHONE is removed.
> + */
> + if (mbhc->current_plug == MBHC_PLUG_TYPE_HEADPHONE)
> + mbhc->extn_cable_hph_rem = true;
> +
> + wcd_mbhc_write_field(mbhc, WCD_MBHC_DETECTION_DONE, 0);
> + wcd_mbhc_write_field(mbhc, WCD_MBHC_ADC_MODE, 0);
> + wcd_mbhc_write_field(mbhc, WCD_MBHC_ADC_EN, 0);
> + wcd_mbhc_elec_hs_report_unplug(mbhc);
> + wcd_mbhc_write_field(mbhc, WCD_MBHC_BTN_ISRC_CTL, 0);
not used, so hphpa_on == false
> + if (hphpa_on) {
> + hphpa_on = false;
> + wcd_mbhc_write_field(mbhc, WCD_MBHC_HPH_PA_EN, 3);
> + }
And this branch is never taken.
Is there a missing hphpa = true assignment somewhere?
There's an additional issue while I am at it:
sound/soc/codecs/wcd-mbhc-v2.c:1225:17: style: Variable 'clamp_state' is
assigned a value that is never used. [unreadVariable]
u8 clamp_state = 0;
^
-Pierre
Powered by blists - more mailing lists