Skip to content

Commit 4db0e5f

Browse files
jgunthorpejoergroedel
authored andcommitted
iommu: Replace iommu_group_device_count() with list_count_nodes()
No reason to wrapper a standard function, just call the library directly. Reviewed-by: Lu Baolu <[email protected]> Reviewed-by: Kevin Tian <[email protected]> Tested-by: Heiko Stuebner <[email protected]> Tested-by: Niklas Schnelle <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Joerg Roedel <[email protected]>
1 parent 32261d1 commit 4db0e5f

1 file changed

Lines changed: 2 additions & 13 deletions

File tree

drivers/iommu/iommu.c

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,17 +1125,6 @@ void iommu_group_remove_device(struct device *dev)
11251125
}
11261126
EXPORT_SYMBOL_GPL(iommu_group_remove_device);
11271127

1128-
static int iommu_group_device_count(struct iommu_group *group)
1129-
{
1130-
struct group_device *entry;
1131-
int ret = 0;
1132-
1133-
list_for_each_entry(entry, &group->devices, list)
1134-
ret++;
1135-
1136-
return ret;
1137-
}
1138-
11391128
static int __iommu_group_for_each_dev(struct iommu_group *group, void *data,
11401129
int (*fn)(struct device *, void *))
11411130
{
@@ -2083,7 +2072,7 @@ int iommu_attach_device(struct iommu_domain *domain, struct device *dev)
20832072
*/
20842073
mutex_lock(&group->mutex);
20852074
ret = -EINVAL;
2086-
if (iommu_group_device_count(group) != 1)
2075+
if (list_count_nodes(&group->devices) != 1)
20872076
goto out_unlock;
20882077

20892078
ret = __iommu_attach_group(domain, group);
@@ -2114,7 +2103,7 @@ void iommu_detach_device(struct iommu_domain *domain, struct device *dev)
21142103

21152104
mutex_lock(&group->mutex);
21162105
if (WARN_ON(domain != group->domain) ||
2117-
WARN_ON(iommu_group_device_count(group) != 1))
2106+
WARN_ON(list_count_nodes(&group->devices) != 1))
21182107
goto out_unlock;
21192108
__iommu_group_set_core_domain(group);
21202109

0 commit comments

Comments
 (0)