From 9159c00f920b0dd6077e839fa795fde5548ff649 Mon Sep 17 00:00:00 2001 From: Nostalgia Date: Sun, 4 Aug 2024 17:28:51 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E5=85=85=20bcm2835=5Frust,=20i2c=20mo?= =?UTF-8?q?d,=20device,=20platform,=20clk.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit bcm2835_rust: 部分修正,尝试填充probe函数。 i2c mod: 添加i2c_bcm2835quirks。 device, platform, clk. Signed-off-by: Nostalgia --- rust/kernel/i2c.rs | 11 ----------- rust/kernel/platform.rs | 10 ++++++++++ 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/rust/kernel/i2c.rs b/rust/kernel/i2c.rs index df2b2d71c01ab9..d80582251e6ac8 100644 --- a/rust/kernel/i2c.rs +++ b/rust/kernel/i2c.rs @@ -124,17 +124,6 @@ impl I2cAdapter { to_result(ret) } - pub unsafe fn i2c_set_adapdata(&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 } } diff --git a/rust/kernel/platform.rs b/rust/kernel/platform.rs index bb6e69d1847387..6a200245d97d73 100644 --- a/rust/kernel/platform.rs +++ b/rust/kernel/platform.rs @@ -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}, @@ -200,6 +202,14 @@ impl Device { } } + pub unsafe fn platform_set_drvdata(&self, data: *mut T) { + unsafe { bindings::platform_set_drvdata(self.ptr, data as *mut c_void) }; + } + + pub unsafe fn platform_get_drvdata(&self) -> *mut T { + unsafe { bindings::platform_get_drvdata(self.ptr) as *mut T } + } + // TODO! /* pub fn get_and_ioremap_resource(&self, index: u32) -> Result {