From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: David Laight <David.Laight@ACULAB.COM>
Cc: Qing Wang <wangqing@vivo.com>,
Thierry Reding <thierry.reding@gmail.com>,
Lee Jones <lee.jones@linaro.org>,
"linux-pwm@vger.kernel.org" <linux-pwm@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] pwm: use div64_u64() instead of do_div()
Date: Thu, 10 Feb 2022 11:09:44 +0100 [thread overview]
Message-ID: <20220210100944.ebkiezfablofqitj@pengutronix.de> (raw)
In-Reply-To: <9273cd6497354dd882faf55b194ff590@AcuMS.aculab.com>
[-- Attachment #1: Type: text/plain, Size: 1248 bytes --]
On Thu, Feb 10, 2022 at 09:48:44AM +0000, David Laight wrote:
> From: Uwe Kleine-König
> > Sent: 09 February 2022 15:26
> ...
> > > - do_div(cycles, period_ns);
> > > + div64_u64(cycles, period_ns);
> >
> > This is wrong, div64_u64() has a different calling convention than do_div().
> >
> > The issue however is real. Please add
>
> Not really although I can't see a check I'd assume that period_ns
> is expected to be much less than a second - so well under 32 bits
> There is certainly a general expectation that multiplying by
> other 'largish' values won't exceed 64 bits.
I'd consider such expectations a bug and hope to catch this type of
problem for new drivers. However I'm not surprised if you can point out
several such problems in the code base. Please fix at will :-)
> Plausible the pwm 'period' should actually be a u32.
> But then care would be needed to ensure the multiplies have
> 64bit results.
There are definitely consumers expecting to be able to set bigger
periods, see a9d887dc1c60ed67f2271d66560cdcf864c4a578.
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | https://www.pengutronix.de/ |
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
prev parent reply other threads:[~2022-02-10 10:09 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-09 8:39 [PATCH] pwm: use div64_u64() instead of do_div() Qing Wang
2022-02-09 15:26 ` Uwe Kleine-König
2022-02-10 9:48 ` David Laight
2022-02-10 10:09 ` Uwe Kleine-König [this message]
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=20220210100944.ebkiezfablofqitj@pengutronix.de \
--to=u.kleine-koenig@pengutronix.de \
--cc=David.Laight@ACULAB.COM \
--cc=lee.jones@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pwm@vger.kernel.org \
--cc=thierry.reding@gmail.com \
--cc=wangqing@vivo.com \
/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).