From patchwork Wed Nov 23 13:36:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Fabrice Gasnier X-Patchwork-Id: 24987 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2802880wrr; Wed, 23 Nov 2022 05:58:13 -0800 (PST) X-Google-Smtp-Source: AA0mqf7LapNrnVL2Jq6fLT1T+EjAyiPswfWPrE3X+Qw3EX8JT+Z0sqGFTm+H0mi4+IQcpqefNBkU X-Received: by 2002:a17:906:8455:b0:7aa:97c7:2c04 with SMTP id e21-20020a170906845500b007aa97c72c04mr10175780ejy.191.1669211892834; Wed, 23 Nov 2022 05:58:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669211892; cv=none; d=google.com; s=arc-20160816; b=lBS8FGSQhy99cXi+80Bet3YoffKumKdgW0kEJOGP5uwxtrBQsIohFjjHHqZhxmB2i2 Gda7W8/jlUqfjVfIYkNgx8AMJAbPTcu8yGs7jOTMyFqIm4D/v2ACm1WFa1HT37ddWDww EOqZhhEWnw7mSkViZektw0t8TAQiTBgxWXEmF7pVgmpcZx4rHZCttgFlpYBBGT1QLdXl 0Uxn15vGnN8Y71b8OoHmrh0GERdKlel4q+wdDofQLj0N3n7x5/kgfhGO4qj+MKiK230q lAPvQWCEoLbczhucdn+TfhnpDi6wenVeF/aEolvXwvzCwBh5jwWFh7LFq9KNcgXypLxS phEw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=43DBf8OtjFvR9aatD+0pcM+rPZ03EasEqHg9movlJfk=; b=iCvdDqd0B1DE5lYaJDNlRlNstNgl8/6VebAJItnHjRh2U6nrlBj4+Uz/JnbfP98XdH ez1wAm7xnOmQOWw54WYuxPSqGz3qBYI6A3IjuncU+FIRYef/DmpiKYduiTBUjUuXEW44 sCXXKsICIM+YZ8OSguHGirAcIaid0ns+HbVvnTXcRZis94odW4YM7TpqP3YGDeXwTXkV qr/kr6V6nFosTis78mhP3oWItjJT6ZFF867kvVR+6KbBe+w93vlGfapXCAg7ppJoFJES 0KZLbb4V55NBBwzVMm6XLFPGT8V2frijKsHtbH2bbvUh2tt14SqH8H9ZUMjahS+1BXQt 5bfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b="iGFQ3b/n"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foss.st.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id di18-20020a170906731200b0078df24be362si13539963ejc.496.2022.11.23.05.57.44; Wed, 23 Nov 2022 05:58:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b="iGFQ3b/n"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foss.st.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237693AbiKWNsX (ORCPT + 99 others); Wed, 23 Nov 2022 08:48:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237634AbiKWNrc (ORCPT ); Wed, 23 Nov 2022 08:47:32 -0500 Received: from mx07-00178001.pphosted.com (mx08-00178001.pphosted.com [91.207.212.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6BEF4429AA; Wed, 23 Nov 2022 05:37:12 -0800 (PST) Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2AND8Qp3022759; Wed, 23 Nov 2022 14:37:03 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=selector1; bh=43DBf8OtjFvR9aatD+0pcM+rPZ03EasEqHg9movlJfk=; b=iGFQ3b/nlXp/OQhxguV0KJedGxSFHpJ0M5WQj7h+KuS73fijiOHE/ROCjUAvaScWwYG4 tSC1WoZZBw0mQgsYeo/Ke0pBxkpvdX8y56o/LJdwTV47OQ1fpmNif3VI8s7ynlP6Ld9g c+LR+t2sPjQTQ3jluh4jiccOl3geBfnBgfpjhcVS+uSlUqDRH9mbUY8GKGx0X+BM0OeM 2xSwSFoyqAwylxrB0WoJhGx7yUkLPNoHHmXhM/OwY6ZH44vyMgdREqzexDrzYbQKRW3i yi4pYm6eMh/1/tWNhYVGluM2jLNWNbqevX9GPBJxBE4otpaH9VEP2xQYhja9sGpKQ5hj Rw== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 3kxrdch3uh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 23 Nov 2022 14:37:03 +0100 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id D900010002A; Wed, 23 Nov 2022 14:37:00 +0100 (CET) Received: from Webmail-eu.st.com (shfdag1node2.st.com [10.75.129.70]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id D2658226FCB; Wed, 23 Nov 2022 14:37:00 +0100 (CET) Received: from localhost (10.48.1.102) by SHFDAG1NODE2.st.com (10.75.129.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.13; Wed, 23 Nov 2022 14:36:58 +0100 From: Fabrice Gasnier To: , CC: , , , , , , Subject: [PATCH] pwm: stm32-lp: fix the check on arr and cmp registers update Date: Wed, 23 Nov 2022 14:36:52 +0100 Message-ID: <20221123133652.465724-1-fabrice.gasnier@foss.st.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Originating-IP: [10.48.1.102] X-ClientProxiedBy: EQNCAS1NODE3.st.com (10.75.129.80) To SHFDAG1NODE2.st.com (10.75.129.70) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-23_07,2022-11-23_01,2022-06-22_01 X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750295529930091201?= X-GMAIL-MSGID: =?utf-8?q?1750295529930091201?= 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 register isn't correctly updated. So ensure both status bits are set before clearing them. Fixes: e70a540b4e02 ("pwm: Add STM32 LPTimer PWM driver") Signed-off-by: Fabrice Gasnier Acked-by: Uwe Kleine-König --- drivers/pwm/pwm-stm32-lp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pwm/pwm-stm32-lp.c b/drivers/pwm/pwm-stm32-lp.c index 3115abb3f52a..61a1c87cd501 100644 --- a/drivers/pwm/pwm-stm32-lp.c +++ b/drivers/pwm/pwm-stm32-lp.c @@ -127,7 +127,7 @@ static int stm32_pwm_lp_apply(struct pwm_chip *chip, struct pwm_device *pwm, /* ensure CMP & ARR registers are properly written */ ret = regmap_read_poll_timeout(priv->regmap, STM32_LPTIM_ISR, val, - (val & STM32_LPTIM_CMPOK_ARROK), + (val & STM32_LPTIM_CMPOK_ARROK) == STM32_LPTIM_CMPOK_ARROK, 100, 1000); if (ret) { dev_err(priv->chip.dev, "ARR/CMP registers write issue\n");