Replace the open-coded self-import check with the drm core helper drm_gem_prime_self_import(), which performs the same ops and device match and returns the backing GEM object with a reference.
Assisted-by: GitHub-Copilot:claude-opus-4.8 Signed-off-by: Niranjana Vishwanathapura <[email protected]> --- drivers/gpu/drm/virtio/virtgpu_prime.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_prime.c b/drivers/gpu/drm/virtio/virtgpu_prime.c index 216c77cd0d21..6c337ff94f2e 100644 --- a/drivers/gpu/drm/virtio/virtgpu_prime.c +++ b/drivers/gpu/drm/virtio/virtgpu_prime.c @@ -339,17 +339,9 @@ struct drm_gem_object *virtgpu_gem_prime_import(struct drm_device *dev, struct drm_gem_object *obj; int ret; - if (buf->ops == &virtgpu_dmabuf_ops.ops) { - obj = buf->priv; - if (obj->dev == dev) { - /* - * Importing dmabuf exported from our own gem increases - * refcount on gem itself instead of f_count of dmabuf. - */ - drm_gem_object_get(obj); - return obj; - } - } + obj = drm_gem_prime_self_import(dev, buf, &virtgpu_dmabuf_ops.ops); + if (obj) + return obj; if (!vgdev->has_resource_blob) return drm_gem_prime_import(dev, buf); -- 2.43.0
