diff mbox

[RFC,033/111] staging: etnaviv: convert shmem release to use etnaviv_gem_ops

Message ID 1427988653-754-34-git-send-email-l.stach@pengutronix.de (mailing list archive)
State New, archived
Headers show

Commit Message

Lucas Stach April 2, 2015, 3:29 p.m. UTC
From: Russell King <rmk+kernel@arm.linux.org.uk>

Convert the shmem object release to use the etnaviv_gem_ops release
method.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
 drivers/staging/etnaviv/etnaviv_gem.c | 25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)
diff mbox

Patch

diff --git a/drivers/staging/etnaviv/etnaviv_gem.c b/drivers/staging/etnaviv/etnaviv_gem.c
index 865b34b8496c..38e6b8ab3124 100644
--- a/drivers/staging/etnaviv/etnaviv_gem.c
+++ b/drivers/staging/etnaviv/etnaviv_gem.c
@@ -536,13 +536,7 @@  static void etnaviv_free_obj(struct drm_gem_object *obj)
 
 	drm_gem_free_mmap_offset(obj);
 
-	if (etnaviv_obj->ops) {
-		etnaviv_obj->ops->release(etnaviv_obj);
-	} else {
-		if (etnaviv_obj->vaddr)
-			vunmap(etnaviv_obj->vaddr);
-		put_pages(obj);
-	}
+	etnaviv_obj->ops->release(etnaviv_obj);
 
 	if (etnaviv_obj->resv == &etnaviv_obj->_resv)
 		reservation_object_fini(etnaviv_obj->resv);
@@ -550,6 +544,17 @@  static void etnaviv_free_obj(struct drm_gem_object *obj)
 	drm_gem_object_release(obj);
 }
 
+static void etnaviv_gem_shmem_release(struct etnaviv_gem_object *etnaviv_obj)
+{
+	if (etnaviv_obj->vaddr)
+		vunmap(etnaviv_obj->vaddr);
+	put_pages(&etnaviv_obj->base);
+}
+
+static const struct etnaviv_gem_ops etnaviv_gem_shmem_ops = {
+	.release = etnaviv_gem_shmem_release,
+};
+
 void etnaviv_gem_free_object(struct drm_gem_object *obj)
 {
 	struct drm_device *dev = obj->dev;
@@ -669,10 +674,12 @@  struct drm_gem_object *etnaviv_gem_new(struct drm_device *dev,
 		goto fail;
 
 	ret = 0;
-	if (flags & ETNA_BO_CMDSTREAM)
+	if (flags & ETNA_BO_CMDSTREAM) {
 		drm_gem_private_object_init(dev, obj, size);
-	else
+	} else {
+		to_etnaviv_bo(obj)->ops = &etnaviv_gem_shmem_ops;
 		ret = drm_gem_object_init(dev, obj, size);
+	}
 
 	if (ret)
 		goto fail;