Skip to contentSkip to conversation

iommu/vsi: Use list_for_each_entry()

PATCH Applied Dan Carpenter 3 participants 3 messages May 20 – May 28

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

PATCH 1/1 iommu/vsi: Use list_for_each_entry()

Smatch complains about the NULL check on "iommu" because list_entry() can't be NULL. Clean up this code by using list_for_each_entry().

---
Untested, but it compiled on the first try (no typos!)

 drivers/iommu/vsi-iommu.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
drivers/iommu/vsi-iommu.c +2 -8
index 5d0721bd2c7a..9954ed414526 100644
@@ -366,15 +366,9 @@ static int vsi_iommu_map_iova(struct vsi_iommu_domain *vsi_domain, u32 *pte_addr
 static void vsi_iommu_flush_tlb(struct iommu_domain *domain)
 {
 	struct vsi_iommu_domain *vsi_domain = to_vsi_domain(domain);
-	struct list_head *pos;
-
-	list_for_each(pos, &vsi_domain->iommus) {
-		struct vsi_iommu *iommu;
-
-		iommu = list_entry(pos, struct vsi_iommu, node);
-		if (!iommu)
-			continue;
+	struct vsi_iommu *iommu;
 
+	list_for_each_entry(iommu, &vsi_domain->iommus, node) {
 		if (pm_runtime_get(iommu->dev) < 0)
 			continue;
 
Signature · 1 line
2.53.0
maintainer Reviewed-by on v1 1/1
#1 lore raw

Le 20/05/2026 à 08:00, Dan Carpenter a écrit :

Quoted 4 lines

Smatch complains about the NULL check on "iommu" because list_entry() can't be NULL. Clean up this code by using list_for_each_entry().

Quoted 28 lines

---
Untested, but it compiled on the first try (no typos!)

  drivers/iommu/vsi-iommu.c | 10 ++--------
  1 file changed, 2 insertions(+), 8 deletions(-)
drivers/iommu/vsi-iommu.c +2 -8
index 5d0721bd2c7a..9954ed414526 100644
@@ -366,15 +366,9 @@ static int vsi_iommu_map_iova(struct vsi_iommu_domain *vsi_domain, u32 *pte_addr
  static void vsi_iommu_flush_tlb(struct iommu_domain *domain)
  {
  	struct vsi_iommu_domain *vsi_domain = to_vsi_domain(domain);
-	struct list_head *pos;
-
-	list_for_each(pos, &vsi_domain->iommus) {
-		struct vsi_iommu *iommu;
-
-		iommu = list_entry(pos, struct vsi_iommu, node);
-		if (!iommu)
-			continue;
+	struct vsi_iommu *iommu;
 
+	list_for_each_entry(iommu, &vsi_domain->iommus, node) {
  		if (pm_runtime_get(iommu->dev) < 0)
  			continue;
 
maintainer Applied
#2 lore raw
In reply to Dan Carpenter
Quoted 2 lines · Dan Carpenter
 drivers/iommu/vsi-iommu.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

Applied, thanks.