Skip to content

Commit e47e8ef

Browse files
WhatAmISupposedToPutHerejannau
authored andcommitted
rust: device: WIP(?): Add get_drvdata for AOP series
Signed-off-by: Sasha Finkelstein <fnkl.kernel@gmail.com> Signed-off-by: Janne Grunau <j@jannau.net>
1 parent 94f7372 commit e47e8ef

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

rust/kernel/device.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,13 @@ impl<Ctx: DeviceContext> Device<Ctx> {
268268
}
269269
}
270270

271+
/// Returns the driver_data pointer.
272+
pub fn get_drvdata<T>(&self) -> *mut T {
273+
// SAFETY: dev_get_drvdata returns a field of the device,
274+
// pointer to which is valid by type invariant
275+
unsafe { bindings::dev_get_drvdata(self.as_raw()) as *mut T }
276+
}
277+
271278
/// Convert a raw C `struct device` pointer to a `&'a Device`.
272279
///
273280
/// # Safety

0 commit comments

Comments
 (0)