summaryrefslogtreecommitdiff
path: root/samples/rust/rust_driver_faux.rs
diff options
context:
space:
mode:
authorAlexei Starovoitov <ast@kernel.org>2025-02-20 18:10:24 -0800
committerAlexei Starovoitov <ast@kernel.org>2025-02-20 18:13:57 -0800
commitbd4319b6c2b36aa5c6534aec1dbe16921ec960ef (patch)
treeaec6748a7c59ea9a3ebb2c543b2e7f0ce2806b91 /samples/rust/rust_driver_faux.rs
parent7042882abc04c720ea798198981943502f4221fe (diff)
parent319fc77f8f45a1b3dba15b0cc1a869778fd222f7 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf bpf-6.14-rc4
Cross-merge bpf fixes after downstream PR (bpf-6.14-rc4). Minor conflict: kernel/bpf/btf.c Adjacent changes: kernel/bpf/arena.c kernel/bpf/btf.c kernel/bpf/syscall.c kernel/bpf/verifier.c mm/memory.c Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'samples/rust/rust_driver_faux.rs')
-rw-r--r--samples/rust/rust_driver_faux.rs29
1 files changed, 29 insertions, 0 deletions
diff --git a/samples/rust/rust_driver_faux.rs b/samples/rust/rust_driver_faux.rs
new file mode 100644
index 000000000000..048c6cb98b29
--- /dev/null
+++ b/samples/rust/rust_driver_faux.rs
@@ -0,0 +1,29 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+//! Rust faux device sample.
+
+use kernel::{c_str, faux, prelude::*, Module};
+
+module! {
+ type: SampleModule,
+ name: "rust_faux_driver",
+ author: "Lyude Paul",
+ description: "Rust faux device sample",
+ license: "GPL",
+}
+
+struct SampleModule {
+ _reg: faux::Registration,
+}
+
+impl Module for SampleModule {
+ fn init(_module: &'static ThisModule) -> Result<Self> {
+ pr_info!("Initialising Rust Faux Device Sample\n");
+
+ let reg = faux::Registration::new(c_str!("rust-faux-sample-device"))?;
+
+ dev_info!(reg.as_ref(), "Hello from faux device!\n");
+
+ Ok(Self { _reg: reg })
+ }
+}