Message ID | 20220506223739.1930-2-jonathan.lemon@gmail.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 4bd46bb037f8e1883dbe1fc9e79896b7f885db3f |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [net,RESEND] ptp: ocp: Use DIV64_U64_ROUND_UP for rounding. | expand |
Hello: This patch was applied to netdev/net.git (master) by Jakub Kicinski <kuba@kernel.org>: On Fri, 6 May 2022 15:37:39 -0700 you wrote: > The initial code used roundup() to round the starting time to > a multiple of a period. This generated an error on 32-bit > systems, so was replaced with DIV_ROUND_UP_ULL(). > > However, this truncates to 32-bits on a 64-bit system. Replace > with DIV64_U64_ROUND_UP() instead. > > [...] Here is the summary with links: - [net,RESEND] ptp: ocp: Use DIV64_U64_ROUND_UP for rounding. https://git.kernel.org/netdev/net/c/4bd46bb037f8 You are awesome, thank you!
diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c index 0feaa4b45317..dd45471f6780 100644 --- a/drivers/ptp/ptp_ocp.c +++ b/drivers/ptp/ptp_ocp.c @@ -1557,7 +1557,7 @@ ptp_ocp_signal_set(struct ptp_ocp *bp, int gen, struct ptp_ocp_signal *s) start_ns = ktime_set(ts.tv_sec, ts.tv_nsec) + NSEC_PER_MSEC; if (!s->start) { /* roundup() does not work on 32-bit systems */ - s->start = DIV_ROUND_UP_ULL(start_ns, s->period); + s->start = DIV64_U64_ROUND_UP(start_ns, s->period); s->start = ktime_add(s->start, s->phase); }
The initial code used roundup() to round the starting time to a multiple of a period. This generated an error on 32-bit systems, so was replaced with DIV_ROUND_UP_ULL(). However, this truncates to 32-bits on a 64-bit system. Replace with DIV64_U64_ROUND_UP() instead. Fixes: b325af3cfab9 ("ptp: ocp: Add signal generators and update sysfs nodes") Signed-off-by: Jonathan Lemon <jonathan.lemon@gmail.com> --- Resend to fix misquoted Fixes: tag --- drivers/ptp/ptp_ocp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)