From: "Russell King (Oracle)" <linux@armlinux.org.uk>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: cgel.zte@gmail.com, linux-pwm@vger.kernel.org,
alexandre.belloni@bootlin.com, Zeal Robot <zealci@zte.com.cn>,
linux-kernel@vger.kernel.org, ludovic.desroches@microchip.com,
thierry.reding@gmail.com,
Changcheng Deng <deng.changcheng@zte.com.cn>,
lee.jones@linaro.org, linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] pwm: Use div64_ul instead of do_div
Date: Thu, 18 Nov 2021 10:09:41 +0000 [thread overview]
Message-ID: <YZYmZecp8WPkFY2F@shell.armlinux.org.uk> (raw)
In-Reply-To: <20211117112400.bkscb2pyavonpfsn@pengutronix.de>
On Wed, Nov 17, 2021 at 12:24:00PM +0100, Uwe Kleine-König wrote:
> Hello,
>
> On Wed, Nov 17, 2021 at 02:04:26AM +0000, cgel.zte@gmail.com wrote:
> > From: Changcheng Deng <deng.changcheng@zte.com.cn>
> >
> > do_div() does a 64-by-32 division. If the divisor is unsigned long, using
> > div64_ul can avoid truncation to 32-bit.
>
> After some research I understood your commit log. I'd write:
>
> do_div() does a 64-by-32 division. Here the divsor is an
> unsigned long which on some platforms is 64 bit wide. So use
> div64_ul instead of do_div to avoid a possible truncation.
>
> The priority of this patch seems to be low, as the device seems to exist
> only on (32bit) arm.
... where unsigned long is 32-bit.
In any case, for this to overflow, we would need to have a clock in
excess of 2^32-1 Hz, or around 4GHz - and if we had such a situation
on 32-bit devices, we need to change the type for holding the frequency
in the clk API, and probably a lot of code in the CCF as well.
Unless there is a real reason for this change, I would suggest leaving
the code as is - there is absolutely no point in making these divisions
more expensive unless there is a real reason.
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
next prev parent reply other threads:[~2021-11-18 10:11 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-17 2:04 [PATCH] pwm: Use div64_ul instead of do_div cgel.zte
2021-11-17 11:24 ` Uwe Kleine-König
2021-11-17 12:46 ` [PATCH V2] " cgel.zte
2021-11-17 14:54 ` Uwe Kleine-König
2021-11-18 2:52 ` [PATCH V3] " cgel.zte
2021-11-18 9:54 ` Uwe Kleine-König
2021-11-18 10:09 ` Russell King (Oracle) [this message]
2021-11-18 13:19 ` [PATCH] " Nicolas Ferre
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YZYmZecp8WPkFY2F@shell.armlinux.org.uk \
--to=linux@armlinux.org.uk \
--cc=alexandre.belloni@bootlin.com \
--cc=cgel.zte@gmail.com \
--cc=deng.changcheng@zte.com.cn \
--cc=lee.jones@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pwm@vger.kernel.org \
--cc=ludovic.desroches@microchip.com \
--cc=thierry.reding@gmail.com \
--cc=u.kleine-koenig@pengutronix.de \
--cc=zealci@zte.com.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).