Skip to content

Commit 611788a

Browse files
committed
rust: i2c: add function to retrieve Device out of a Client
Signed-off-by: Fabien Parent <[email protected]>
1 parent 15c3522 commit 611788a

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

rust/kernel/i2c.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
77
use crate::{
88
bindings,
9-
device::RawDevice,
9+
device::{Device, RawDevice},
1010
driver::{self, RawDeviceId},
1111
error::{from_result, to_result, Result},
1212
of,
@@ -213,6 +213,13 @@ impl Client {
213213
pub fn raw_client(&self) -> *mut bindings::i2c_client {
214214
self.ptr
215215
}
216+
217+
/// Returns the I2C client [`Device`] structure
218+
pub fn device(&self) -> Device {
219+
Device {
220+
ptr: self.raw_device(),
221+
}
222+
}
216223
}
217224

218225
unsafe impl RawDevice for Client {

0 commit comments

Comments
 (0)