| 1 |
// SPDX-License-Identifier: GPL-2.0-only |
| 2 |
|
| 3 |
//! Rust faux device sample. |
| 4 |
|
| 5 |
use kernel::{ |
| 6 |
faux, |
| 7 |
prelude::*, |
| 8 |
Module, // |
| 9 |
}; |
| 10 |
|
| 11 |
module! { |
| 12 |
type: SampleModule, |
| 13 |
name: "rust_faux_driver", |
| 14 |
authors: ["Lyude Paul"], |
| 15 |
description: "Rust faux device sample", |
| 16 |
license: "GPL", |
| 17 |
} |
| 18 |
|
| 19 |
struct SampleModule { |
| 20 |
_reg: faux::Registration, |
| 21 |
} |
| 22 |
|
| 23 |
impl Module for SampleModule { |
| 24 |
fn init(_module: &'static ThisModule) -> Result<Self> { |
| 25 |
pr_info!("Initialising Rust Faux Device Sample\n"); |
| 26 |
|
| 27 |
let reg = faux::Registration::new(c"rust-faux-sample-device", None)?; |
| 28 |
|
| 29 |
dev_info!(reg, "Hello from faux device!\n"); |
| 30 |
|
| 31 |
Ok(Self { _reg: reg }) |
| 32 |
} |
| 33 |
} |