Skip to content

Commit 2c61b8c

Browse files
dakrgregkh
authored andcommitted
firmware_loader: annotate doctests as no_run
The doctests of `Firmware` are compile-time only tests, since they require a proper `Device` and a valid path to a (firmware) blob in order to do something sane on runtime - we can't satisfy both of those requirements. Hence, configure the example as `no_run`. Unfortunately, the kernel's Rust build system can't consider the `no_run` attribute yet. Hence, for the meantime, wrap the example code into a new function and never actually call it. Fixes: de65828 ("rust: add firmware abstractions") Signed-off-by: Danilo Krummrich <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 997197b commit 2c61b8c

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

rust/kernel/firmware.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,18 @@ type FwFunc =
2626
///
2727
/// # Examples
2828
///
29-
/// ```
29+
/// ```no_run
3030
/// # use kernel::{c_str, device::Device, firmware::Firmware};
3131
///
32+
/// # fn no_run() -> Result<(), Error> {
3233
/// # // SAFETY: *NOT* safe, just for the example to get an `ARef<Device>` instance
3334
/// # let dev = unsafe { Device::from_raw(core::ptr::null_mut()) };
3435
///
35-
/// let fw = Firmware::request(c_str!("path/to/firmware.bin"), &dev).unwrap();
36+
/// let fw = Firmware::request(c_str!("path/to/firmware.bin"), &dev)?;
3637
/// let blob = fw.data();
38+
///
39+
/// # Ok(())
40+
/// # }
3741
/// ```
3842
pub struct Firmware(NonNull<bindings::firmware>);
3943

0 commit comments

Comments
 (0)