summaryrefslogtreecommitdiff
path: root/samples/rust/rust_driver_faux.rs
blob: 048c6cb98b29a14c7350aae8c4d602c79ce46924 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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 })
    }
}