iommu/rockchip: Convert to probe/release_device() call-backs

Convert the Rockchip IOMMU driver to use the probe_device() and
release_device() call-backs of iommu_ops, so that the iommu core code
does the group and sysfs setup.

Signed-off-by: Joerg Roedel <jroedel@suse.de>
Link: https://lore.kernel.org/r/20200429133712.31431-26-joro@8bytes.org
Signed-off-by: Joerg Roedel <jroedel@suse.de>
This commit is contained in:
Joerg Roedel 2020-04-29 15:37:03 +02:00
parent bfe3bd493b
commit d826044324

View File

@ -1054,40 +1054,28 @@ static void rk_iommu_domain_free(struct iommu_domain *domain)
kfree(rk_domain);
}
static int rk_iommu_add_device(struct device *dev)
static struct iommu_device *rk_iommu_probe_device(struct device *dev)
{
struct iommu_group *group;
struct rk_iommu *iommu;
struct rk_iommudata *data;
struct rk_iommu *iommu;
data = dev->archdata.iommu;
if (!data)
return -ENODEV;
return ERR_PTR(-ENODEV);
iommu = rk_iommu_from_dev(dev);
group = iommu_group_get_for_dev(dev);
if (IS_ERR(group))
return PTR_ERR(group);
iommu_group_put(group);
iommu_device_link(&iommu->iommu, dev);
data->link = device_link_add(dev, iommu->dev,
DL_FLAG_STATELESS | DL_FLAG_PM_RUNTIME);
return 0;
return &iommu->iommu;
}
static void rk_iommu_remove_device(struct device *dev)
static void rk_iommu_release_device(struct device *dev)
{
struct rk_iommu *iommu;
struct rk_iommudata *data = dev->archdata.iommu;
iommu = rk_iommu_from_dev(dev);
device_link_del(data->link);
iommu_device_unlink(&iommu->iommu, dev);
iommu_group_remove_device(dev);
}
static struct iommu_group *rk_iommu_device_group(struct device *dev)
@ -1126,8 +1114,8 @@ static const struct iommu_ops rk_iommu_ops = {
.detach_dev = rk_iommu_detach_device,
.map = rk_iommu_map,
.unmap = rk_iommu_unmap,
.add_device = rk_iommu_add_device,
.remove_device = rk_iommu_remove_device,
.probe_device = rk_iommu_probe_device,
.release_device = rk_iommu_release_device,
.iova_to_phys = rk_iommu_iova_to_phys,
.device_group = rk_iommu_device_group,
.pgsize_bitmap = RK_IOMMU_PGSIZE_BITMAP,