diff options
| author | Lyude Paul <[email protected]> | 2025-05-13 22:09:55 +0000 |
|---|---|---|
| committer | Danilo Krummrich <[email protected]> | 2025-05-13 22:26:16 +0000 |
| commit | 36b1ccbfa0c2f45fae3e07bf66e40d7fd6704874 (patch) | |
| tree | b489cf0e27a46cfff5209e6245d2c893a57ce426 /drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | |
| parent | rust: drm: gem: Use NonNull for Object::dev (diff) | |
| download | kernel-36b1ccbfa0c2f45fae3e07bf66e40d7fd6704874.tar.gz kernel-36b1ccbfa0c2f45fae3e07bf66e40d7fd6704874.zip | |
rust: drm: gem: Refactor IntoGEMObject::from_gem_obj() to as_ref()
There's a few issues with this function, mainly:
* This function -probably- should have been unsafe from the start. Pointers
are not always necessarily valid, but you want a function that does
field-projection for a pointer that can travel outside of the original
struct to be unsafe, at least if I understand properly.
* *mut Self is not terribly useful in this context, the majority of uses of
from_gem_obj() grab a *mut Self and then immediately convert it into a
&'a Self. It also goes against the ffi conventions we've set in the rest
of the kernel thus far.
* from_gem_obj() also doesn't follow the naming conventions in the rest of
the DRM bindings at the moment, as_ref() would be a better name.
So, let's:
* Make from_gem_obj() unsafe
* Convert it to return &'a Self
* Rename it to as_ref()
* Update all call locations
Signed-off-by: Lyude Paul <[email protected]>
Reviewed-by: Daniel Almeida <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Danilo Krummrich <[email protected]>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c')
0 files changed, 0 insertions, 0 deletions
