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

Felix Kuehling felix.kuehling at amd.com
Fri Jan 26 19:26:38 UTC 2018


On 2018-01-26 01:29 PM, Tom St Denis wrote:
> Signed-off-by: Tom St Denis <tom.stdenis at 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;
>  }
>  
>  /*



More information about the amd-gfx mailing list