Skip to content

Commit 9e276d0

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 7cbe531 commit 9e276d0

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
@@ -356,6 +356,13 @@ impl<Ctx: DeviceContext> Device<Ctx> {
356356
}
357357
}
358358

359+
/// Returns the driver_data pointer.
360+
pub fn get_drvdata<T>(&self) -> *mut T {
361+
// SAFETY: dev_get_drvdata returns a field of the device,
362+
// pointer to which is valid by type invariant
363+
unsafe { bindings::dev_get_drvdata(self.as_raw()) as *mut T }
364+
}
365+
359366
/// Convert a raw C `struct device` pointer to a `&'a Device`.
360367
///
361368
/// # Safety

0 commit comments

Comments
 (0)