From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AA785C433FE for ; Wed, 23 Nov 2022 14:54:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: In-Reply-To:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Reply-To:Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date :Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=lBSberIa0AOl+jPtm2ooE4fFIHzzaGJ8r3XWJ1/rVjw=; b=NR27Lsc7Jthy1owY5r45V+OPdj 8Qr+xnEWHTcBQEN3GHmoj2GyvD2A9VowsYwGUV2EuprbM2odN8UqvP3mSJJQPaAlAYcnHUiZ1P8uW 6gHl2KjR57gwOEho8j3VnXu9RNcZOEuVHKTm+8UP9QwiIFNAlhZ4SzSANc1O8wHPADFOrmiZjPjRD JjjiBNXml/EvEXKqdzEZOfr5sAj4LsNxtxJnZDSAdKdUS+lB3DCm1BkH2uUE0rnm1pgfQSRxYF3kr dkU1hbObgTN8djVD1OoA3pdZioyxPbYbK4+1rVFVV2pl4jUVGFI+kROYDfGrsU7/PjcE2YO9MgFql HkuAwB8w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oxr71-000D3x-KK; Wed, 23 Nov 2022 14:52:31 +0000 Received: from mail-qk1-x72b.google.com ([2607:f8b0:4864:20::72b]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oxr6d-000Ctw-83 for linux-arm-kernel@lists.infradead.org; Wed, 23 Nov 2022 14:52:08 +0000 Received: by mail-qk1-x72b.google.com with SMTP id v8so12534095qkg.12 for ; Wed, 23 Nov 2022 06:52:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=knbxmQVIOU2Pd66Dq2acA052ZEHkRF2txPVugpmQJls=; b=vgoCKFZRKLg5X6KRRSHGgXpYEh2IpY5j6Jj0EMht5qtQ5vVTuqIdbNTURoY0AF/5w3 UG4cMxe7+vdo7xqYJkf0wioum7PckU4FwTl2NM4DiiKgXdx7FnMC4v9HUQFX5HhpeP4f ioRAEFIoHR95thd4TYiEIm3w41NCD3rn69jUjdDuL3QUc6WPJ+TMpVp1CfAHmLz6tkbw jTKsJ8BYK53PPoLsQEtvfiR6S+b4KvrxJufS3BUv8ynKpLJd/r197eXTqmcNp2mSHqLw 8kZrNl4pn4Q96xALlgZmACcrrISzshdRfuyDoktiEl/wr6ZepBXVza/Dl0sywh0Ofvtx 178A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=knbxmQVIOU2Pd66Dq2acA052ZEHkRF2txPVugpmQJls=; b=GdYDsoO5yxSc5pzlwdxSQUXACWCW8KYVShjvZt2GiHGJVoyp6607oUl6XPbh2TfZxR fx+EG/K9Ts35oxS3RY/vv7j4CnTCNGXVgk4R7aExzWkqXg4KUmhBTFihlPOLZoXY5Fwz fWGEsPWr4wkW4LgLyoe3v3EGk10yY73VK9z2NhK0v/OdBh1jVDOy5LB7B01ccHvh7qgI O6HkRnsn2E17cUFpR7iKiXl2D4O2CbNhZHvY3oE5p7LVuB0P9Qe6vxTrCCX0I8z0UNdO gUSE3nMpiG4dLqdy07UPTdi/ixGDIkOFUT644OxhQGEH7Xx1FHohiZbkarEf+PudbaFh entg== X-Gm-Message-State: ANoB5pmfhw+ENEO9c5vx7JSoxDYcwJeaLfXVWPSxVb7pH+CtPSh+QYwK UoQAe33yF+WtU4rCxnLyYvep9w== X-Google-Smtp-Source: AA0mqf50nMaGK0F/5gySpgXWH3AhQK7OFs7Gu6ckRt9Fe7BUaW8hnqeaWOrFbDNOi68j5pTlArM48Q== X-Received: by 2002:a37:2f44:0:b0:6fa:fc92:13fd with SMTP id v65-20020a372f44000000b006fafc9213fdmr25224598qkh.183.1669215123957; Wed, 23 Nov 2022 06:52:03 -0800 (PST) Received: from fedora (69-109-179-158.lightspeed.dybhfl.sbcglobal.net. [69.109.179.158]) by smtp.gmail.com with ESMTPSA id i11-20020a05620a248b00b006fb3884e10bsm12520572qkn.24.2022.11.23.06.52.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Nov 2022 06:52:03 -0800 (PST) Date: Tue, 22 Nov 2022 02:33:52 -0500 From: William Breathitt Gray To: Fabrice Gasnier Cc: jic23@kernel.org, alexandre.torgue@foss.st.com, olivier.moysan@foss.st.com, linux-iio@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] counter: stm32-lptimer-cnt: fix the check on arr and cmp registers update Message-ID: References: <20221123133609.465614-1-fabrice.gasnier@foss.st.com> MIME-Version: 1.0 In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221123_065207_352311_462BEDFB X-CRM114-Status: GOOD ( 25.47 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: multipart/mixed; boundary="===============4061624358442463417==" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org --===============4061624358442463417== Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="pzBUpj5aqWF9hSSN" Content-Disposition: inline --pzBUpj5aqWF9hSSN Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Nov 22, 2022 at 02:27:50AM -0500, William Breathitt Gray wrote: > On Wed, Nov 23, 2022 at 02:36:09PM +0100, Fabrice Gasnier wrote: > > The ARR (auto reload register) and CMP (compare) registers are > > successively written. The status bits to check the update of these > > registers are polled together with regmap_read_poll_timeout(). > > The condition to end the loop may become true, even if one of the regis= ter > > isn't correctly updated. > > So ensure both status bits are set before clearing them. > >=20 > > Fixes: d8958824cf07 ("iio: counter: Add support for STM32 LPTimer") > > Signed-off-by: Fabrice Gasnier > > --- > > drivers/counter/stm32-lptimer-cnt.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > >=20 > > diff --git a/drivers/counter/stm32-lptimer-cnt.c b/drivers/counter/stm3= 2-lptimer-cnt.c > > index d6b80b6dfc28..8439755559b2 100644 > > --- a/drivers/counter/stm32-lptimer-cnt.c > > +++ b/drivers/counter/stm32-lptimer-cnt.c > > @@ -69,7 +69,7 @@ static int stm32_lptim_set_enable_state(struct stm32_= lptim_cnt *priv, > > =20 > > /* ensure CMP & ARR registers are properly written */ > > ret =3D regmap_read_poll_timeout(priv->regmap, STM32_LPTIM_ISR, val, > > - (val & STM32_LPTIM_CMPOK_ARROK), > > + (val & STM32_LPTIM_CMPOK_ARROK) =3D=3D STM32_LPTIM_CMPOK_AR= ROK, >=20 > This is a reasonable fix, but I don't like seeing so much happening in > an argument list -- it's easy to misunderstand what's going on which can > lead to further bugs the future. Pull out this condition to a dedicated > bool variable with a comment explaining why we need the equivalence > check (i.e. to ensure both status bits are set and not just one). >=20 > William Breathitt Gray Alternatively, you could pull out just (val & STM32_LPTIM_CMPOK_ARROK) to a separate variable and keep the equivalence condition inline if you think it'll be clearer that way. William Breathitt Gray --pzBUpj5aqWF9hSSN Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEARYKAB0WIQSNN83d4NIlKPjon7a1SFbKvhIjKwUCY3x7YAAKCRC1SFbKvhIj K9w1AP98ZG3DrAmGPMHuLe6esFEn0tC6ND7mWOexsyUahUYdawD/R2NVJxw+1mLI RQk8aAe4SpweKg5EY0hASmH+yqpo4A0= =2pWS -----END PGP SIGNATURE----- --pzBUpj5aqWF9hSSN-- --===============4061624358442463417== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel --===============4061624358442463417==--