mirror of
https://github.com/torvalds/linux.git
synced 2026-06-04 20:46:48 +02:00
rust: drm: gem: Use NonNull for Object::dev
There is usually not much of a reason to use a raw pointer in a data struct, so move this to NonNull instead. Signed-off-by: Lyude Paul <lyude@redhat.com> Reviewed-by: Daniel Almeida <daniel.almeida@collabora.com> Link: https://lore.kernel.org/r/20250513221046.903358-2-lyude@redhat.com Signed-off-by: Danilo Krummrich <dakr@kernel.org>
This commit is contained in:
parent
61479ae38c
commit
6ee48aee8c
|
|
@ -177,7 +177,7 @@ impl<T> BaseObject for T where Self: crate::types::AlwaysRefCounted + IntoGEMObj
|
|||
#[pin_data]
|
||||
pub struct Object<T: DriverObject + Send + Sync> {
|
||||
obj: Opaque<bindings::drm_gem_object>,
|
||||
dev: *const drm::Device<T::Driver>,
|
||||
dev: NonNull<drm::Device<T::Driver>>,
|
||||
#[pin]
|
||||
data: T,
|
||||
}
|
||||
|
|
@ -212,7 +212,7 @@ pub fn new(dev: &drm::Device<T::Driver>, size: usize) -> Result<ARef<Self>> {
|
|||
data <- T::new(dev, size),
|
||||
// INVARIANT: The drm subsystem guarantees that the `struct drm_device` will live
|
||||
// as long as the GEM object lives.
|
||||
dev,
|
||||
dev: dev.into(),
|
||||
}),
|
||||
GFP_KERNEL,
|
||||
)?;
|
||||
|
|
@ -237,7 +237,7 @@ pub fn new(dev: &drm::Device<T::Driver>, size: usize) -> Result<ARef<Self>> {
|
|||
pub fn dev(&self) -> &drm::Device<T::Driver> {
|
||||
// SAFETY: The DRM subsystem guarantees that the `struct drm_device` will live as long as
|
||||
// the GEM object lives, hence the pointer must be valid.
|
||||
unsafe { &*self.dev }
|
||||
unsafe { self.dev.as_ref() }
|
||||
}
|
||||
|
||||
fn as_raw(&self) -> *mut bindings::drm_gem_object {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user