Skip to content

Commit b136c6a

Browse files
author
Sven Van Asbroeck
committed
Add minimal platform driver for bcm2835-rng
Implements the bare minimum for a platform driver to register itself with the core. It won't be able to do anything, except show up in sysfs. Signed-off-by: Sven Van Asbroeck <[email protected]>
1 parent af25e4e commit b136c6a

File tree

3 files changed

+45
-0
lines changed

3 files changed

+45
-0
lines changed

drivers/char/hw_random/Kconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,19 @@ config HW_RANDOM_BCM2835
9898

9999
If unsure, say Y.
100100

101+
config HW_RANDOM_BCM2835_RUST
102+
tristate "Rust implementation of Broadcom BCM2835 Random Number Generator"
103+
depends on HAS_RUST && ARCH_BCM2835
104+
help
105+
This driver provides alternative Rust-based kernel-side support
106+
for the Random Number Generator hardware found on the Broadcom
107+
BCM2835 SoC.
108+
109+
To compile this driver as a module, choose M here: the
110+
module will be called bcm2835_rng_rust
111+
112+
If unsure, say N.
113+
101114
config HW_RANDOM_IPROC_RNG200
102115
tristate "Broadcom iProc/STB RNG200 support"
103116
depends on ARCH_BCM_IPROC || ARCH_BCM2835 || ARCH_BRCMSTB

drivers/char/hw_random/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ obj-$(CONFIG_HW_RANDOM_PSERIES) += pseries-rng.o
3131
obj-$(CONFIG_HW_RANDOM_POWERNV) += powernv-rng.o
3232
obj-$(CONFIG_HW_RANDOM_HISI) += hisi-rng.o
3333
obj-$(CONFIG_HW_RANDOM_BCM2835) += bcm2835-rng.o
34+
obj-$(CONFIG_HW_RANDOM_BCM2835_RUST) += bcm2835_rng_rust.o
3435
obj-$(CONFIG_HW_RANDOM_IPROC_RNG200) += iproc-rng200.o
3536
obj-$(CONFIG_HW_RANDOM_ST) += st-rng.o
3637
obj-$(CONFIG_HW_RANDOM_XGENE) += xgene-rng.o
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
3+
//! Broadcom BCM2835 Random Number Generator support.
4+
5+
#![no_std]
6+
#![feature(allocator_api, global_asm)]
7+
8+
use alloc::boxed::Box;
9+
use core::pin::Pin;
10+
use kernel::prelude::*;
11+
use kernel::{cstr, platdev};
12+
13+
module! {
14+
type: RngModule,
15+
name: b"bcm2835_rng_rust",
16+
author: b"Rust for Linux Contributors",
17+
description: b"BCM2835 Random Number Generator (RNG) driver",
18+
license: b"GPL v2",
19+
}
20+
21+
struct RngModule {
22+
_pdev: Pin<Box<platdev::Registration>>,
23+
}
24+
25+
impl KernelModule for RngModule {
26+
fn init() -> Result<Self> {
27+
let pdev = platdev::Registration::new_pinned(cstr!("bcm2835-rng-rust"), &THIS_MODULE)?;
28+
29+
Ok(RngModule { _pdev: pdev })
30+
}
31+
}

0 commit comments

Comments
 (0)