[PATCH] dma-buf/sync_debug: convert to list_for_each_entry()

qiwuchen55 at gmail.com qiwuchen55 at gmail.com
Sun Feb 23 05:37:20 UTC 2020


From: chenqiwu <chenqiwu at xiaomi.com>

Convert list_for_each() to list_for_each_entry() to simplify code.

Signed-off-by: chenqiwu <chenqiwu at xiaomi.com>
---
 drivers/dma-buf/sync_debug.c | 19 ++++++-------------
 1 file changed, 6 insertions(+), 13 deletions(-)

diff --git a/drivers/dma-buf/sync_debug.c b/drivers/dma-buf/sync_debug.c
index 101394f..05cfeee 100644
--- a/drivers/dma-buf/sync_debug.c
+++ b/drivers/dma-buf/sync_debug.c
@@ -106,13 +106,12 @@ static void sync_print_fence(struct seq_file *s,
 
 static void sync_print_obj(struct seq_file *s, struct sync_timeline *obj)
 {
-	struct list_head *pos;
+	struct sync_pt *pt;
 
 	seq_printf(s, "%s: %d\n", obj->name, obj->value);
 
 	spin_lock_irq(&obj->lock);
-	list_for_each(pos, &obj->pt_list) {
-		struct sync_pt *pt = container_of(pos, struct sync_pt, link);
+	list_for_each_entry(pt, &obj->pt_list, link) {
 		sync_print_fence(s, &pt->base, false);
 	}
 	spin_unlock_irq(&obj->lock);
@@ -140,16 +139,13 @@ static void sync_print_sync_file(struct seq_file *s,
 
 static int sync_info_debugfs_show(struct seq_file *s, void *unused)
 {
-	struct list_head *pos;
+	struct sync_timeline *obj;
+	struct sync_file *sync_file;
 
 	seq_puts(s, "objs:\n--------------\n");
 
 	spin_lock_irq(&sync_timeline_list_lock);
-	list_for_each(pos, &sync_timeline_list_head) {
-		struct sync_timeline *obj =
-			container_of(pos, struct sync_timeline,
-				     sync_timeline_list);
-
+	list_for_each_entry(obj, &sync_timeline_list_head, sync_timeline_list) {
 		sync_print_obj(s, obj);
 		seq_putc(s, '\n');
 	}
@@ -158,10 +154,7 @@ static int sync_info_debugfs_show(struct seq_file *s, void *unused)
 	seq_puts(s, "fences:\n--------------\n");
 
 	spin_lock_irq(&sync_file_list_lock);
-	list_for_each(pos, &sync_file_list_head) {
-		struct sync_file *sync_file =
-			container_of(pos, struct sync_file, sync_file_list);
-
+	list_for_each_entry(sync_file, &sync_file_list_head, sync_file_list) {
 		sync_print_sync_file(s, sync_file);
 		seq_putc(s, '\n');
 	}
-- 
1.9.1



More information about the dri-devel mailing list