Rust for Linux List
 help / color / mirror / Atom feed
* [PATCH v4 0/2] rust: add u64 division helpers and fix the pwm_th1520 32-bit build
@ 2026-11-18 22:48 FUJITA Tomonori
  2026-11-18 22:48 ` [PATCH v4 1/2] rust: math: add div64_u64() and div64_u64_round_up() FUJITA Tomonori
  2026-11-18 22:48 ` [PATCH v4 2/2] pwm: th1520: Fix 32-bit build with COMPILE_TEST FUJITA Tomonori
  0 siblings, 2 replies; 6+ messages in thread
From: FUJITA Tomonori @ 2026-11-18 22:48 UTC (permalink / raw)
  To: fustini, guoren, ojeda, ukleinek, wefu
  Cc: a.hindborg, acourbot, aliceryhl, bjorn3_gh, boqun,
	chenhan0017.work, dakr, daniel.almeida, gary, linux-riscv, lossin,
	m.wilczynski, tamird, tmgross, work, linux-pwm, rust-for-linux,
	FUJITA Tomonori

From: FUJITA Tomonori <fujita.tomonori@gmail.com>

This series fixes the 32-bit build of the TH1520 PWM driver with
COMPILE_TEST.

Patch 1 adds a math module to the kernel crate with Rust versions of
div64_u64() and DIV64_U64_ROUND_UP(). Patch 2 uses them in the driver.

The driver only needs u64 by u64 division. It does not need a 128-bit
intermediate value like mul_u64_u64_div_u64().

Miguel, Uwe acked patch 2 and is fine with this series going through
the Rust tree.

chenhan's patch [1] also adds rust/kernel/math.rs, with signed
division helpers. Both use the same module header, so whichever
is applied later needs only a small rebase.

Tested with the doctests on x86_64 and 32-bit ARM QEMU.

[1] https://lore.kernel.org/rust-for-linux/20261031103206.24051-4-chenhan0017.work@gmail.com/

v4:
- Add #[track_caller] to both helpers (Alice)
- Check for a zero divisor only on 32-bit, and use the panic of `/` on
  64-bit (Alice)
- Add Uwe's Acked-by to patch 2
- Rebase on v7.4-rc3
v3: https://lore.kernel.org/rust-for-linux/20261030020209.3833766-1-tomo@flapping.org/
- Use div helpers instead of limiting COMPILE_TEST to 64BIT (Uwe)
- Add a math module with div64_u64() and div64_u64_round_up()
- Drop Cc: stable and the Reviewed-by tags, since the change is different
v2: https://lore.kernel.org/rust-for-linux/20260930101257.1649945-1-tomo@flapping.org/
- Fix a typo in the commit message
- Add Cc: stable, Reported-by and Closes tags
- Add Reviewed-by tags from Andreas and Gary
- Rebase on v7.3-rc5
v1: https://lore.kernel.org/all/20260929095612.1072417-1-tomo@flapping.org/

FUJITA Tomonori (2):
  rust: math: add div64_u64() and div64_u64_round_up()
  pwm: th1520: Fix 32-bit build with COMPILE_TEST

 drivers/pwm/pwm_th1520.rs |  8 +++--
 rust/kernel/lib.rs        |  1 +
 rust/kernel/math.rs       | 73 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 80 insertions(+), 2 deletions(-)
 create mode 100644 rust/kernel/math.rs


base-commit: aebb7274476403040d582c61478df8f4a7bf9cd3
-- 
2.43.0


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

end of thread, other threads:[~2026-11-18 23:23 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-18 22:48 [PATCH v4 0/2] rust: add u64 division helpers and fix the pwm_th1520 32-bit build FUJITA Tomonori
2026-11-18 22:48 ` [PATCH v4 1/2] rust: math: add div64_u64() and div64_u64_round_up() FUJITA Tomonori
2026-11-18 22:53   ` Danilo Krummrich
2026-11-18 23:23   ` Alice Ryhl
2026-11-18 22:48 ` [PATCH v4 2/2] pwm: th1520: Fix 32-bit build with COMPILE_TEST FUJITA Tomonori
2026-11-18 23:23   ` Alice Ryhl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox