summaryrefslogtreecommitdiffstats
path: root/rust/kernel
diff options
context:
space:
mode:
authorBenno Lossin <benno.lossin@proton.me>2023-10-26 22:19:33 +0200
committerMiguel Ojeda <ojeda@kernel.org>2023-12-14 20:14:01 +0100
commit88c2e1169f5f0c2ccdd0a001e4447a1b0da2b661 (patch)
treeca6c672d6c4925f404068061c49f294b2dfaacbc /rust/kernel
parentrust: macros: update 'paste!' macro to accept string literals (diff)
downloadlinux-88c2e1169f5f0c2ccdd0a001e4447a1b0da2b661.tar.xz
linux-88c2e1169f5f0c2ccdd0a001e4447a1b0da2b661.zip
rust: macros: improve `#[vtable]` documentation
Traits marked with `#[vtable]` need to provide default implementations for optional functions. The C side represents these with `NULL` in the vtable, so the default functions are never actually called. We do not want to replicate the default behavior from C in Rust, because that is not maintainable. Therefore we should use `build_error` in those default implementations. The error message for that is provided at `kernel::error::VTABLE_DEFAULT_ERROR`. Signed-off-by: Benno Lossin <benno.lossin@proton.me> Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com> Reviewed-by: Andreas Hindborg <a.hindborg@samsung.com> Reviewed-by: Alice Ryhl <aliceryhl@google.com> Reviewed-by: Finn Behrens <me@kloenk.dev> Link: https://lore.kernel.org/r/20231026201855.1497680-1-benno.lossin@proton.me [ Wrapped paragraph to 80 as requested and capitalized sentence. ] Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Diffstat (limited to 'rust/kernel')
-rw-r--r--rust/kernel/error.rs4
1 files changed, 4 insertions, 0 deletions
diff --git a/rust/kernel/error.rs b/rust/kernel/error.rs
index 032b64543953..376280b6a745 100644
--- a/rust/kernel/error.rs
+++ b/rust/kernel/error.rs
@@ -335,3 +335,7 @@ where
Err(e) => T::from(e.to_errno() as i16),
}
}
+
+/// Error message for calling a default function of a [`#[vtable]`](macros::vtable) trait.
+pub const VTABLE_DEFAULT_ERROR: &str =
+ "This function must not be called, see the #[vtable] documentation.";