[PATCH v3 1/3] rust: time: rename the rem_nanos() divisor
From: chenhan
Date: Sat Oct 17 2026 - 07:12:06 EST
The argument to rem_nanos() is the divisor, while self holds the
dividend. Rename the argument and correct the documentation. Drop the
architecture-specific implementation explanation from the public API
documentation; the argument type already states the divisor's width.
This does not change the function's type or behavior. It is a preparation
for documenting and checking the invalid divisors in the next patch.
Cc: stable@xxxxxxxxxxxxxxx # prerequisite for the Delta division/remainder fix
Assisted-by: LLM
Signed-off-by: chenhan <chenhan0017.work@xxxxxxxxx>
---
rust/kernel/time.rs | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/rust/kernel/time.rs b/rust/kernel/time.rs
index 5ae377e70dd8..16b44e82d2ac 100644
--- a/rust/kernel/time.rs
+++ b/rust/kernel/time.rs
@@ -614,16 +614,13 @@ pub fn to_jiffies_timeout(self) -> Delta<Jiffy> {
Delta::<Jiffy>::from_jiffies(jiffies)
}
- /// Return `self % dividend` where `dividend` is in nanoseconds.
- ///
- /// The kernel doesn't have any emulation for `s64 % s64` on 32 bit platforms, so this is
- /// limited to 32 bit dividends.
+ /// Return `self % divisor` where `divisor` is in nanoseconds.
#[inline]
- pub fn rem_nanos(self, dividend: i32) -> Self {
+ pub fn rem_nanos(self, divisor: i32) -> Self {
#[cfg(CONFIG_64BIT)]
{
Self {
- value: self.as_nanos() % i64::from(dividend),
+ value: self.as_nanos() % i64::from(divisor),
}
}
@@ -632,7 +629,7 @@ pub fn rem_nanos(self, dividend: i32) -> Self {
let mut rem = 0;
// SAFETY: `rem` is in the stack, so we can always provide a valid pointer to it.
- unsafe { bindings::div_s64_rem(self.as_nanos(), dividend, &mut rem) };
+ unsafe { bindings::div_s64_rem(self.as_nanos(), divisor, &mut rem) };
Self {
value: i64::from(rem),
--
2.34.1