From: Yang Li <yang.lee@linux.alibaba.com>
To: patrice.chotard@foss.st.com
Cc: a.zummo@towertech.it, alexandre.belloni@bootlin.com,
linux-arm-kernel@lists.infradead.org, linux-rtc@vger.kernel.org,
linux-kernel@vger.kernel.org,
Yang Li <yang.lee@linux.alibaba.com>
Subject: [PATCH -next] rtc: st-lpc: Use div64_ul instead of do_div
Date: Thu, 18 Nov 2021 11:25:41 +0800 [thread overview]
Message-ID: <1637205941-26223-1-git-send-email-yang.lee@linux.alibaba.com> (raw)
do_div() does a 64-by-32 division. Here the divisor 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.
Eliminate the following coccicheck warnings:
./drivers/rtc/rtc-st-lpc.c:96:1-7: WARNING: do_div() does a 64-by-32
division, please consider using div64_ul instead.
./drivers/rtc/rtc-st-lpc.c:251:1-7: WARNING: do_div() does a 64-by-32
division, please consider using div64_ul instead.
Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Yang Li <yang.lee@linux.alibaba.com>
---
drivers/rtc/rtc-st-lpc.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/rtc/rtc-st-lpc.c b/drivers/rtc/rtc-st-lpc.c
index bdb20f6..b6e169b 100644
--- a/drivers/rtc/rtc-st-lpc.c
+++ b/drivers/rtc/rtc-st-lpc.c
@@ -93,7 +93,7 @@ static int st_rtc_read_time(struct device *dev, struct rtc_time *tm)
spin_unlock_irqrestore(&rtc->lock, flags);
lpt = ((unsigned long long)lpt_msb << 32) | lpt_lsb;
- do_div(lpt, rtc->clkrate);
+ lpt = div64_ul(lpt, rtc->clkrate);
rtc_time64_to_tm(lpt, tm);
return 0;
@@ -248,7 +248,8 @@ static int st_rtc_probe(struct platform_device *pdev)
rtc->rtc_dev->ops = &st_rtc_ops;
rtc->rtc_dev->range_max = U64_MAX;
- do_div(rtc->rtc_dev->range_max, rtc->clkrate);
+ rtc->rtc_dev->range_max = div64_ul(rtc->rtc_dev->range_max,
+ rtc->clkrate);
ret = devm_rtc_register_device(rtc->rtc_dev);
if (ret) {
--
1.8.3.1
reply other threads:[~2021-11-18 3:25 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1637205941-26223-1-git-send-email-yang.lee@linux.alibaba.com \
--to=yang.lee@linux.alibaba.com \
--cc=a.zummo@towertech.it \
--cc=alexandre.belloni@bootlin.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rtc@vger.kernel.org \
--cc=patrice.chotard@foss.st.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
all inboxes | Powered by JetHome®