diff mbox

[v2] drm/drm_vma_manager.c: Remove useless goto statement

Message ID 20171101144458.5353-1-Liviu.Dudau@arm.com (mailing list archive)
State New, archived
Headers show

Commit Message

Liviu Dudau Nov. 1, 2017, 2:44 p.m. UTC
Commit db2395eccf08i ("drm: Convert drm_vma_manager to embedded
interval-tree in drm_mm") removed a line in drm_vma_offset_add() function that
makes checking the result of calling drm_mm_insert_node() and the goto
call redundant. Rework the function (as suggested by Chris Wilson) to
eliminate the need for the goto and associated label.

v2: rewrite function to remove all goto statements.

Fixes: db2395eccf08i ("drm: Convert drm_vma_manager to embedded interval-tree in drm_mm")
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Liviu Dudau <liviu.dudau@arm.com>
---
 drivers/gpu/drm/drm_vma_manager.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

Comments

Chris Wilson Nov. 1, 2017, 2:47 p.m. UTC | #1
Quoting Liviu Dudau (2017-11-01 14:44:58)
> Commit db2395eccf08i ("drm: Convert drm_vma_manager to embedded
> interval-tree in drm_mm") removed a line in drm_vma_offset_add() function that
> makes checking the result of calling drm_mm_insert_node() and the goto
> call redundant. Rework the function (as suggested by Chris Wilson) to
> eliminate the need for the goto and associated label.
> 
> v2: rewrite function to remove all goto statements.
> 
> Fixes: db2395eccf08i ("drm: Convert drm_vma_manager to embedded interval-tree in drm_mm")
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> Signed-off-by: Liviu Dudau <liviu.dudau@arm.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
-Chris
Daniel Vetter Nov. 2, 2017, 9:43 a.m. UTC | #2
On Wed, Nov 01, 2017 at 02:47:34PM +0000, Chris Wilson wrote:
> Quoting Liviu Dudau (2017-11-01 14:44:58)
> > Commit db2395eccf08i ("drm: Convert drm_vma_manager to embedded
> > interval-tree in drm_mm") removed a line in drm_vma_offset_add() function that
> > makes checking the result of calling drm_mm_insert_node() and the goto
> > call redundant. Rework the function (as suggested by Chris Wilson) to
> > eliminate the need for the goto and associated label.
> > 
> > v2: rewrite function to remove all goto statements.
> > 
> > Fixes: db2395eccf08i ("drm: Convert drm_vma_manager to embedded interval-tree in drm_mm")
> > Cc: Chris Wilson <chris@chris-wilson.co.uk>
> > Signed-off-by: Liviu Dudau <liviu.dudau@arm.com>
> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>

Applied to drm-misc-next.
-Daniel
diff mbox

Patch

diff --git a/drivers/gpu/drm/drm_vma_manager.c b/drivers/gpu/drm/drm_vma_manager.c
index 28f1226576f8c..23c749c05b5aa 100644
--- a/drivers/gpu/drm/drm_vma_manager.c
+++ b/drivers/gpu/drm/drm_vma_manager.c
@@ -203,21 +203,16 @@  EXPORT_SYMBOL(drm_vma_offset_lookup_locked);
 int drm_vma_offset_add(struct drm_vma_offset_manager *mgr,
 		       struct drm_vma_offset_node *node, unsigned long pages)
 {
-	int ret;
+	int ret = 0;
 
 	write_lock(&mgr->vm_lock);
 
-	if (drm_mm_node_allocated(&node->vm_node)) {
-		ret = 0;
-		goto out_unlock;
-	}
+	if (!drm_mm_node_allocated(&node->vm_node))
+		ret = drm_mm_insert_node(&mgr->vm_addr_space_mm,
+					 &node->vm_node, pages);
 
-	ret = drm_mm_insert_node(&mgr->vm_addr_space_mm, &node->vm_node, pages);
-	if (ret)
-		goto out_unlock;
-
-out_unlock:
 	write_unlock(&mgr->vm_lock);
+
 	return ret;
 }
 EXPORT_SYMBOL(drm_vma_offset_add);