[PATCH 14/15] clocksource: efi: use DIV_ROUND_DOWN_ULL for 64-bit devision

Ahmad Fatoum a.fatoum at barebox.org
Tue May 27 14:22:59 PDT 2025


From: Ahmad Fatoum <ahmad at a3f.at>

The denominator freq is 64-bit, but this worked out ok so far, because
the driver was only used on 64-bit systems. Now that we want to start
compiling it for 32-bit as well, make the division work there as well.

Note that nb_100ns is a valid result and will instruct the EFI firmware
to expire the timer at the next tick.

Signed-off-by: Ahmad Fatoum <a.fatoum at barebox.org>
---
 drivers/clocksource/efi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clocksource/efi.c b/drivers/clocksource/efi.c
index 1ac587a715f2..2f8bfdec489a 100644
--- a/drivers/clocksource/efi.c
+++ b/drivers/clocksource/efi.c
@@ -74,7 +74,7 @@ static int efi_cs_init(struct clocksource *cs)
 			BS->close_event(efi_cs_evt);
 			return -ENODEV;
 		}
-		nb_100ns = 10 * 1000 * 1000 / freq;
+		nb_100ns = DIV_ROUND_DOWN_ULL(10 * 1000 * 1000, freq);
 		pr_warn("EFI Event timer too slow freq = %llu Hz\n", freq);
 		efiret = BS->set_timer(efi_cs_evt, EFI_TIMER_PERIODIC, nb_100ns);
 		if (EFI_ERROR(efiret)) {
-- 
2.39.5




More information about the barebox mailing list