Message ID | 20221110114549.34121-1-steven.price@arm.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp95180wru; Thu, 10 Nov 2022 03:50:00 -0800 (PST) X-Google-Smtp-Source: AMsMyM4Zb47FNRKZgck9Er3nT2+o6OHQiWMBVIoepcqLi+7SNEveNY6Jtk5sqax87gifFDZ9CzjS X-Received: by 2002:a05:6402:3641:b0:463:b8dc:893f with SMTP id em1-20020a056402364100b00463b8dc893fmr2169717edb.28.1668081000392; Thu, 10 Nov 2022 03:50:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668081000; cv=none; d=google.com; s=arc-20160816; b=hm/wqGW2UcYgfs3hmHwIaQK8NUvvjfej0mVEQBscNFtKOqTYYojmsB4uoOU9LnK444 RX6yNQli3DaRKI7RvN9tfO9pzWtXBz+WLgqzkpBdGJfGjyIxwB4ZGAOYaadPekbCVXxE TbVH9CAOd6vQ028u5UZ4GV1tRuIieIHh7bGR++Zf+4T9jEBL5fYwzKYd4e9uM8oGhUJH INnIn7fTnHafGL4nhKOeEmEEBHNrKSHOkEar2Dx8aKdYvuppohKjoaUX2O6Q/6ZfhYuT TGEMbTuF7bKpatYEv3E6//uop0SMccKAKSRy+BYQ6ppY5tulbfD1DgFKRtwsttZFjx1X 1ElQ== 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; bh=b5p3w6OAZ1N02hlmbg7uoRL0deH/AEKr1zsjSn+aFPw=; b=MQGXZYRKMTxe0OTgxRZc8aaiTmOYG4HmnwTzOFMArxtsyvPeH3cQksu7Tm4HapypNb kssuFQBymVd0DKVHP4JwVZsfWUnjVCO1BIHacW7pFjlsP8n3s3hQASPehmrAndww9MEV +5g1/l+p6xGawQQ2ZZbBzo8x2B9c1VQ6T+r5hoymYXo86em8BaMPonMcHGjlQh9GF9V5 364w6ZpX/Hl1Wkv2Ld7YCZQ2eMY/a7OESOc9u/uC/mABGw94yZeDlUU/5X9ltN2pHwBw 8Zr9U6mBGkOJsT3h4WEedWzH+g/pah+epGkeeLF1KvQ5symQyv3T97UqBDwb+z+GOPVM Zsfw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l18-20020a170906795200b007aea2b23ee3si3159611ejo.277.2022.11.10.03.49.32; Thu, 10 Nov 2022 03:50:00 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230443AbiKJLqY (ORCPT <rfc822;winker.wchi@gmail.com> + 99 others); Thu, 10 Nov 2022 06:46:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230280AbiKJLqV (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 10 Nov 2022 06:46:21 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D0E541F2CE; Thu, 10 Nov 2022 03:46:20 -0800 (PST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C93011FB; Thu, 10 Nov 2022 03:46:26 -0800 (PST) Received: from e122027.cambridge.arm.com (e122027.cambridge.arm.com [10.1.30.25]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 958253F534; Thu, 10 Nov 2022 03:46:19 -0800 (PST) From: Steven Price <steven.price@arm.com> To: Jonathan Hunter <jonathanh@nvidia.com>, Thierry Reding <thierry.reding@gmail.com> Cc: Steven Price <steven.price@arm.com>, =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= <u.kleine-koenig@pengutronix.de>, linux-kernel@vger.kernel.org, linux-pwm@vger.kernel.org, linux-tegra@vger.kernel.org Subject: [PATCH] pwm: tegra: Fix 32 bit build Date: Thu, 10 Nov 2022 11:45:48 +0000 Message-Id: <20221110114549.34121-1-steven.price@arm.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749109703054069375?= X-GMAIL-MSGID: =?utf-8?q?1749109703054069375?= |
Series |
pwm: tegra: Fix 32 bit build
|
|
Commit Message
Steven Price
Nov. 10, 2022, 11:45 a.m. UTC
The value of NSEC_PER_SEC << PWM_DUTY_WIDTH doesn't fix within a 32 bit
integer causing a build warning/error (and the value truncated):
drivers/pwm/pwm-tegra.c: In function ‘tegra_pwm_config’:
drivers/pwm/pwm-tegra.c:148:53: error: result of ‘1000000000 << 8’ requires 39 bits to represent, but ‘long int’ only has 32 bits [-Werror=shift-overflow=]
148 | required_clk_rate = DIV_ROUND_UP_ULL(NSEC_PER_SEC << PWM_DUTY_WIDTH,
| ^~
Explicitly cast to a u64 to ensure the correct result.
Fixes: cfcb68817fb3 ("pwm: tegra: Improve required rate calculation")
Signed-off-by: Steven Price <steven.price@arm.com>
---
drivers/pwm/pwm-tegra.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On 10/11/2022 11:45, Steven Price wrote: > The value of NSEC_PER_SEC << PWM_DUTY_WIDTH doesn't fix within a 32 bit > integer causing a build warning/error (and the value truncated): > > drivers/pwm/pwm-tegra.c: In function ‘tegra_pwm_config’: > drivers/pwm/pwm-tegra.c:148:53: error: result of ‘1000000000 << 8’ requires 39 bits to represent, but ‘long int’ only has 32 bits [-Werror=shift-overflow=] > 148 | required_clk_rate = DIV_ROUND_UP_ULL(NSEC_PER_SEC << PWM_DUTY_WIDTH, > | ^~ > > Explicitly cast to a u64 to ensure the correct result. > > Fixes: cfcb68817fb3 ("pwm: tegra: Improve required rate calculation") > Signed-off-by: Steven Price <steven.price@arm.com> > --- > drivers/pwm/pwm-tegra.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/pwm/pwm-tegra.c b/drivers/pwm/pwm-tegra.c > index 6fc4b69a3ba7..249dc0193297 100644 > --- a/drivers/pwm/pwm-tegra.c > +++ b/drivers/pwm/pwm-tegra.c > @@ -145,7 +145,7 @@ static int tegra_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, > * source clock rate as required_clk_rate, PWM controller will > * be able to configure the requested period. > */ > - required_clk_rate = DIV_ROUND_UP_ULL(NSEC_PER_SEC << PWM_DUTY_WIDTH, > + required_clk_rate = DIV_ROUND_UP_ULL((u64)NSEC_PER_SEC << PWM_DUTY_WIDTH, > period_ns); > > if (required_clk_rate > clk_round_rate(pc->clk, required_clk_rate)) Thanks! Reviewed-by: Jon Hunter <jonathanh@nvidia.com> Jon
Hello, On Thu, Nov 10, 2022 at 11:45:48AM +0000, Steven Price wrote: > The value of NSEC_PER_SEC << PWM_DUTY_WIDTH doesn't fix within a 32 bit > integer causing a build warning/error (and the value truncated): > > drivers/pwm/pwm-tegra.c: In function ‘tegra_pwm_config’: > drivers/pwm/pwm-tegra.c:148:53: error: result of ‘1000000000 << 8’ requires 39 bits to represent, but ‘long int’ only has 32 bits [-Werror=shift-overflow=] > 148 | required_clk_rate = DIV_ROUND_UP_ULL(NSEC_PER_SEC << PWM_DUTY_WIDTH, > | ^~ > > Explicitly cast to a u64 to ensure the correct result. Hmm, ideally this should have popped up earlier :-\ Anyhow: Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Thanks Uwe
On Thu, 10 Nov 2022 11:45:48 +0000, Steven Price wrote: > The value of NSEC_PER_SEC << PWM_DUTY_WIDTH doesn't fix within a 32 bit > integer causing a build warning/error (and the value truncated): > > drivers/pwm/pwm-tegra.c: In function ‘tegra_pwm_config’: > drivers/pwm/pwm-tegra.c:148:53: error: result of ‘1000000000 << 8’ requires 39 bits to represent, but ‘long int’ only has 32 bits [-Werror=shift-overflow=] > 148 | required_clk_rate = DIV_ROUND_UP_ULL(NSEC_PER_SEC << PWM_DUTY_WIDTH, > | ^~ > > [...] Applied, thanks! [1/1] pwm: tegra: Fix 32 bit build commit: dd1f1da4ada5d8ac774c2ebe97230637820b3323 Best regards,
diff --git a/drivers/pwm/pwm-tegra.c b/drivers/pwm/pwm-tegra.c index 6fc4b69a3ba7..249dc0193297 100644 --- a/drivers/pwm/pwm-tegra.c +++ b/drivers/pwm/pwm-tegra.c @@ -145,7 +145,7 @@ static int tegra_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, * source clock rate as required_clk_rate, PWM controller will * be able to configure the requested period. */ - required_clk_rate = DIV_ROUND_UP_ULL(NSEC_PER_SEC << PWM_DUTY_WIDTH, + required_clk_rate = DIV_ROUND_UP_ULL((u64)NSEC_PER_SEC << PWM_DUTY_WIDTH, period_ns); if (required_clk_rate > clk_round_rate(pc->clk, required_clk_rate))