From patchwork Fri Jun 21 14:37:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= X-Patchwork-Id: 13707689 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 9EF54C27C4F for ; Fri, 21 Jun 2024 14:38:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc: To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=DpjbtuRsYUxGDKKpuIwVrQYGfcBuCB+ep5KKwdfomXI=; b=EpBal6QzSy22v0vw9YsVlRgoZX wpsKqcqEb+Hclhwwm4baLvaUw8EUpWLNS72YvVEsIn9ZW4WslVlY1KsfjkgYwEJbcXoAiMpSZAZfO XyBZgdRNbPyMuBQ8k/Cca8/CLTOtpHcgYyOKcZSAMPZAkwslRfoyXet/T/WeTTnBxmfFs5YhM1XTx 142XM4aJmOmFOSLrYQf2duAqZxZfI2GloPYKiwUNo8rkwrkVaMxwdVVzsNN3I+WEaZYYJ0K42Ir1r sEZI7l+lxI8EEYGiKNGiJM9Ul3BfT28tLws6DvCfKaqT4nX1ik5x9AVTxouicEEHsOOP8f6YetWk2 8mXuGJ0A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sKfOn-00000009X8g-1Oe3; Fri, 21 Jun 2024 14:37:57 +0000 Received: from mail-ej1-x630.google.com ([2a00:1450:4864:20::630]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sKfOY-00000009X2s-1KR0 for linux-arm-kernel@lists.infradead.org; Fri, 21 Jun 2024 14:37:43 +0000 Received: by mail-ej1-x630.google.com with SMTP id a640c23a62f3a-a6265d3ba8fso218158766b.0 for ; Fri, 21 Jun 2024 07:37:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1718980660; x=1719585460; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=DpjbtuRsYUxGDKKpuIwVrQYGfcBuCB+ep5KKwdfomXI=; b=oViz6pv4fhILjf+KJVCRFX5JPGN8eCtToHl73zeCZFs7tRwgE0bZW6QTXezFyOxgwd JWylmR3nW0p2j/HpoidEs6n8pMrLpRknAewZVnZWMtaXr16ivMMEJUZ2DBS05PlTv0yT 1MoOkeZp80AE8pYKklbFkVS1sq4luIUosBG6hgpiloO0msD1P4nViViOkg8OwgNUDBLH kiM868RouhElmuBLeHwP/fHAn9Z/bUfUnPwOFFBqQlRWgB1fCe4lscCuRe7qOfM0MV/6 XVN8+GGGDVQFudRJwkHq8FbJPMToQQuTRY7aODAlR0RtsvOgmi7/DqE8i8t7uHGuBphH dVvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718980660; x=1719585460; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DpjbtuRsYUxGDKKpuIwVrQYGfcBuCB+ep5KKwdfomXI=; b=AM9bslY8GSCF2PVjqUlVCvak5Xq39Byi6FUXuKgjlEtHL5mFLySM0d/XWwXxgWDSdb ANFLdY6qeKvUul4gq2l0ShfdZepSRTG2uvB9eDWZays8jDQYhkOxNbhYpsnyKL2RBixm dzuFo6/fS9iEbnewjRjrGH5BANbXJPzNCg0AtXV0uTc4k9phSzu7RDdrTj2jhB7iKtlc cusVePZ/2VhU1k1WF0MmsXglAT6HAgQRlI8YEyrOejFBg97OvxvulUTWYXkJya8FExhW bDtMfq0Tl38HEPPqU5ayWD9M1MrNDs1igjjeaZofM74nYNucvqs8pCJIUoMcleM1yqQJ G+aA== X-Forwarded-Encrypted: i=1; AJvYcCXI1yXnRfWRkqOchX3Cq89dbeVUIFJFUnx8eCZDPSObgovrs9i4w92yLKk0eKN3UvJyhs5/0icXvsPVEL8eoL88M2GQzl3B4foWZXjoHrkv/kHCPv4= X-Gm-Message-State: AOJu0YwvagG3GBYBgkb0FNRV99kTggwG5Ebg6c0D/DRG23FpODtKYpUC HjvRMmhJssxGr3/XxjJfM1CowwWQbTQuXnKhSfdBDexkfMJZilCQL6Tv7oe6OwQ= X-Google-Smtp-Source: AGHT+IFnG8vPc7gD/zkJj+cDdWoK1zUqRd6sd4hZoStrTa7UEp0SdW6Bnq1Jrrg14s9KXzb7mLfmvQ== X-Received: by 2002:a17:907:a646:b0:a6f:5192:6f4d with SMTP id a640c23a62f3a-a6fab60321fmr603671866b.8.1718980660351; Fri, 21 Jun 2024 07:37:40 -0700 (PDT) Received: from localhost (p5091583d.dip0.t-ipconnect.de. [80.145.88.61]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6fcf56ece7sm90255466b.208.2024.06.21.07.37.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Jun 2024 07:37:39 -0700 (PDT) From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Fabrice Gasnier , Maxime Coquelin , Alexandre Torgue , Benjamin Gaignard , Lee Jones , Thierry Reding Cc: linux-pwm@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, Trevor Gamblin , stable@vger.kernel.org Subject: [PATCH v2 1/3] pwm: stm32: Refuse too small period requests Date: Fri, 21 Jun 2024 16:37:12 +0200 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=969; i=u.kleine-koenig@baylibre.com; h=from:subject:message-id; bh=77m9S/e76ZnqolXIdKGvPpQwodpWtsZsa1irYtdWzSg=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBmdZAb+JF1Lt4sQgcrKfQpUfAROKFoD9THKpVyX 3OGJ7yuteKJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZnWQGwAKCRCPgPtYfRL+ TogNB/4wXOzt1/fRlY9bvWJQ8dB2JW/44VfPAoPIjaBk7pL32PDPR21QrNgn1+8ThreMJc6YFht BTJPKzI2CtXXdaR/N90Zdv+6Hl+EAxR3+JzPp1fN0F0v74hQ/DsWOPXcQFG+21256SX25ScI2Hv s6m/49IIBgcyGmVdHiIZVt/IaoQyXtW7PfhKWqZBCcmOs2zLOhhllZQFwiLhhr5ADfObNftH080 nIxbYKKHZ+lHZIHeAKH74pq2GjrYAHvlzoSHMnHg7IcbB369mX5L2nxfkwOq/un0+QEzy8PGj0C TosDsIqF3zMkjlyMqWdIzyKTzTVNQg5bgLc9w2hB5UsIeZSq X-Developer-Key: i=u.kleine-koenig@baylibre.com; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240621_073742_394510_2313A5D1 X-CRM114-Status: GOOD ( 11.34 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org If period_ns is small, prd might well become 0. Catch that case because otherwise with regmap_write(priv->regmap, TIM_ARR, prd - 1); a few lines down quite a big period is configured. Fixes: 7edf7369205b ("pwm: Add driver for STM32 plaftorm") Cc: stable@vger.kernel.org Reviewed-by: Trevor Gamblin Signed-off-by: Uwe Kleine-König --- drivers/pwm/pwm-stm32.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/pwm/pwm-stm32.c b/drivers/pwm/pwm-stm32.c index a2f231d13a9f..3e7b2a8e34e7 100644 --- a/drivers/pwm/pwm-stm32.c +++ b/drivers/pwm/pwm-stm32.c @@ -337,6 +337,8 @@ static int stm32_pwm_config(struct stm32_pwm *priv, unsigned int ch, prd = mul_u64_u64_div_u64(period_ns, clk_get_rate(priv->clk), (u64)NSEC_PER_SEC * (prescaler + 1)); + if (!prd) + return -EINVAL; /* * All channels share the same prescaler and counter so when two From patchwork Fri Jun 21 14:37:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= X-Patchwork-Id: 13707690 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 B3359C27C4F for ; Fri, 21 Jun 2024 14:38:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc: To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=nFQvBp09SYhqBXHYcpVbluB3rmpVFZWSPU/sKj+XFgQ=; b=N6psYdC/EvFrE/a/6eUPyz/N6s /IVCRj0oFk/3WaPcrveI+6LODJJse23wNpw0e21bmcTbFz3OuJtDRQufu2ZI8mfQHwdNSWD9dqVf7 ythiwts93o9eqlbSXqj7lQkXSZypP6CYDiuj+tHXqLuDzDrZ0G6rf5UQFIXjlr2cHebDCUgyAYoaB QE8qB2W9rTgOITB7zbjqorrxS8QtpHIgKFANxPAaETZcSohhLjrSn9S8et4Qv41LAAHWTr8tuTTq2 jBD2hQhdI584tpfO4xFAsKeaQM/FanE1ze/1o/eWvbqgNnBOLfKzRCMZgfJoqT+h4xqHC6hmM1X3v FgnCAqCw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sKfOp-00000009XAN-259M; Fri, 21 Jun 2024 14:37:59 +0000 Received: from mail-ed1-x52c.google.com ([2a00:1450:4864:20::52c]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sKfOZ-00000009X3H-1TNf for linux-arm-kernel@lists.infradead.org; Fri, 21 Jun 2024 14:37:45 +0000 Received: by mail-ed1-x52c.google.com with SMTP id 4fb4d7f45d1cf-57d05e0017aso2602725a12.1 for ; Fri, 21 Jun 2024 07:37:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1718980662; x=1719585462; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=nFQvBp09SYhqBXHYcpVbluB3rmpVFZWSPU/sKj+XFgQ=; b=acMGjSYFkoi2dcCaeUH0UB9lZnjn0htj9jM/H0Pckf/MyKzvxIy2JV8QwJ/LjCUT6C Wg+Y8EoFqTzB/RQYNKz3qYH1dsi2A09Bkf2qhpdRHjfOrZiwdrmqld9qF+D/HcgKSdFg Zg/TWrNpvPxIwySQ6tRW1ZDQrtnrJz1qKvEmxce+vR2l3N42b2sAb0Pyl06Nn/3cqznE Vrq0JRlEmKg15GLi6HaaADaEreARm8IOvZuRvvH7dkANtWMb8UXveJ1YR1cRQcJYTx7P bhR3zsbTQ/X2gl0yIV9Sgy5v/U4DoOHQow94CmoF3aMIykWrxGwqucKY2TD9nkRoPqyD mvfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718980662; x=1719585462; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nFQvBp09SYhqBXHYcpVbluB3rmpVFZWSPU/sKj+XFgQ=; b=qm775FswlF/O83YPGCScb1cSxvMvgtQKrQH/4nUb9lAMCq0DHNHrduW1h8G9FZqdG5 jNV5fddFXBJJ9uylm4Lz+HbMIeR6MYLUVDnBk2fE7smTz0pOO+6ol18wF89R8G3N19Lt 0GNksIghHqPOxjD2Cm62QzUyPcxPnS1NZopwZEovVYdyPXIj6EVBoGvmiKrWQ/+/6/pj 3Jq7zGldfM1dWi33EoVcCA2Cz6nyY3yOdUaArRemUerSCw3p4GJZttVEiPNVh3Xe332B Ek295ifndRy6E8vzBPc5ieNooCR8nyMyykVbQwM/ewlL9uRDRX91Tz4HO+cGrsMeui/5 zrhw== X-Forwarded-Encrypted: i=1; AJvYcCW3mh0gRHPeJy8CPKDczlGyDkNFjYd7O7PuLe+jg6qjSh2JsnDJqUDKvayC0I2LPDiDiKeS3dLysrM1bPHQTPfZd4RMmmBfJhCRxMzoM+A5B8kdZzI= X-Gm-Message-State: AOJu0YxHZB/PkBBFJy941hld6yPXx9OsANb60hzAh6vUneKaR5/I4kNC 52e6zcswao1g5AKe1mlbSe260bbQtLEbS+sa/e4pTlRB7WSgNNjJD8ON2ROwy50= X-Google-Smtp-Source: AGHT+IHhBkbnDwe6DC78mHyYrZoTEMrk9luPtrCGS6uQpBAuAlhQcl4/FTWTW5gRCSAfgVzjizpaQA== X-Received: by 2002:a17:906:fe4d:b0:a6f:4b7d:599b with SMTP id a640c23a62f3a-a6fab64869dmr667183566b.33.1718980661770; Fri, 21 Jun 2024 07:37:41 -0700 (PDT) Received: from localhost (p5091583d.dip0.t-ipconnect.de. [80.145.88.61]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6fcf56ee06sm90550566b.198.2024.06.21.07.37.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Jun 2024 07:37:41 -0700 (PDT) From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Fabrice Gasnier , Maxime Coquelin , Alexandre Torgue , Benjamin Gaignard , Lee Jones , Thierry Reding Cc: linux-pwm@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, Trevor Gamblin Subject: [PATCH v2 2/3] pwm: stm32: Fix calculation of prescaler Date: Fri, 21 Jun 2024 16:37:13 +0200 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2498; i=u.kleine-koenig@baylibre.com; h=from:subject:message-id; bh=k1b/UZlBPcg27jJ13+cEn2qIvvv2MFL41xaIuM2GWOg=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBmdZAdj6nX78OTtkGgf+zjfTRynFlrjHnlSPFLB /sXRGO38cqJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZnWQHQAKCRCPgPtYfRL+ TpsPCACpUFVr/Itd1iZOgd/j4VQ1XonbgsnD5G7pim5yCA1J/WsMS8mS+NJSuUN83vBBSyk8uEp Jr5j0peLUzVb3MKp8PcSn19eXTfXnkitfvvr+UnJ4HzcKZkUp3jCDf4f+WlNZRM/ZCdHJqDafs1 PGPOGdY3A7h6VtZtSNn40D/sMD9n+bgcS4ZGELGa/mnOQ0seYBXqYyT941X8UpSK60KZHgNAjRp dOVhv184I2YtPmfJGMkDM1jvDqtcOn3u/2mY3UyhNzXS5yEc1cBbm7ljRofEEBG87rZ1c1/oloS wBhYOqRr2nZ0UpEDKNNMyvaaxLinCMBBY32VQkGyLHg45K94 X-Developer-Key: i=u.kleine-koenig@baylibre.com; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240621_073743_421859_838B7280 X-CRM114-Status: GOOD ( 15.57 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org A small prescaler is beneficial, as this improves the resolution of the duty_cycle configuration. However if the prescaler is too small, the maximal possible period becomes considerably smaller than the requested value. One situation where this goes wrong is the following: With a parent clock rate of 208877930 Hz and max_arr = 0xffff = 65535, a request for period = 941243 ns currently results in PSC = 1. The value for ARR is then calculated to ARR = 941243 * 208877930 / (1000000000 * 2) - 1 = 98301 This value is bigger than 65535 however and so doesn't fit into the respective register field. In this particular case the PWM was configured for a period of 313733.4806027616 ns (with ARR = 98301 & 0xffff). Even if ARR was configured to its maximal value, only period = 627495.6861167669 ns would be achievable. Fix the calculation accordingly and adapt the comment to match the new algorithm. With the calculation fixed the above case results in PSC = 2 and so an actual period of 941229.1667195285 ns. Fixes: 8002fbeef1e4 ("pwm: stm32: Calculate prescaler with a division instead of a loop") Signed-off-by: Uwe Kleine-König --- drivers/pwm/pwm-stm32.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/drivers/pwm/pwm-stm32.c b/drivers/pwm/pwm-stm32.c index 3e7b2a8e34e7..a7ff39e9fc28 100644 --- a/drivers/pwm/pwm-stm32.c +++ b/drivers/pwm/pwm-stm32.c @@ -321,17 +321,23 @@ static int stm32_pwm_config(struct stm32_pwm *priv, unsigned int ch, * First we need to find the minimal value for prescaler such that * * period_ns * clkrate - * ------------------------------ + * ------------------------------ < max_arr + 1 * NSEC_PER_SEC * (prescaler + 1) * - * isn't bigger than max_arr. + * This equation is equivalent to + * + * period_ns * clkrate + * ---------------------------- < prescaler + 1 + * NSEC_PER_SEC * (max_arr + 1) + * + * Using integer division and knowing that the right hand side is + * integer, this is further equivalent to + * + * (period_ns * clkrate) // (NSEC_PER_SEC * (max_arr + 1)) ≤ prescaler */ prescaler = mul_u64_u64_div_u64(period_ns, clk_get_rate(priv->clk), - (u64)NSEC_PER_SEC * priv->max_arr); - if (prescaler > 0) - prescaler -= 1; - + (u64)NSEC_PER_SEC * (priv->max_arr + 1)); if (prescaler > MAX_TIM_PSC) return -EINVAL; From patchwork Fri Jun 21 14:37:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= X-Patchwork-Id: 13707692 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 07B7BC27C4F for ; Fri, 21 Jun 2024 14:38:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc: To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Ysq3uDxdRX+lWPBKjGMKWeUw8FNy+OKaKwytbRkcytM=; b=X1oIohykoS2TF1ciDCZm9N0VOy fTwbFHdC3iPpNgxQ0QPqdUbqi3G5uImnlOC86JXHqD/gB8vykvRAp42LveMhIHuAmJcw5nHF89T1Y hUpPjISF4q7+Z6FYApnSG2PJKxAZwkN2wzmF9QoTnAUAaWKye3cp9VZcDoE20aQsl/BOoM09s+kp5 wLYCiyHXwJUnEoirfZzi922ZbL+S/k/rMsP/aoU04e4xhAmWL1fZPRCe8NBLDf3b9xccrAO1fUCBq 73hWLvLcu2DD65valTXo8GQ7DGpB58j2/rpCQZ0N0skLTwQfT4mBd5ibZ4jRD5g2FZPmR7rmsJWKt JNLPeUxw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sKfOr-00000009XBZ-2e8d; Fri, 21 Jun 2024 14:38:01 +0000 Received: from mail-lj1-x22e.google.com ([2a00:1450:4864:20::22e]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sKfOb-00000009X3q-0cpK for linux-arm-kernel@lists.infradead.org; Fri, 21 Jun 2024 14:37:46 +0000 Received: by mail-lj1-x22e.google.com with SMTP id 38308e7fff4ca-2eaea28868dso27765261fa.3 for ; Fri, 21 Jun 2024 07:37:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1718980663; x=1719585463; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Ysq3uDxdRX+lWPBKjGMKWeUw8FNy+OKaKwytbRkcytM=; b=uQ1AqqIDQodTzlKsZeJkeHBEzBwbyaVNLGazQCwxMsE1+TMzitom9Lc/ZhUG97E9up YN5loLZmI2qLALQ8jq+N0MqUkUwu3Gg+lz3khifjWEgIRzC/hvWkhGYpHlPaR0yGJboh QK/fc5BoZP83tDcWJ/eJFmky5SpHdEa8AtQQvMvrpqDXQctmwPnTJ9ntbhgM2ZEBySjv hTs4ONIGb6FuQ/YIl5Eqgfmc5ygTgcOqig4Tc3PUPzJXh03/WBqNOFYz3Iax6BeGVwrA +cza5FlJs0jyP6ERb7u5edlYgiy8Wq/zcmBrzoTLXJt/h25+StmX90XzqJiRwJ86og92 q6og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718980663; x=1719585463; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ysq3uDxdRX+lWPBKjGMKWeUw8FNy+OKaKwytbRkcytM=; b=wL3vVSo1auJj5dQghjxnictoXYIQaj7j4jGjrnY3Iuj9Y6I5eyOudo9TqkMtPFB1ir kh6Cb3NuBDVF1KEnOQDTmNs3jgrHmMZ1IXyqYg+Au9OvbGEnE3UFg9iiUZszwapoZR5I ZhyekuPafRA+mOGgn8zG6whCXDBbsD0ehDgW0ry87JY6C9j6vEzLkYDTJieiV6VFuYLm DnEx+fqlQ3wChRitqYEaBZpKkqKKQhLbfc1G/10c2HcKdfby+6hf1Muzzihvq644eqTT dY5D4SBMGp/0LXN8HvsPU+NBgQb4NtLOv0iwzSILF29gPtoXnK2CbI/+WOaZV9rGKg8w qH8w== X-Forwarded-Encrypted: i=1; AJvYcCWXe103QN5LdtehRFU2zMzVN0wEVoCmAQaC9S04wSm90kUpl66bvH1WEld4IRes5pjgaYfwK4kgF4pTcz+MDAz/YkC6sX6ZyGIWNRJqqjPn9ycXcAU= X-Gm-Message-State: AOJu0Yzww6WiSTjVDbUlHzg/a0jTbdqIVq24q/T8OfaFO5TU9bz09KjD nnSW1d5uoPD0UB+oCxGnk/sdkv6Ow++ApZPN0DyN+EKa5cj5G2IGYLEitkoBNVU= X-Google-Smtp-Source: AGHT+IFLJYSC6FgjmimkqI552OEyvALn0atKDFSRu4RIfBpKfbrvs9j00kDHZDdQpT6hofjonr2dCw== X-Received: by 2002:a2e:860e:0:b0:2eb:d963:d8cc with SMTP id 38308e7fff4ca-2ec3cffc54dmr66022471fa.49.1718980663095; Fri, 21 Jun 2024 07:37:43 -0700 (PDT) Received: from localhost (p5091583d.dip0.t-ipconnect.de. [80.145.88.61]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6fcf560632sm89872266b.160.2024.06.21.07.37.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Jun 2024 07:37:42 -0700 (PDT) From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Fabrice Gasnier , Maxime Coquelin , Alexandre Torgue , Benjamin Gaignard , Lee Jones , Thierry Reding Cc: linux-pwm@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, Trevor Gamblin Subject: [PATCH v2 3/3] pwm: stm32: Fix error message to not describe the previous error path Date: Fri, 21 Jun 2024 16:37:14 +0200 Message-ID: <285182163211203fc823a65b180761f46e828dcb.1718979150.git.u.kleine-koenig@baylibre.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=997; i=u.kleine-koenig@baylibre.com; h=from:subject:message-id; bh=SfN1/kmbTsUXBRgADyC88RwGMUteJe+oranzSQBC5Fk=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBmdZAfb+L0dKnD/968LLQzw7aJDYzoGaDBtRJAB NS3vUyhQRCJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZnWQHwAKCRCPgPtYfRL+ TpYoCACUHHNFQz4vsijVkCs9ya+JpnFPamzXqQOcAYtZspgBby/vtiTojF3PA+ZxfJwj7G430Jx 9ifJDujnDwnuPMbRfJFgXPJomcN5p3Ijc7iSJ2ToVfDkY4T9MUjYbl5Kzff22KmeOj0IfCOEpl4 4uoU9zsubXjvbpq5G/MnS7CnM7DJP3j8wE7icIh2aOMHqkCsDT36QAKpUAzhlyJdmJW2Lvhm51+ wn+O4Q4fa8z6CtH8UuaWMugsrFsJ6AXsA5PqGjVq0v0dFeE4Ava0FCLo1QwXh6zxhnXYXWawKlt 4MHbZtWkTvogh8CUvJ77vCWrdOkRqtuYrmTkH5dsC7khnrSK X-Developer-Key: i=u.kleine-koenig@baylibre.com; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240621_073745_242928_5D2E9C9F X-CRM114-Status: GOOD ( 13.45 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org "Failed to lock the clock" is an appropriate error message for clk_rate_exclusive_get() failing, but not for the clock running too fast for the driver's calculations. Adapt the error message accordingly. Fixes: d44d635635a7 ("pwm: stm32: Fix for settings using period > UINT32_MAX") Signed-off-by: Uwe Kleine-König --- drivers/pwm/pwm-stm32.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/pwm/pwm-stm32.c b/drivers/pwm/pwm-stm32.c index a7ff39e9fc28..bc32e9abf2b1 100644 --- a/drivers/pwm/pwm-stm32.c +++ b/drivers/pwm/pwm-stm32.c @@ -681,7 +681,8 @@ static int stm32_pwm_probe(struct platform_device *pdev) * .apply() won't overflow. */ if (clk_get_rate(priv->clk) > 1000000000) - return dev_err_probe(dev, -EINVAL, "Failed to lock clock\n"); + return dev_err_probe(dev, -EINVAL, "Clock freq too high (%lu)\n", + clk_get_rate(priv->clk)); chip->ops = &stm32pwm_ops;