aboutsummaryrefslogtreecommitdiffstats
path: root/samples/rust/rust_driver_pci.rs
diff options
context:
space:
mode:
authorAlice Ryhl <[email protected]>2025-03-03 08:45:16 +0000
committerMiguel Ojeda <[email protected]>2025-03-09 19:52:46 +0000
commitfc2f191f850d9a2fb1b78c51d49076e60fb42c49 (patch)
treece891a7d8af47e95aa5d9c3dbcf6ef9a484be5da /samples/rust/rust_driver_pci.rs
parentprint: use new #[export] macro for rust_fmt_argument (diff)
downloadkernel-fc2f191f850d9a2fb1b78c51d49076e60fb42c49.tar.gz
kernel-fc2f191f850d9a2fb1b78c51d49076e60fb42c49.zip
panic_qr: use new #[export] macro
This validates at compile time that the signatures match what is in the header file. It highlights one annoyance with the compile-time check, which is that it can only be used with functions marked unsafe. If the function is not unsafe, then this error is emitted: error[E0308]: `if` and `else` have incompatible types --> <linux>/drivers/gpu/drm/drm_panic_qr.rs:987:19 | 986 | #[export] | --------- expected because of this 987 | pub extern "C" fn drm_panic_qr_max_data_size(version: u8, url_len: usize) -> usize { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ expected unsafe fn, found safe fn | = note: expected fn item `unsafe extern "C" fn(_, _) -> _ {kernel::bindings::drm_panic_qr_max_data_size}` found fn item `extern "C" fn(_, _) -> _ {drm_panic_qr_max_data_size}` The signature declarations are moved to a header file so it can be included in the Rust bindings helper, and the extern keyword is removed as it is unnecessary. Reviewed-by: Andreas Hindborg <[email protected]> Reviewed-by: Tamir Duberstein <[email protected]> Acked-by: Simona Vetter <[email protected]> Acked-by: Greg Kroah-Hartman <[email protected]> Signed-off-by: Alice Ryhl <[email protected]> Reviewed-by: Jocelyn Falempe <[email protected]> Link: https://lore.kernel.org/r/[email protected] [ Fixed `rustfmt`. Moved on top the unsafe requirement comment to follow the usual style, and slightly reworded it for clarity. Formatted bindings helper comment. - Miguel ] Signed-off-by: Miguel Ojeda <[email protected]>
Diffstat (limited to 'samples/rust/rust_driver_pci.rs')
0 files changed, 0 insertions, 0 deletions