Skip to content

Commit

Permalink
补充 bcm2835_rust, i2c mod, device, platform, clk.
Browse files Browse the repository at this point in the history
bcm2835_rust: 部分修正,尝试填充probe函数。
i2c mod: 添加i2c_bcm2835quirks。
device, platform, clk.

Signed-off-by: Nostalgia <[email protected]>
  • Loading branch information
lvyuemeng committed Aug 4, 2024
1 parent 2775d2b commit 9159c00
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
11 changes: 0 additions & 11 deletions rust/kernel/i2c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,17 +124,6 @@ impl I2cAdapter {
to_result(ret)
}

pub unsafe fn i2c_set_adapdata<T>(&self, data: *mut T) {
unsafe {
bindings::dev_set_drvdata(self.0.get() as *mut bindings::i2c_adapter, data as *mut ())
}
}

pub fn i2c_add_adapter(&self) -> Result {
let ret = unsafe { bindings::i2c_add_adapter(self.0.get()) };
to_result(ret)
}

pub fn timeout(&self) -> usize {
unsafe { self.0.timeout as usize }
}
Expand Down
10 changes: 10 additions & 0 deletions rust/kernel/platform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
//!
//! C header: [`include/linux/platform_device.h`](../../../../include/linux/platform_device.h)
use core::ffi::c_void;

use crate::{
bindings,
device::{self, RawDevice},
Expand Down Expand Up @@ -200,6 +202,14 @@ impl Device {
}
}

pub unsafe fn platform_set_drvdata<T>(&self, data: *mut T) {
unsafe { bindings::platform_set_drvdata(self.ptr, data as *mut c_void) };
}

pub unsafe fn platform_get_drvdata<T>(&self) -> *mut T {
unsafe { bindings::platform_get_drvdata(self.ptr) as *mut T }
}

// TODO!
/*
pub fn get_and_ioremap_resource(&self, index: u32) -> Result<IoMem> {
Expand Down

0 comments on commit 9159c00

Please sign in to comment.