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/armada/armada_gem.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/armada/armada_gem.c 
b/drivers/gpu/drm/armada/armada_gem.c
index da7335cbe82d..19f0ed6164c5 100644
--- a/drivers/gpu/drm/armada/armada_gem.c
+++ b/drivers/gpu/drm/armada/armada_gem.c
@@ -502,18 +502,11 @@ armada_gem_prime_import(struct drm_device *dev, struct 
dma_buf *buf)
 {
        struct dma_buf_attachment *attach;
        struct armada_gem_object *dobj;
+       struct drm_gem_object *obj;
 
-       if (buf->ops == &armada_gem_prime_dmabuf_ops) {
-               struct drm_gem_object *obj = buf->priv;
-               if (obj->dev == dev) {
-                       /*
-                        * Importing our own dmabuf(s) increases the
-                        * refcount on the gem object itself.
-                        */
-                       drm_gem_object_get(obj);
-                       return obj;
-               }
-       }
+       obj = drm_gem_prime_self_import(dev, buf, &armada_gem_prime_dmabuf_ops);
+       if (obj)
+               return obj;
 
        attach = dma_buf_attach(buf, dev->dev);
        if (IS_ERR(attach))
-- 
2.43.0

Reply via email to