提交 0929deca 编写于 作者: J Joerg Roedel

iommu/s390: Use iommu_group_get_for_dev() in s390_iommu_add_device()

The iommu_group_get_for_dev() function also attaches the
device to its group, so this code doesn't need to be in the
iommu driver.

Further by using this function the driver can make use of
default domains in the future.
Reviewed-by: NGerald Schaefer <gerald.schaefer@de.ibm.com>
Signed-off-by: NJoerg Roedel <jroedel@suse.de>
上级 c0bc126f
...@@ -165,20 +165,14 @@ static void s390_iommu_detach_device(struct iommu_domain *domain, ...@@ -165,20 +165,14 @@ static void s390_iommu_detach_device(struct iommu_domain *domain,
static int s390_iommu_add_device(struct device *dev) static int s390_iommu_add_device(struct device *dev)
{ {
struct iommu_group *group; struct iommu_group *group = iommu_group_get_for_dev(dev);
int rc;
group = iommu_group_get(dev); if (IS_ERR(group))
if (!group) { return PTR_ERR(group);
group = iommu_group_alloc();
if (IS_ERR(group))
return PTR_ERR(group);
}
rc = iommu_group_add_device(group, dev);
iommu_group_put(group); iommu_group_put(group);
return rc; return 0;
} }
static void s390_iommu_remove_device(struct device *dev) static void s390_iommu_remove_device(struct device *dev)
...@@ -344,6 +338,7 @@ static struct iommu_ops s390_iommu_ops = { ...@@ -344,6 +338,7 @@ static struct iommu_ops s390_iommu_ops = {
.iova_to_phys = s390_iommu_iova_to_phys, .iova_to_phys = s390_iommu_iova_to_phys,
.add_device = s390_iommu_add_device, .add_device = s390_iommu_add_device,
.remove_device = s390_iommu_remove_device, .remove_device = s390_iommu_remove_device,
.device_group = generic_device_group,
.pgsize_bitmap = S390_IOMMU_PGSIZES, .pgsize_bitmap = S390_IOMMU_PGSIZES,
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册