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

2018-01-26 Thread Felix Kuehling
On 2018-01-26 01:29 PM, Tom St Denis wrote:
> Signed-off-by: Tom St Denis 
> ---
>  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, >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;
>  }
>  
>  /*

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


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

2018-01-26 Thread Tom St Denis
Signed-off-by: Tom St Denis 
---
 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, >dma_pools, pools) {
-   if (pool->type != type)
-   continue;
-   found = pool;
-   break;
+   if (pool->type == type)
+   return pool;
}
-   return found;
+   return NULL;
 }
 
 /*
-- 
2.14.3

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel