Skip to content

Commit fa6f1ba

Browse files
author
Sven Van Asbroeck
committed
bcm2835_rng_rust: implement PlatformDriver trait
Implement this in the simplest possible way: by printing a `pr_info` log message on `probe()`/`remove()`. Signed-off-by: Sven Van Asbroeck <[email protected]>
1 parent 22fe6d2 commit fa6f1ba

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

drivers/char/hw_random/bcm2835_rng_rust.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use alloc::boxed::Box;
99
use core::pin::Pin;
1010
use kernel::of::OfMatchTable;
11+
use kernel::platdev::PlatformDriver;
1112
use kernel::prelude::*;
1213
use kernel::{c_str, platdev};
1314

@@ -19,6 +20,20 @@ module! {
1920
license: b"GPL v2",
2021
}
2122

23+
struct RngDriver;
24+
25+
impl PlatformDriver for RngDriver {
26+
fn probe(device_id: i32) -> Result {
27+
pr_info!("probing discovered hwrng with id {}\n", device_id);
28+
Ok(())
29+
}
30+
31+
fn remove(device_id: i32) -> Result {
32+
pr_info!("removing hwrng with id {}\n", device_id);
33+
Ok(())
34+
}
35+
}
36+
2237
struct RngModule {
2338
_pdev: Pin<Box<platdev::Registration>>,
2439
}
@@ -27,7 +42,7 @@ impl KernelModule for RngModule {
2742
fn init() -> Result<Self> {
2843
let of_match_tbl = OfMatchTable::new(&c_str!("brcm,bcm2835-rng"))?;
2944

30-
let pdev = platdev::Registration::new_pinned(
45+
let pdev = platdev::Registration::new_pinned::<RngDriver>(
3146
c_str!("bcm2835-rng-rust"),
3247
Some(of_match_tbl),
3348
&THIS_MODULE,

0 commit comments

Comments
 (0)