Skip to content

Commit 698f04d

Browse files
authored
Merge pull request #276 from TheSven73/rust-for-linux-pdev-pr2
Simple Rust driver that touches real hardware: PR 2/6
2 parents 1a73789 + c02591f commit 698f04d

File tree

7 files changed

+106
-294
lines changed

7 files changed

+106
-294
lines changed

Diff for: arch/arm/boot/dts/bcm2835-rpi-zero-w-rust.dts

-156
This file was deleted.

Diff for: arch/arm/boot/dts/bcm2836-rpi-2-b-rust.dts

-135
This file was deleted.

Diff for: drivers/char/hw_random/bcm2835_rng_rust.rs

+8-1
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
}

Diff for: rust/kernel/bindings_helper.h

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <linux/mm.h>
1515
#include <uapi/linux/android/binder.h>
1616
#include <linux/platform_device.h>
17+
#include <linux/of_platform.h>
1718

1819
// `bindgen` gets confused at certain things
1920
const gfp_t BINDINGS_GFP_KERNEL = GFP_KERNEL;

Diff for: rust/kernel/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ pub mod sysctl;
6363

6464
pub mod io_buffer;
6565
pub mod iov_iter;
66+
pub mod of;
6667
pub mod platdev;
6768
mod types;
6869
pub mod user_ptr;

0 commit comments

Comments
 (0)