diff mbox

[1/6] drm: make drm_mm_init() return void

Message ID 1372703583-9550-2-git-send-email-dh.herrmann@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

David Herrmann July 1, 2013, 6:32 p.m. UTC
There is no reason to return "int" as this function never fails.
Furthermore, several drivers (ast, sis) already depend on this.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
---
 drivers/gpu/drm/drm_gem.c            | 8 ++------
 drivers/gpu/drm/drm_mm.c             | 4 +---
 drivers/gpu/drm/ttm/ttm_bo.c         | 6 +-----
 drivers/gpu/drm/ttm/ttm_bo_manager.c | 8 +-------
 include/drm/drm_mm.h                 | 6 +++---
 5 files changed, 8 insertions(+), 24 deletions(-)

Comments

Daniel Vetter July 1, 2013, 7:22 p.m. UTC | #1
On Mon, Jul 01, 2013 at 08:32:58PM +0200, David Herrmann wrote:
> There is no reason to return "int" as this function never fails.
> Furthermore, several drivers (ast, sis) already depend on this.
> 
> Signed-off-by: David Herrmann <dh.herrmann@gmail.com>

Back when I've reworked drm_mm I was still a rookie and didn't want to
touch all drivers, hence why I've left the int return type. Good riddance
to that!

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> ---
>  drivers/gpu/drm/drm_gem.c            | 8 ++------
>  drivers/gpu/drm/drm_mm.c             | 4 +---
>  drivers/gpu/drm/ttm/ttm_bo.c         | 6 +-----
>  drivers/gpu/drm/ttm/ttm_bo_manager.c | 8 +-------
>  include/drm/drm_mm.h                 | 6 +++---
>  5 files changed, 8 insertions(+), 24 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
> index cf919e3..88f0322 100644
> --- a/drivers/gpu/drm/drm_gem.c
> +++ b/drivers/gpu/drm/drm_gem.c
> @@ -108,12 +108,8 @@ drm_gem_init(struct drm_device *dev)
>  		return -ENOMEM;
>  	}
>  
> -	if (drm_mm_init(&mm->offset_manager, DRM_FILE_PAGE_OFFSET_START,
> -			DRM_FILE_PAGE_OFFSET_SIZE)) {
> -		drm_ht_remove(&mm->offset_hash);
> -		kfree(mm);
> -		return -ENOMEM;
> -	}
> +	drm_mm_init(&mm->offset_manager, DRM_FILE_PAGE_OFFSET_START,
> +		    DRM_FILE_PAGE_OFFSET_SIZE);
>  
>  	return 0;
>  }
> diff --git a/drivers/gpu/drm/drm_mm.c b/drivers/gpu/drm/drm_mm.c
> index 07cf99c..7917729 100644
> --- a/drivers/gpu/drm/drm_mm.c
> +++ b/drivers/gpu/drm/drm_mm.c
> @@ -669,7 +669,7 @@ int drm_mm_clean(struct drm_mm * mm)
>  }
>  EXPORT_SYMBOL(drm_mm_clean);
>  
> -int drm_mm_init(struct drm_mm * mm, unsigned long start, unsigned long size)
> +void drm_mm_init(struct drm_mm * mm, unsigned long start, unsigned long size)
>  {
>  	INIT_LIST_HEAD(&mm->hole_stack);
>  	INIT_LIST_HEAD(&mm->unused_nodes);
> @@ -690,8 +690,6 @@ int drm_mm_init(struct drm_mm * mm, unsigned long start, unsigned long size)
>  	list_add_tail(&mm->head_node.hole_stack, &mm->hole_stack);
>  
>  	mm->color_adjust = NULL;
> -
> -	return 0;
>  }
>  EXPORT_SYMBOL(drm_mm_init);
>  
> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> index 9b07b7d..e97c5a0 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> @@ -1619,9 +1619,7 @@ int ttm_bo_device_init(struct ttm_bo_device *bdev,
>  		goto out_no_sys;
>  
>  	bdev->addr_space_rb = RB_ROOT;
> -	ret = drm_mm_init(&bdev->addr_space_mm, file_page_offset, 0x10000000);
> -	if (unlikely(ret != 0))
> -		goto out_no_addr_mm;
> +	drm_mm_init(&bdev->addr_space_mm, file_page_offset, 0x10000000);
>  
>  	INIT_DELAYED_WORK(&bdev->wq, ttm_bo_delayed_workqueue);
>  	INIT_LIST_HEAD(&bdev->ddestroy);
> @@ -1635,8 +1633,6 @@ int ttm_bo_device_init(struct ttm_bo_device *bdev,
>  	mutex_unlock(&glob->device_list_mutex);
>  
>  	return 0;
> -out_no_addr_mm:
> -	ttm_bo_clean_mm(bdev, 0);
>  out_no_sys:
>  	return ret;
>  }
> diff --git a/drivers/gpu/drm/ttm/ttm_bo_manager.c b/drivers/gpu/drm/ttm/ttm_bo_manager.c
> index 9212494..e4367f9 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo_manager.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo_manager.c
> @@ -103,18 +103,12 @@ static int ttm_bo_man_init(struct ttm_mem_type_manager *man,
>  			   unsigned long p_size)
>  {
>  	struct ttm_range_manager *rman;
> -	int ret;
>  
>  	rman = kzalloc(sizeof(*rman), GFP_KERNEL);
>  	if (!rman)
>  		return -ENOMEM;
>  
> -	ret = drm_mm_init(&rman->mm, 0, p_size);
> -	if (ret) {
> -		kfree(rman);
> -		return ret;
> -	}
> -
> +	drm_mm_init(&rman->mm, 0, p_size);
>  	spin_lock_init(&rman->lock);
>  	man->priv = rman;
>  	return 0;
> diff --git a/include/drm/drm_mm.h b/include/drm/drm_mm.h
> index 88591ef..de92425 100644
> --- a/include/drm/drm_mm.h
> +++ b/include/drm/drm_mm.h
> @@ -275,9 +275,9 @@ static inline  struct drm_mm_node *drm_mm_search_free_in_range_color(
>  	return drm_mm_search_free_in_range_generic(mm, size, alignment, color,
>  						   start, end, best_match);
>  }
> -extern int drm_mm_init(struct drm_mm *mm,
> -		       unsigned long start,
> -		       unsigned long size);
> +extern void drm_mm_init(struct drm_mm *mm,
> +			unsigned long start,
> +			unsigned long size);
>  extern void drm_mm_takedown(struct drm_mm *mm);
>  extern int drm_mm_clean(struct drm_mm *mm);
>  extern int drm_mm_pre_get(struct drm_mm *mm);
> -- 
> 1.8.3.2
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie July 2, 2013, 3:47 a.m. UTC | #2
On Tue, Jul 2, 2013 at 5:22 AM, Daniel Vetter <daniel@ffwll.ch> wrote:
> On Mon, Jul 01, 2013 at 08:32:58PM +0200, David Herrmann wrote:
>> There is no reason to return "int" as this function never fails.
>> Furthermore, several drivers (ast, sis) already depend on this.
>>
>> Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
>
> Back when I've reworked drm_mm I was still a rookie and didn't want to
> touch all drivers, hence why I've left the int return type. Good riddance
> to that!
>
> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

Thanks, I've stuck this in -next as it looks like a nice cleanup I'd like now.

Dave.
diff mbox

Patch

diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
index cf919e3..88f0322 100644
--- a/drivers/gpu/drm/drm_gem.c
+++ b/drivers/gpu/drm/drm_gem.c
@@ -108,12 +108,8 @@  drm_gem_init(struct drm_device *dev)
 		return -ENOMEM;
 	}
 
-	if (drm_mm_init(&mm->offset_manager, DRM_FILE_PAGE_OFFSET_START,
-			DRM_FILE_PAGE_OFFSET_SIZE)) {
-		drm_ht_remove(&mm->offset_hash);
-		kfree(mm);
-		return -ENOMEM;
-	}
+	drm_mm_init(&mm->offset_manager, DRM_FILE_PAGE_OFFSET_START,
+		    DRM_FILE_PAGE_OFFSET_SIZE);
 
 	return 0;
 }
