Skip to contentSkip to conversation

drm/ttm: fix condition (and vs or)

PATCH In review Dan Carpenter 4 participants 4 messages Dec 8, 2011

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/ttm: fix condition (and vs or)

The "if (!p && !p->dev)" condition isn't right because || was intended instead of &&. But actually, "p" is the list cursor and so it's always non-NULL and we can just remove that bit. We can remove the another similar check as well.

drivers/gpu/drm/ttm/ttm_page_alloc_dma.c +3 -5
index 6678abc..1cf4c2c 100644
@@ -930,10 +930,8 @@ static int ttm_dma_pool_get_num_unused_pages(void)
 	unsigned total = 0;
 
 	mutex_lock(&_manager->lock);
-	list_for_each_entry(p, &_manager->pools, pools) {
-		if (p)
-			total += p->pool->npages_free;
-	}
+	list_for_each_entry(p, &_manager->pools, pools)
+		total += p->pool->npages_free;
 	mutex_unlock(&_manager->lock);
 	return total;
 }
@@ -1023,7 +1021,7 @@ static int ttm_dma_pool_mm_shrink(struct shrinker *shrink,
 	list_for_each_entry(p, &_manager->pools, pools) {
 		unsigned nr_free;
 
-		if (!p && !p->dev)
+		if (!p->dev)
 			continue;
 		if (shrink_pages = 0)
 			break;
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Dan Carpenter

The "if (!p && !p->dev)" condition isn't right because || was intended instead of &&. But actually, "p" is the list cursor and so it's always non-NULL and we can just remove that bit. We can remove the another similar check as well.

Quoted 31 lines
drivers/gpu/drm/ttm/ttm_page_alloc_dma.c +3 -5
index 6678abc..1cf4c2c 100644
@@ -930,10 +930,8 @@ static int ttm_dma_pool_get_num_unused_pages(void)
 	unsigned total = 0;
 
 	mutex_lock(&_manager->lock);
-	list_for_each_entry(p, &_manager->pools, pools) {
-		if (p)
-			total += p->pool->npages_free;
-	}
+	list_for_each_entry(p, &_manager->pools, pools)
+		total += p->pool->npages_free;
 	mutex_unlock(&_manager->lock);
 	return total;
 }
@@ -1023,7 +1021,7 @@ static int ttm_dma_pool_mm_shrink(struct shrinker *shrink,
 	list_for_each_entry(p, &_manager->pools, pools) {
 		unsigned nr_free;
 
-		if (!p && !p->dev)
+		if (!p->dev)
 			continue;
 		if (shrink_pages == 0)
 			break;

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#2 lore raw
Quoted 3 lines · Jerome Glisse
Quoted 2 lines · Dan Carpenter

The "if (!p && !p->dev)" condition isn't right because || was intended instead of &&. But actually, "p" is the list cursor and so it's always

Duh!

Quoted 5 lines
Quoted 4 lines

non-NULL and we can just remove that bit. We can remove the another similar check as well.

And Acked-by me.

Jerome, since you have the patches (And are thinking to send a GIT PULL to Dave) in your tree, could you include this patch in your queue?

Or would you prefer I do at some other point of time?

Thanks!

Quoted 35 lines
Quoted 27 lines
drivers/gpu/drm/ttm/ttm_page_alloc_dma.c +3 -5
index 6678abc..1cf4c2c 100644
@@ -930,10 +930,8 @@ static int ttm_dma_pool_get_num_unused_pages(void)
 	unsigned total = 0;
 
 	mutex_lock(&_manager->lock);
-	list_for_each_entry(p, &_manager->pools, pools) {
-		if (p)
-			total += p->pool->npages_free;
-	}
+	list_for_each_entry(p, &_manager->pools, pools)
+		total += p->pool->npages_free;
 	mutex_unlock(&_manager->lock);
 	return total;
 }
@@ -1023,7 +1021,7 @@ static int ttm_dma_pool_mm_shrink(struct shrinker *shrink,
 	list_for_each_entry(p, &_manager->pools, pools) {
 		unsigned nr_free;
 
-		if (!p && !p->dev)
+		if (!p->dev)
 			continue;
 		if (shrink_pages = 0)
 			break;
Quoted 4 lines

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#3 lore raw

----- Original Message -----

Quoted 19 lines

From: "Konrad Rzeszutek Wilk" <[email protected]>
To: "Jerome Glisse" <[email protected]>
Cc: [email protected], "Jerome Glisse" <[email protected]>, [email protected], "Thomas Hellstrom" <[email protected]>, "Dan Carpenter" <[email protected]>
Sent: Thursday, 8 December, 2011 4:53:34 PM
Subject: Re: [patch] drm/ttm: fix condition (and vs or)

Quoted 5 lines · Jerome Glisse
Quoted 4 lines · Dan Carpenter

The "if (!p && !p->dev)" condition isn't right because || was intended
instead of &&. But actually, "p" is the list cursor and so it's always

Duh!

Quoted 4 lines
Quoted 4 lines

non-NULL and we can just remove that bit. We can remove the another
similar check as well.

Quoted 9 lines
Quoted 2 lines
Quoted 1 line

And Acked-by me.

Jerome, since you have the patches (And are thinking to send a GIT PULL
to Dave) in your tree, could you include this patch in your queue?

I've taken the TTM changes into drm-next already, just reviewing the radeon stuff.

But if that appeared on top in Jerome's tree I can steal it.

Dave.