Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] The newly introduced `expires_unchecked` method is private, making it inaccessible outside the module and defeating its documented purpose. --
--- Patch [4]: [PATCH 4/6] rust: hrtimer: restrict expires() to exclusive access --- commit eb28ef35be5861cd1df93f56841e97d8fd3ed101 Author: FUJITA Tomonori <[email protected]> rust: hrtimer: restrict expires() to exclusive access This commit changes HrTimer::expires() to require exclusive access via Pin<&mut Self> to prevent unsynchronized reads. It routes the read through a new C helper and introduces an unsafe expires_unchecked() method for contexts guaranteeing exclusive access externally. Link: https://lore.kernel.org/r/[email protected] > diff --git a/rust/kernel/time/hrtimer.rs b/rust/kernel/time/hrtimer.rs > index e6570a6162035..bdb6aaa228396 100644 > --- a/rust/kernel/time/hrtimer.rs > +++ b/rust/kernel/time/hrtimer.rs [ ... ] > @@ -567,27 +567,36 @@ pub fn forward_now(self: Pin<&mut Self>, interval: > Delta) -> u64 > self.forward(HrTimerInstant::<T>::now(), interval) > } > > + /// Return the time expiry for this [`HrTimer`]. > + /// > + /// # Safety > + /// > + /// The caller must have exclusive access to `self`. > + #[inline] > + unsafe fn expires_unchecked(&self) -> HrTimerInstant<T> [Severity: Medium] Will this method be usable by external modules or drivers? The commit message states the intent is to provide expires_unchecked() for contexts that can guarantee exclusive access by other means. Since it is missing the pub visibility modifier, it appears to be private to the hrtimer module and inaccessible to other Rust code that might need it. > + where > + T: HasHrTimer<T>, > + { > + // SAFETY: > + // - The C API requirements for this function are fulfilled by our > safety contract. > + // - Timers cannot have negative `ktime_t` values as their > expiration time. > + unsafe { > Instant::from_ktime(bindings::hrtimer_get_expires(Self::raw_get(self))) } > + } -- Sashiko AI review ยท https://sashiko.dev/#/patchset/[email protected]?part=4