diff --git a/drivers/gpu/drm/drm_mm.c b/drivers/gpu/drm/drm_mm.c
index 07cf99c..7917729 100644
--- a/drivers/gpu/drm/drm_mm.c
+++ b/drivers/gpu/drm/drm_mm.c
@@ -669,7 +669,7 @@  int drm_mm_clean(struct drm_mm * mm)
 }
 EXPORT_SYMBOL(drm_mm_clean);
 
-int drm_mm_init(struct drm_mm * mm, unsigned long start, unsigned long size)
+void drm_mm_init(struct drm_mm * mm, unsigned long start, unsigned long size)
 {
 	INIT_LIST_HEAD(&mm->hole_stack);
 	INIT_LIST_HEAD(&mm->unused_nodes);
@@ -690,8 +690,6 @@  int drm_mm_init(struct drm_mm * mm, unsigned long start, unsigned long size)
 	list_add_tail(&mm->head_node.hole_stack, &mm->hole_stack);
 
 	mm->color_adjust = NULL;
-
-	return 0;
 }
 EXPORT_SYMBOL(drm_mm_init);
 
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 9b07b7d..e97c5a0 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -1619,9 +1619,7 @@  int ttm_bo_device_init(struct ttm_bo_device *bdev,
 		goto out_no_sys;
 
 	bdev->addr_space_rb = RB_ROOT;
-	ret = drm_mm_init(&bdev->addr_space_mm, file_page_offset, 0x10000000);
-	if (unlikely(ret != 0))
-		goto out_no_addr_mm;
+	drm_mm_init(&bdev->addr_space_mm, file_page_offset, 0x10000000);
 
 	INIT_DELAYED_WORK(&bdev->wq, ttm_bo_delayed_workqueue);
 	INIT_LIST_HEAD(&bdev->ddestroy);
@@ -1635,8 +1633,6 @@  int ttm_bo_device_init(struct ttm_bo_device *bdev,
 	mutex_unlock(&glob->device_list_mutex);
 
 	return 0;
-out_no_addr_mm:
-	ttm_bo_clean_mm(bdev, 0);
 out_no_sys:
 	return ret;
 }
diff --git a/drivers/gpu/drm/ttm/ttm_bo_manager.c b/drivers/gpu/drm/ttm/ttm_bo_manager.c
index 9212494..e4367f9 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_manager.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_manager.c
@@ -103,18 +103,12 @@  static int ttm_bo_man_init(struct ttm_mem_type_manager *man,
 			   unsigned long p_size)
 {
 	struct ttm_range_manager *rman;
-	int ret;
 
 	rman = kzalloc(sizeof(*rman), GFP_KERNEL);
 	if (!rman)
 		return -ENOMEM;
 
-	ret = drm_mm_init(&rman->mm, 0, p_size);
-	if (ret) {
-		kfree(rman);
-		return ret;
-	}
-
+	drm_mm_init(&rman->mm, 0, p_size);
 	spin_lock_init(&rman->lock);
 	man->priv = rman;
 	return 0;
diff --git a/include/drm/drm_mm.h b/include/drm/drm_mm.h
index 88591ef..de92425 100644
--- a/include/drm/drm_mm.h
+++ b/include/drm/drm_mm.h
@@ -275,9 +275,9 @@  static inline  struct drm_mm_node *drm_mm_search_free_in_range_color(
 	return drm_mm_search_free_in_range_generic(mm, size, alignment, color,
 						   start, end, best_match);
 }
-extern int drm_mm_init(struct drm_mm *mm,
-		       unsigned long start,
-		       unsigned long size);
+extern void drm_mm_init(struct drm_mm *mm,
+			unsigned long start,
+			unsigned long size);
 extern void drm_mm_takedown(struct drm_mm *mm);
 extern int drm_mm_clean(struct drm_mm *mm);
 extern int drm_mm_pre_get(struct drm_mm *mm);