diff options
author | Alexandre Courbot <acourbot@nvidia.com> | 2025-06-24 21:59:19 +0900 |
---|---|---|
committer | Danilo Krummrich <dakr@kernel.org> | 2025-06-25 20:13:32 +0200 |
commit | 4092e1b41202ff39aad75a40a03ac1d318443670 (patch) | |
tree | 7e30fe8bf6d7270edad2e8fed269ea1db0ecfea4 /drivers/gpu/nova-core/util.rs | |
parent | d612799de75b0cddbc00e2261355377493d74d45 (diff) |
gpu: nova-core: replace `Duration` with `Delta`
The kernel's `Delta` type was not available when the `wait_on` function
was introduced. Now that it is, switch to it as it is more compact than
`Duration` and cannot panic.
Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
Link: https://lore.kernel.org/r/20250624-nova-delta-v1-1-b37d75a593ac@nvidia.com
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
Diffstat (limited to 'drivers/gpu/nova-core/util.rs')
-rw-r--r-- | drivers/gpu/nova-core/util.rs | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/drivers/gpu/nova-core/util.rs b/drivers/gpu/nova-core/util.rs index 5cafe0797cd6..64fb13760764 100644 --- a/drivers/gpu/nova-core/util.rs +++ b/drivers/gpu/nova-core/util.rs @@ -1,9 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 -use core::time::Duration; - use kernel::prelude::*; -use kernel::time::Instant; +use kernel::time::{Delta, Instant}; pub(crate) const fn to_lowercase_bytes<const N: usize>(s: &str) -> [u8; N] { let src = s.as_bytes(); @@ -34,7 +32,7 @@ pub(crate) const fn const_bytes_to_str(bytes: &[u8]) -> &str { /// /// TODO[DLAY]: replace with `read_poll_timeout` once it is available. /// (https://lore.kernel.org/lkml/20250220070611.214262-8-fujita.tomonori@gmail.com/) -pub(crate) fn wait_on<R, F: Fn() -> Option<R>>(timeout: Duration, cond: F) -> Result<R> { +pub(crate) fn wait_on<R, F: Fn() -> Option<R>>(timeout: Delta, cond: F) -> Result<R> { let start_time = Instant::now(); loop { @@ -42,7 +40,7 @@ pub(crate) fn wait_on<R, F: Fn() -> Option<R>>(timeout: Duration, cond: F) -> Re return Ok(ret); } - if start_time.elapsed().as_nanos() > timeout.as_nanos() as i64 { + if start_time.elapsed().as_nanos() > timeout.as_nanos() { return Err(ETIMEDOUT); } } |