mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-09-04 20:19:47 +08:00

A little late in the review of the faux device interface, we added the ability to specify a parent device when creating new faux devices - but this never got ported over to the rust bindings. So, let's add the missing argument now so we don't have to convert other users later down the line. Signed-off-by: Lyude Paul <lyude@redhat.com> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Link: https://lore.kernel.org/r/20250227193522.198344-1-lyude@redhat.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
30 lines
672 B
Rust
30 lines
672 B
Rust
// 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"), None)?;
|
|
|
|
dev_info!(reg.as_ref(), "Hello from faux device!\n");
|
|
|
|
Ok(Self { _reg: reg })
|
|
}
|
|
}
|