summaryrefslogtreecommitdiffstats
path: root/rust/kernel/platform.rs
diff options
context:
space:
mode:
authorAlice Ryhl <aliceryhl@google.com>2025-03-03 08:45:16 +0000
committerMiguel Ojeda <ojeda@kernel.org>2025-03-09 20:52:46 +0100
commitfc2f191f850d9a2fb1b78c51d49076e60fb42c49 (patch)
treece891a7d8af47e95aa5d9c3dbcf6ef9a484be5da /rust/kernel/platform.rs
parent92d2873bedf33974b04530215692705185ec6572 (diff)
downloadlinux-stable-fc2f191f850d9a2fb1b78c51d49076e60fb42c49.tar.gz
linux-stable-fc2f191f850d9a2fb1b78c51d49076e60fb42c49.tar.bz2
linux-stable-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 <a.hindborg@kernel.org> Reviewed-by: Tamir Duberstein <tamird@gmail.com> Acked-by: Simona Vetter <simona.vetter@ffwll.ch> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Alice Ryhl <aliceryhl@google.com> Reviewed-by: Jocelyn Falempe <jfalempe@redhat.com> Link: https://lore.kernel.org/r/20250303-export-macro-v3-5-41fbad85a27f@google.com [ 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 <ojeda@kernel.org>
Diffstat (limited to 'rust/kernel/platform.rs')
0 files changed, 0 insertions, 0 deletions