From: "Liao, Chang" <liaochang1@huawei.com>
To: Thorsten Blum <thorsten.blum@toblux.com>
Cc: <anna-maria@linutronix.de>, <frederic@kernel.org>,
<jstultz@google.com>, <linux-kernel@vger.kernel.org>,
<peterz@infradead.org>, <tglx@linutronix.de>
Subject: Re: [PATCH v2] time: Use div64_ul() instead of do_div()
Date: Mon, 26 Feb 2024 19:34:31 +0800 [thread overview]
Message-ID: <c48aa5ff-8bce-52d7-6f52-ec18b74620d7@huawei.com> (raw)
In-Reply-To: <20240226090305.117120-2-thorsten.blum@toblux.com>
在 2024/2/26 17:03, Thorsten Blum 写道:
> Fixes Coccinelle/coccicheck warning reported by do_div.cocci.
>
> Compared to do_div(), div64_ul() does not implicitly cast the divisor and
> does not unnecessarily calculate the remainder.
>
> Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com>
> ---
> Changes in v2:
> - s/div64_long/div64_ul/ as suggested by Chang Liao
> ---
> kernel/time/jiffies.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/time/jiffies.c b/kernel/time/jiffies.c
> index bc4db9e5ab70..fccee15e94d5 100644
> --- a/kernel/time/jiffies.c
> +++ b/kernel/time/jiffies.c
> @@ -91,7 +91,7 @@ int register_refined_jiffies(long cycles_per_second)
> /* shift_hz stores hz<<8 for extra accuracy */
> shift_hz = (u64)cycles_per_second << 8;
> shift_hz += cycles_per_tick/2;
> - do_div(shift_hz, cycles_per_tick);
> + shift_hz = div64_ul(shift_hz, cycles_per_tick);
LGTM
Reviewed-by: Liao Chang <liaochang1@huawei.com>
> /* Calculate nsec_per_tick using shift_hz */
> nsec_per_tick = (u64)NSEC_PER_SEC << 8;
> nsec_per_tick += (u32)shift_hz/2;
--
BR
Liao, Chang
prev parent reply other threads:[~2024-02-26 11:34 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-25 23:25 [PATCH] time: Use div64_long() " Thorsten Blum
2024-02-26 3:28 ` Liao, Chang
2024-02-26 8:27 ` Thorsten Blum
2024-02-26 9:03 ` [PATCH v2] time: Use div64_ul() " Thorsten Blum
2024-02-26 11:34 ` Liao, Chang [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=c48aa5ff-8bce-52d7-6f52-ec18b74620d7@huawei.com \
--to=liaochang1@huawei.com \
--cc=anna-maria@linutronix.de \
--cc=frederic@kernel.org \
--cc=jstultz@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=thorsten.blum@toblux.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®