Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4644685iob; Sun, 8 May 2022 20:24:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyMBIbWLdxfcW4yF8yvSrAm8DsFsNlZB4WAed6JDyUyW73FPiHqX9PXSLPXzCJIYyeoQYqT X-Received: by 2002:a17:90b:1bce:b0:1dc:9a4e:bc66 with SMTP id oa14-20020a17090b1bce00b001dc9a4ebc66mr16076202pjb.70.1652066694355; Sun, 08 May 2022 20:24:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652066694; cv=none; d=google.com; s=arc-20160816; b=h31W3EI44QyjAMCTU9VAz5oBjLAB1ModSjAgoQEEsiZ2/3aMB1GACF6qfxE3VAg9+N Szx2IVb3FXbTNtbQCld2HjeDddnKwYB2qXL0FQJy66H9NNdWsa0RntsDZOK4ywNGdMjc ROC66nQPBYhp7SL4HaMNfKCTYBLHMdpkmjj6vnmqsS9Gisej87c+PVzZudm6pTULZPzg 10tADKFFSoCOM/hUB4PhBBMEu5iiER9tF1sXfY328dTGXDccN3CKgmNA8t/DyPEmlV93 AozKYObfpt9pZjIlYrHeCPmwpVoednArfhjOD/Njcaighi+ztKtqncfqpEsThk/sO9zb 0SzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=BGM4e8dlW2rnY5tjhs9oiiib3imBRnPsRxxY6qM+kZ4=; b=GiPf+pKdJffpSDwY+v8q7yD9GsplKLCBNtXHfKqCrLkkZrEUdlpn0pnuVzSs6Jyxq1 ccxlSqXOM+eDyc9uJVroKD52F5x4XCOBim1RfiQ8bEUeqGwYq460kC9RtJjJf29rFmBL XV4OFZLGAYDrwvWoDtrxq7Diunkgrf+oURdXotQgOlJ4H84KbHVgiSCl/sBEI1LBrmyh mVwcBFc7jTP6kc5el/qInO2cIz7HSj5/w5m3q8D+82GVEjVkMMcJNM+scQ4/D02DY1jB 0L/tkOBqOqDRyEBL/xXsbDDC1NEfKZ6opTHh0jYFStjS2Xn7QRvFyB0VD/JV8QQipqZ8 6wng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="Cv7nqR/t"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id u64-20020a638543000000b003ab971aeb0fsi12385223pgd.498.2022.05.08.20.24.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 May 2022 20:24:54 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="Cv7nqR/t"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 191099A9AF; Sun, 8 May 2022 20:24:45 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1444828AbiEFXBN (ORCPT + 99 others); Fri, 6 May 2022 19:01:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1444733AbiEFXBD (ORCPT ); Fri, 6 May 2022 19:01:03 -0400 Received: from mail-qv1-xf2c.google.com (mail-qv1-xf2c.google.com [IPv6:2607:f8b0:4864:20::f2c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D737C5C667; Fri, 6 May 2022 15:57:13 -0700 (PDT) Received: by mail-qv1-xf2c.google.com with SMTP id ke5so6428180qvb.5; Fri, 06 May 2022 15:57:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BGM4e8dlW2rnY5tjhs9oiiib3imBRnPsRxxY6qM+kZ4=; b=Cv7nqR/tLqVTBsytmAQLGkwrOSuyqjm9iJALV8wRpxzyMxwLGuvaxVOBblpzJdiQkr lCI6oDGbUiipN5u9wBh/WD5G3ZEVmbbk/NuaoAczXPucBVI/Q3/81679OvLoGosOn0Ms 6w+j96cFj08P6QyRK264+FYtPJZ+6b9HgAhOw5AJTysJudS+l1FZGCdcLUfxMCnCtVn0 OqDLaqgEFe189lgdb34G6dDmobZ0BtWgqv/HopPqRApa/OBc+bA2nM3l2JZfLkIqbPF5 tFQY+kx3Ji5mBO7mKOd1zNS+/3LeTKjkUSSA8r0bZA07+d0pM2JeJdOTA7gdXboJsey9 cAEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BGM4e8dlW2rnY5tjhs9oiiib3imBRnPsRxxY6qM+kZ4=; b=MT0k+aNYlV7xaH+nhxi7xIFGueJqZ1Z15E9cIE6XDVBr/imvdXp/klgGpEYwqj/1EP P1xPnl5BvUjf9hHtDtTA/fx41L3bojpZvOVZT01ixdifH8z5OgJUgYGiZZx09STGxbiZ H3FQXAiOwm6CNG0z+71/dcNnJ7cEVeuSQ2vc/54pQX33yKUC0d1Mv2EpYSQsLXxMPaIo HscahI9QmP1h4kqYn7jsR67t5+QShjPb2JWnRZ+hsEyWSCHrKlfiu8xZt0/K4b0fdgiY Jmb+TFWUSdRrCW5DdyigP67bju1odsVkvoJltXi9Xwf2IQP9DZPpqdnODPIu/0LuB2et y7Eg== X-Gm-Message-State: AOAM530Ag6u7nDR/jpX0/7TgvGRSSMgWBDR2Ad4E5MSxchL/vEWLShki fvmxgFPx9PNrsyAXbeWBJfU= X-Received: by 2002:a05:6214:b94:b0:456:38b2:2d76 with SMTP id fe20-20020a0562140b9400b0045638b22d76mr4403222qvb.70.1651877833036; Fri, 06 May 2022 15:57:13 -0700 (PDT) Received: from grrm.lan (bras-base-mtrlpq4809w-grc-17-70-53-205-21.dsl.bell.ca. [70.53.205.21]) by smtp.gmail.com with ESMTPSA id q188-20020a37a7c5000000b0069fc13ce208sm3187880qke.57.2022.05.06.15.57.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 May 2022 15:57:12 -0700 (PDT) From: Yannick Brosseau To: jic23@kernel.org, lars@metafoo.de, mcoquelin.stm32@gmail.com, alexandre.torgue@foss.st.com, fabrice.gasnier@foss.st.com, olivier.moysan@foss.st.com Cc: paul@crapouillou.net, linux-iio@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Yannick Brosseau Subject: [PATCH 2/2] iio: adc: stm32: Fix check for spurious IRQs on STM32F4 Date: Fri, 6 May 2022 18:56:17 -0400 Message-Id: <20220506225617.1774604-3-yannick.brosseau@gmail.com> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220506225617.1774604-1-yannick.brosseau@gmail.com> References: <20220506225617.1774604-1-yannick.brosseau@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The check for spurious IRQs introduced in 695e2f5c289bb assumed that the bits in the control and status registers are aligned. This is true for the H7 and MP1 version, but not the F4. Instead of comparing both registers bitwise, we check the bit in the status and control for each interrupt we are interested in. Signed-off-by: Yannick Brosseau --- drivers/iio/adc/stm32-adc.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/iio/adc/stm32-adc.c b/drivers/iio/adc/stm32-adc.c index a68ecbda6480..5b0f138333ee 100644 --- a/drivers/iio/adc/stm32-adc.c +++ b/drivers/iio/adc/stm32-adc.c @@ -1422,9 +1422,10 @@ static irqreturn_t stm32_adc_threaded_isr(int irq, void *data) return IRQ_HANDLED; } - if (!(status & mask)) + if(!((status & regs->isr_eoc.mask) && (mask & regs->ier_eoc.mask)) || + ((status & regs->isr_ovr.mask) && (mask & regs->ier_ovr.mask))) dev_err_ratelimited(&indio_dev->dev, - "Unexpected IRQ: IER=0x%08x, ISR=0x%08x\n", + "Unexpected IRQ: CR1/IER=0x%08x, SR/ISR=0x%08x\n", mask, status); return IRQ_NONE; @@ -1438,7 +1439,9 @@ static irqreturn_t stm32_adc_isr(int irq, void *data) u32 status = stm32_adc_readl(adc, regs->isr_eoc.reg); u32 mask = stm32_adc_readl(adc, regs->ier_eoc.reg); - if (!(status & mask)) + /* Check that we have the interrupt we care about are enabled and active */ + if(!((status & regs->isr_eoc.mask) && (mask & regs->ier_eoc.mask)) || + ((status & regs->isr_ovr.mask) && (mask & regs->ier_ovr.mask))) return IRQ_WAKE_THREAD; if (status & regs->isr_ovr.mask) { -- 2.36.0