Skip to content

Commit 4ac3849

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 4020266 commit 4ac3849

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
@@ -270,6 +270,13 @@ impl<Ctx: DeviceContext> Device<Ctx> {
270270
}
271271
}
272272

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

0 commit comments

Comments
 (0)