Skip to contentSkip to conversation

iommu: use iommu_group_ref_get to hold group reference

PATCH In review Yuan Can 2 participants 3 messages Aug 26, 2022 – Aug 30, 2022 IOMMU

lore
Share & tools
lore

Yuan Can

author
#0 lore raw

PATCH 1/1 iommu: use iommu_group_ref_get to hold group reference

Replace kobject_get with iommu_group_ref_get for better readability.

---
 drivers/iommu/iommu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/iommu.c +1 -1
index 780fb7071577..8e7f30f7188c 100644
@@ -903,7 +903,7 @@ int iommu_group_add_device(struct iommu_group *group, struct device *dev)
 		goto err_free_name;
 	}
 
-	kobject_get(group->devices_kobj);
+	iommu_group_ref_get(group);
 
 	dev->iommu_group = group;
 
Signature · 1 line
2.17.1
reviewer
#1 lore raw
Quoted 2 lines · Yuan Can

Replace kobject_get with iommu_group_ref_get for better readability.

I disagree, sorry. iommu_group_ref_get() is meant as a helper for drivers, and the core code uses the raw kobject internally everywhere else, including several other times within this function. Especially the raw kobject_put() in the cleanup path - in terms of readability I'd say it's actively harmful to obfuscate what that pairs with.

Thanks,
Robin.

Quoted 18 lines
---
  drivers/iommu/iommu.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/iommu.c +1 -1
index 780fb7071577..8e7f30f7188c 100644
@@ -903,7 +903,7 @@ int iommu_group_add_device(struct iommu_group *group, struct device *dev)
  		goto err_free_name;
  	}
 
-	kobject_get(group->devices_kobj);
+	iommu_group_ref_get(group);
 
  	dev->iommu_group = group;
 
author
#2 lore raw
Quoted 8 lines · Robin Murphy
Quoted 2 lines · Yuan Can

Replace kobject_get with iommu_group_ref_get for better readability.

I disagree, sorry. iommu_group_ref_get() is meant as a helper for drivers, and the core code uses the raw kobject internally everywhere else, including several other times within this function. Especially the raw kobject_put() in the cleanup path - in terms of readability I'd say it's actively harmful to obfuscate what that pairs with.

Thanks,
Robin.

Understood, thanks for your reply.

Best regards,

Yuan Can

Quoted 18 lines
Quoted 17 lines

---
  drivers/iommu/iommu.c | 2 +-

  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/iommu.c +1 -0
index 780fb7071577..8e7f30f7188c 100644
@@ -903,7 +903,7 @@ int iommu_group_add_device(struct iommu_group 
 *group, struct device *dev)
           goto err_free_name;
       }
   -    kobject_get(group->devices_kobj);
+    iommu_group_ref_get(group);
         dev->iommu_group = group;