diff mbox

[07/12] drm/ttm: Simplify ttm_dma_find_pool()

Message ID 20180126182911.20761-8-tom.stdenis@amd.com (mailing list archive)
State New, archived
Headers show

Commit Message

StDenis, Tom Jan. 26, 2018, 6:29 p.m. UTC
Signed-off-by: Tom St Denis <tom.stdenis@amd.com>
---
 drivers/gpu/drm/ttm/ttm_page_alloc_dma.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

Comments

Felix Kuehling Jan. 26, 2018, 7:26 p.m. UTC | #1
On 2018-01-26 01:29 PM, Tom St Denis wrote:
> Signed-off-by: Tom St Denis <tom.stdenis@amd.com>
> ---
>  drivers/gpu/drm/ttm/ttm_page_alloc_dma.c | 12 +++++-------
>  1 file changed, 5 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
> index 962838cfb1a3..579c4aedc17e 100644
> --- a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
> +++ b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
> @@ -680,10 +680,10 @@ static struct dma_pool *ttm_dma_pool_init(struct device *dev, gfp_t flags,
>  static struct dma_pool *ttm_dma_find_pool(struct device *dev,
>  					  enum pool_type type)
>  {
> -	struct dma_pool *pool, *tmp, *found = NULL;
> +	struct dma_pool *pool, *tmp;
>  
>  	if (type == IS_UNDEFINED)
> -		return found;
> +		return NULL;
>  
>  	/* NB: We iterate on the 'struct dev' which has no spinlock, but
>  	 * it does have a kref which we have taken. The kref is taken during
> @@ -697,12 +697,10 @@ static struct dma_pool *ttm_dma_find_pool(struct device *dev,
>  	 * driver so this function will not be called.
>  	 */
>  	list_for_each_entry_safe(pool, tmp, &dev->dma_pools, pools) {
> -		if (pool->type != type)
> -			continue;
> -		found = pool;
> -		break;
> +		if (pool->type == type)
> +			return pool;
>  	}

Now you could also remove the braces around the loop body, because it's
only a single statement.

Regards,
  Felix

> -	return found;
> +	return NULL;
>  }
>  
>  /*
diff mbox

Patch

diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
index 962838cfb1a3..579c4aedc17e 100644
--- a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
+++ b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
@@ -680,10 +680,10 @@  static struct dma_pool *ttm_dma_pool_init(struct device *dev, gfp_t flags,
 static struct dma_pool *ttm_dma_find_pool(struct device *dev,
 					  enum pool_type type)
 {
-	struct dma_pool *pool, *tmp, *found = NULL;
+	struct dma_pool *pool, *tmp;
 
 	if (type == IS_UNDEFINED)
-		return found;
+		return NULL;
 
 	/* NB: We iterate on the 'struct dev' which has no spinlock, but
 	 * it does have a kref which we have taken. The kref is taken during
@@ -697,12 +697,10 @@  static struct dma_pool *ttm_dma_find_pool(struct device *dev,
 	 * driver so this function will not be called.
 	 */
 	list_for_each_entry_safe(pool, tmp, &dev->dma_pools, pools) {
-		if (pool->type != type)
-			continue;
-		found = pool;
-		break;
+		if (pool->type == type)
+			return pool;
 	}
-	return found;
+	return NULL;
 }
 
 /*