[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250116.210644.2053799984954195907.fujita.tomonori@gmail.com>
Date: Thu, 16 Jan 2025 21:06:44 +0900 (JST)
From: FUJITA Tomonori <fujita.tomonori@...il.com>
To: aliceryhl@...gle.com
Cc: fujita.tomonori@...il.com, linux-kernel@...r.kernel.org,
boqun.feng@...il.com, rust-for-linux@...r.kernel.org,
netdev@...r.kernel.org, andrew@...n.ch, hkallweit1@...il.com,
tmgross@...ch.edu, ojeda@...nel.org, alex.gaynor@...il.com,
gary@...yguo.net, bjorn3_gh@...tonmail.com, benno.lossin@...ton.me,
a.hindborg@...sung.com, anna-maria@...utronix.de, frederic@...nel.org,
tglx@...utronix.de, arnd@...db.de, jstultz@...gle.com, sboyd@...nel.org,
mingo@...hat.com, peterz@...radead.org, juri.lelli@...hat.com,
vincent.guittot@...aro.org, dietmar.eggemann@....com, rostedt@...dmis.org,
bsegall@...gle.com, mgorman@...e.de, vschneid@...hat.com
Subject: Re: [PATCH v8 3/7] rust: time: Introduce Instant type
On Thu, 16 Jan 2025 10:32:45 +0100
Alice Ryhl <aliceryhl@...gle.com> wrote:
>> -impl Ktime {
>> - /// Create a `Ktime` from a raw `ktime_t`.
>> +impl Instant {
>> + /// Create a `Instant` from a raw `ktime_t`.
>> #[inline]
>> - pub fn from_raw(inner: bindings::ktime_t) -> Self {
>> + fn from_raw(inner: bindings::ktime_t) -> Self {
>> Self { inner }
>> }
>
> Please keep this function public.
Surely, your driver uses from_raw()?
>> /// Get the current time using `CLOCK_MONOTONIC`.
>> #[inline]
>> - pub fn ktime_get() -> Self {
>> + pub fn now() -> Self {
>> // SAFETY: It is always safe to call `ktime_get` outside of NMI context.
>> Self::from_raw(unsafe { bindings::ktime_get() })
>> }
>>
>> - /// Divide the number of nanoseconds by a compile-time constant.
>> #[inline]
>> - fn divns_constant<const DIV: i64>(self) -> i64 {
>> - self.to_ns() / DIV
>> - }
>> -
>> - /// Returns the number of nanoseconds.
>> - #[inline]
>> - pub fn to_ns(self) -> i64 {
>> - self.inner
>> - }
>> -
>> - /// Returns the number of milliseconds.
>> - #[inline]
>> - pub fn to_ms(self) -> i64 {
>> - self.divns_constant::<NSEC_PER_MSEC>()
>> + /// Return the amount of time elapsed since the `Instant`.
>> + pub fn elapsed(&self) -> Delta {
>
> Nit: This places the #[inline] marker before the documentation. Please
> move it after to be consistent.
Oops, I'll fix.
Powered by blists - more mailing lists