mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-01-17 20:10:49 +00:00
There are a few cases where we need the lowercase name of a given chipset, notably to resolve firmware files paths for dynamic loading or to build the module information. So far, we relied on a static `NAMES` array for the latter, and some CString hackery for the former. Replace both with a new `name` const method that returns the lowercase name of a chipset instance. We can generate it using the `paste!` macro. Using this method removes the need to create a `CString` when loading firmware, and lets us remove a couple of utility functions that now have no user. Acked-by: Danilo Krummrich <dakr@kernel.org> Link: https://lore.kernel.org/r/20250913-nova_firmware-v6-3-9007079548b0@nvidia.com Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
28 lines
844 B
Rust
28 lines
844 B
Rust
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
use kernel::prelude::*;
|
|
use kernel::time::{Delta, Instant, Monotonic};
|
|
|
|
/// Wait until `cond` is true or `timeout` elapsed.
|
|
///
|
|
/// When `cond` evaluates to `Some`, its return value is returned.
|
|
///
|
|
/// `Err(ETIMEDOUT)` is returned if `timeout` has been reached without `cond` evaluating to
|
|
/// `Some`.
|
|
///
|
|
/// 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: Delta, cond: F) -> Result<R> {
|
|
let start_time = Instant::<Monotonic>::now();
|
|
|
|
loop {
|
|
if let Some(ret) = cond() {
|
|
return Ok(ret);
|
|
}
|
|
|
|
if start_time.elapsed().as_nanos() > timeout.as_nanos() {
|
|
return Err(ETIMEDOUT);
|
|
}
|
|
}
|
|
}
|