Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp681396pxb; Tue, 19 Oct 2021 10:42:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzqtOvj2SZ+JcnHkSKM5Spqjs/yDscmcEK2+DZE7iUhP5zwqD9GciPPAS8WQgGPC2UKFxVh X-Received: by 2002:a17:906:d8d5:: with SMTP id re21mr40274771ejb.110.1634665342090; Tue, 19 Oct 2021 10:42:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634665342; cv=none; d=google.com; s=arc-20160816; b=zz/SjTnTc8XtT9A+SCrSE9kpU0yBh5XFQ4tie8G52jA4Ifsnh/jbFFw3STwFVhkiGt snZ5+hiu/wnz2ToYWuJ8kzk1dMXqUTv5y0/sSZK11qlpQWaZSRh/oGR+JpT2yHA6IjpR J46MW2Gemqy1471ES8im0DSEjZbTsLFaZF6qaA1sQAfGusLC4oL67DYGOzhP6gkQ3irx AzBioto7gxaaiiaR+eFHfGfdDg62gIVlUv87poo065ddrWQTz1Fu6A7PUqvzyiAfbxOG DRlaoD4OUvQpiLXa3N1AhyYK8GW0yS+XcrZsHkYsbGcxnihkQP1DPsA3kiU/XWBO+8OY qHMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=MiPyXbMYpWJJ3rTJkZVJ6BJqWEHjkBzl9Pp7nbJABtg=; b=HTCN6er7C8/gDpoVnYb8VU7cfDEsrFffXahTxivfGfeQZqV49b133d7WaDgxu1czz0 R519P/o5W8yUTQfZUy0LTihd9PHC+ClyQ9oux1kSKk20UIlag6bxvDrxBeLw08uae549 I6NjLRxXW3VGUmRL9zr5qIDAt0wsOLyLvo9DMUCdcAQKEfRC6k+IBs7pHdMrOCQ9RxkC VXDmPEWyBkCPaGri9VVEcVkCKXL6VqF1cQMIH35QGNf3zVOzoofwoSYmrNyc7m7OkOct x9lI1e9G+jXODhHvlqh30mg6d1F90SJt2z2u02yFv8QbNqSG6qhtVULlHxXjKq8Omk/c bCKg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 13si24682440ejr.134.2021.10.19.10.41.58; Tue, 19 Oct 2021 10:42:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234770AbhJSRlU (ORCPT + 99 others); Tue, 19 Oct 2021 13:41:20 -0400 Received: from smtp03.smtpout.orange.fr ([80.12.242.125]:60295 "EHLO smtp.smtpout.orange.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234526AbhJSRlU (ORCPT ); Tue, 19 Oct 2021 13:41:20 -0400 Received: from [192.168.1.18] ([92.140.161.106]) by smtp.orange.fr with ESMTPA id ct4qmJ5v2PNphct4qm4mlQ; Tue, 19 Oct 2021 19:39:06 +0200 X-ME-Helo: [192.168.1.18] X-ME-Auth: YWZlNiIxYWMyZDliZWIzOTcwYTEyYzlhMmU3ZiQ1M2U2MzfzZDfyZTMxZTBkMTYyNDBjNDJlZmQ3ZQ== X-ME-Date: Tue, 19 Oct 2021 19:39:06 +0200 X-ME-IP: 92.140.161.106 Subject: Re: [PATCH] ASoC: codecs: Fix WCD_MBHC_HPH_PA_EN usage To: Srinivas Kandagatla , lgirdwood@gmail.com, broonie@kernel.org, perex@perex.cz, tiwai@suse.com, yang.lee@linux.alibaba.com Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org References: <988948f7f266aa00698704687537335b7e6a67b2.1634455711.git.christophe.jaillet@wanadoo.fr> <3ff34912-19e6-4d52-e9da-0e78ceb1d2ff@linaro.org> From: Christophe JAILLET Message-ID: Date: Tue, 19 Oct 2021 19:39:04 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <3ff34912-19e6-4d52-e9da-0e78ceb1d2ff@linaro.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le 19/10/2021 à 15:47, Srinivas Kandagatla a écrit : > > > On 17/10/2021 08:31, Christophe JAILLET wrote: >> 'hphpa_on' is known to be false, so the if block at the end of the >> function >> is dead code. > > Yes, this is a dead code we should remove it. Ok, thanks for the clarification. > > This code was part of moisture detection logic which is not enabled in > upstream code yet. If 'yet' is the important word of the sentence, maybe the best is to leave the code as-is. If you prefer it to be removed, I can send a patch if it helps. > > During Moisture detection if the PA is on then we switch it off and do > moisture measurements and at the end of the function we restore the > state of PA. > >> >> Turn it into a meaningful code by having 'hphpa_on' be static. Use is >> as a >> flip-flop variable. > > No, It does not. > > Have you even tested this patch in anyway? No, as said below the ---, the purpose of this patch was not to be correct (or tested). It was only to draw attention on odd things. CJ > >> >> Fixes: 0e5c9e7ff899 ("ASoC: codecs: wcd: add multi button Headset >> detection support") >> Signed-off-by: Christophe JAILLET >> --- >> The purpose of this patch is not to be correct (!) but to draw attention >> on several points: >>     - in 'wcd_mbhc_adc_hs_rem_irq()', the "if (hphpa_on)" path is dead >> code >>       because 'hphpa_on' is known to be false >>     - What is this magic number '3'? >>       All 'wcd_mbhc_read_field()' look for 0 or non-0 >>     - a 'mutex_[un]lock()' in an IRQ handler looks spurious to me >> >> Instead of this (likely broken) patch, it is likely that something is >> missing elsewhere. Maybe in 'wcd_mbhc_adc_hs_ins_irq()'. >> I also guess that 'hphpa_on' should be read for somewhere else. >> --- >>   sound/soc/codecs/wcd-mbhc-v2.c | 5 ++++- >>   1 file changed, 4 insertions(+), 1 deletion(-) >> >> diff --git a/sound/soc/codecs/wcd-mbhc-v2.c >> b/sound/soc/codecs/wcd-mbhc-v2.c >> index 405128ccb4b0..783d8c35bc1b 100644 >> --- a/sound/soc/codecs/wcd-mbhc-v2.c >> +++ b/sound/soc/codecs/wcd-mbhc-v2.c >> @@ -1176,7 +1176,7 @@ 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; >> +    static bool hphpa_on = false; >>       mutex_lock(&mbhc->lock); >>       timeout = jiffies + >> msecs_to_jiffies(WCD_FAKE_REMOVAL_MIN_PERIOD_MS); >> @@ -1212,6 +1212,9 @@ static irqreturn_t wcd_mbhc_adc_hs_rem_irq(int >> irq, void *data) >>       if (hphpa_on) { >>           hphpa_on = false; >> +        wcd_mbhc_write_field(mbhc, WCD_MBHC_HPH_PA_EN, 0); >> +    } else { >> +        hphpa_on = true; >>           wcd_mbhc_write_field(mbhc, WCD_MBHC_HPH_PA_EN, 3); > > Just remove this dead code. > > --srini >>       } >>   exit: >> >