]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
ptp: ocp: Use DIV64_U64_ROUND_UP for rounding.
authorJonathan Lemon <jonathan.lemon@gmail.com>
Fri, 6 May 2022 22:37:39 +0000 (15:37 -0700)
committerJakub Kicinski <kuba@kernel.org>
Tue, 10 May 2022 00:18:41 +0000 (17:18 -0700)
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>
Link: https://lore.kernel.org/r/20220506223739.1930-2-jonathan.lemon@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/ptp/ptp_ocp.c

index 0feaa4b453175b22abd933eeb38f6fba6e95bb62..dd45471f678083358a7b0b6c34770c1d04c47409 100644 (file)
@@ -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);
        }