netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] ptp: ocp: Use DIV64_U64_ROUND_UP for rounding.
@ 2022-05-05 23:40 Jonathan Lemon
  2022-05-07  0:13 ` Vadim Fedorenko
  0 siblings, 1 reply; 2+ messages in thread
From: Jonathan Lemon @ 2022-05-05 23:40 UTC (permalink / raw)
  To: netdev; +Cc: richardcochran, kernel-team, davem, kuba, pabeni

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>
---
 drivers/ptp/ptp_ocp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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);
 	}
 
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net] ptp: ocp: Use DIV64_U64_ROUND_UP for rounding.
  2022-05-05 23:40 [PATCH net] ptp: ocp: Use DIV64_U64_ROUND_UP for rounding Jonathan Lemon
@ 2022-05-07  0:13 ` Vadim Fedorenko
  0 siblings, 0 replies; 2+ messages in thread
From: Vadim Fedorenko @ 2022-05-07  0:13 UTC (permalink / raw)
  To: Jonathan Lemon, netdev; +Cc: richardcochran, kernel-team, davem, kuba, pabeni

On 06.05.2022 00:40, Jonathan Lemon 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.
> 
> Fixes: 'b325af3cfab9 ("ptp: ocp: Add signal generators and update sysfs nodes")'
> Signed-off-by: Jonathan Lemon <jonathan.lemon@gmail.com>

Acked-by: Vadim Fedorenko <vfedorenko@novek.ru>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-05-07  0:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-05 23:40 [PATCH net] ptp: ocp: Use DIV64_U64_ROUND_UP for rounding Jonathan Lemon
2022-05-07  0:13 ` Vadim Fedorenko

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).