Skip to content

Commit 6e4043a

Browse files
author
Sven Van Asbroeck
committed
bcm2835_rng_rust: add devicetree matching
Devices described in the devicetree with the following `compatible` string will now match: `brcm,bcm2835-rng` Example devicetree .dts: ```dts &some_bus { rng@7e104000 { compatible = "brcm,bcm2835-rng"; reg = <0x7e104000 0x10>; }; rng@7e104040 { compatible = "brcm,bcm2835-rng"; reg = <0x7e104040 0x10>; }; }; ``` This will instantiate two hardware random-number generator devices. Signed-off-by: Sven Van Asbroeck <[email protected]>
1 parent fb3fdcb commit 6e4043a

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

drivers/char/hw_random/bcm2835_rng_rust.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
use alloc::boxed::Box;
99
use core::pin::Pin;
10+
use kernel::of::OfMatchTable;
1011
use kernel::prelude::*;
1112
use kernel::{cstr, platdev};
1213

@@ -24,7 +25,13 @@ struct RngModule {
2425

2526
impl KernelModule for RngModule {
2627
fn init() -> Result<Self> {
27-
let pdev = platdev::Registration::new_pinned(cstr!("bcm2835-rng-rust"), &THIS_MODULE)?;
28+
let of_match_tbl = OfMatchTable::new(&cstr!("brcm,bcm2835-rng"))?;
29+
30+
let pdev = platdev::Registration::new_pinned(
31+
cstr!("bcm2835-rng-rust"),
32+
Some(of_match_tbl),
33+
&THIS_MODULE,
34+
)?;
2835

2936
Ok(RngModule { _pdev: pdev })
3037
}

0 commit comments

Comments
 (0)