Commit d8260443 authored by Joerg Roedel's avatar Joerg Roedel

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: default avatarJoerg Roedel <jroedel@suse.de>
Link: https://lore.kernel.org/r/20200429133712.31431-26-joro@8bytes.orgSigned-off-by: default avatarJoerg Roedel <jroedel@suse.de>
parent bfe3bd49
...@@ -1054,40 +1054,28 @@ static void rk_iommu_domain_free(struct iommu_domain *domain) ...@@ -1054,40 +1054,28 @@ static void rk_iommu_domain_free(struct iommu_domain *domain)
kfree(rk_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_iommudata *data;
struct rk_iommu *iommu;
data = dev->archdata.iommu; data = dev->archdata.iommu;
if (!data) if (!data)
return -ENODEV; return ERR_PTR(-ENODEV);
iommu = rk_iommu_from_dev(dev); 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, data->link = device_link_add(dev, iommu->dev,
DL_FLAG_STATELESS | DL_FLAG_PM_RUNTIME); 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; struct rk_iommudata *data = dev->archdata.iommu;
iommu = rk_iommu_from_dev(dev);
device_link_del(data->link); 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) static struct iommu_group *rk_iommu_device_group(struct device *dev)
...@@ -1126,8 +1114,8 @@ static const struct iommu_ops rk_iommu_ops = { ...@@ -1126,8 +1114,8 @@ static const struct iommu_ops rk_iommu_ops = {
.detach_dev = rk_iommu_detach_device, .detach_dev = rk_iommu_detach_device,
.map = rk_iommu_map, .map = rk_iommu_map,
.unmap = rk_iommu_unmap, .unmap = rk_iommu_unmap,
.add_device = rk_iommu_add_device, .probe_device = rk_iommu_probe_device,
.remove_device = rk_iommu_remove_device, .release_device = rk_iommu_release_device,
.iova_to_phys = rk_iommu_iova_to_phys, .iova_to_phys = rk_iommu_iova_to_phys,
.device_group = rk_iommu_device_group, .device_group = rk_iommu_device_group,
.pgsize_bitmap = RK_IOMMU_PGSIZE_BITMAP, .pgsize_bitmap = RK_IOMMU_PGSIZE_BITMAP,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment