mirror of
https://github.com/torvalds/linux.git
synced 2026-10-07 19:16:02 +02:00
Add a faux::Device type that wraps struct faux_device and implements AsBusDevice, enabling faux devices to be used as parent devices for subsystems that require a bus device, such as DRM. Update Registration to return &faux::Device<Bound> via AsRef. Reviewed-by: Alexandre Courbot <acourbot@nvidia.com> Tested-by: Deborah Brouwer <deborah.brouwer@collabora.com> Link: https://patch.msgid.link/20260628145406.2107056-4-dakr@kernel.org [ Drop redundant 'struct device' invariant; implied by valid struct faux_device. - Danilo ] Signed-off-by: Danilo Krummrich <dakr@kernel.org>
35 lines
704 B
Rust
35 lines
704 B
Rust
// SPDX-License-Identifier: GPL-2.0-only
|
|
|
|
//! Rust faux device sample.
|
|
|
|
use kernel::{
|
|
faux,
|
|
prelude::*,
|
|
Module, //
|
|
};
|
|
|
|
module! {
|
|
type: SampleModule,
|
|
name: "rust_faux_driver",
|
|
authors: ["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"rust-faux-sample-device", None)?;
|
|
let fdev = reg.as_ref();
|
|
|
|
dev_info!(fdev, "Hello from faux device!\n");
|
|
|
|
Ok(Self { _reg: reg })
|
|
}
|
|
}
|