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 X-Spam-Level: X-Spam-Status: No, score=-2.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C1225C43331 for ; Mon, 30 Mar 2020 20:44:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9420120757 for ; Mon, 30 Mar 2020 20:44:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728907AbgC3UoU (ORCPT ); Mon, 30 Mar 2020 16:44:20 -0400 Received: from alexa-out-sd-01.qualcomm.com ([199.106.114.38]:4960 "EHLO alexa-out-sd-01.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728123AbgC3UoU (ORCPT ); Mon, 30 Mar 2020 16:44:20 -0400 Received: from unknown (HELO ironmsg04-sd.qualcomm.com) ([10.53.140.144]) by alexa-out-sd-01.qualcomm.com with ESMTP; 30 Mar 2020 13:44:03 -0700 Received: from gurus-linux.qualcomm.com ([10.46.162.81]) by ironmsg04-sd.qualcomm.com with ESMTP; 30 Mar 2020 13:44:00 -0700 Received: by gurus-linux.qualcomm.com (Postfix, from userid 383780) id F2EE44BFF; Mon, 30 Mar 2020 13:43:59 -0700 (PDT) Date: Mon, 30 Mar 2020 13:43:59 -0700 From: Guru Das Srinagesh To: Arnd Bergmann Cc: Linux PWM List , Thierry Reding , Uwe =?utf-8?Q?Kleine-K=C3=B6nig?= , Subbaraman Narayanamurthy , "linux-kernel@vger.kernel.org" , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team Subject: Re: [PATCH v11 06/12] pwm: imx27: Use 64-bit division macro and function Message-ID: <20200330204359.GB5107@codeaurora.org> References: <5aae102e21c0e63ad2588ae1e174b48b06d25e96.1584667964.git.gurus@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 20, 2020 at 06:09:39PM +0100, Arnd Bergmann wrote: > On Fri, Mar 20, 2020 at 2:42 AM Guru Das Srinagesh wrote: > > > @@ -240,8 +240,7 @@ static int pwm_imx27_apply(struct pwm_chip *chip, struct pwm_device *pwm, > > > > period_cycles /= prescale; > > c = (unsigned long long)period_cycles * state->duty_cycle; > > - do_div(c, state->period); > > - duty_cycles = c; > > + duty_cycles = div64_u64(c, state->period); > > > > This change looks fine, but I wonder if the code directly above it > > c = clk_get_rate(imx->clk_per); > c *= state->period; > do_div(c, 1000000000); > period_cycles = c; > > might run into an overflow when both the clock rate and the period > are large numbers. Hmm. Seems to me like addressing this would be outside the scope of this patch series. Thank you. Guru Das.