iommu/vt-d: Use list_for_each_safe() to simplify code
authorYijing Wang <wangyijing@huawei.com>
Tue, 20 May 2014 12:37:47 +0000 (20:37 +0800)
committerJoerg Roedel <jroedel@suse.de>
Fri, 4 Jul 2014 09:16:20 +0000 (11:16 +0200)
Use list_for_each_entry_safe() instead of list_entry()
to simplify code.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Joerg Roedel <jroedel@suse.de>
drivers/iommu/intel-iommu.c

index 51b6b77..4b0f1ac 100644 (file)
@@ -2102,13 +2102,11 @@ static inline void unlink_domain_info(struct device_domain_info *info)
 
 static void domain_remove_dev_info(struct dmar_domain *domain)
 {
-       struct device_domain_info *info;
+       struct device_domain_info *info, *tmp;
        unsigned long flags, flags2;
 
        spin_lock_irqsave(&device_domain_lock, flags);
-       while (!list_empty(&domain->devices)) {
-               info = list_entry(domain->devices.next,
-                       struct device_domain_info, link);
+       list_for_each_entry_safe(info, tmp, &domain->devices, link) {
                unlink_domain_info(info);
                spin_unlock_irqrestore(&device_domain_lock, flags);