Skip to content

Commit 80e4592

Browse files
committed
iommu/mediatek: Convert to probe/release_device() call-backs
Convert the Mediatek 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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Joerg Roedel <[email protected]>
1 parent dea74f1 commit 80e4592

File tree

1 file changed

+6
-18
lines changed

1 file changed

+6
-18
lines changed

drivers/iommu/mtk_iommu.c

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -441,38 +441,26 @@ static phys_addr_t mtk_iommu_iova_to_phys(struct iommu_domain *domain,
441441
return pa;
442442
}
443443

444-
static int mtk_iommu_add_device(struct device *dev)
444+
static struct iommu_device *mtk_iommu_probe_device(struct device *dev)
445445
{
446446
struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev);
447447
struct mtk_iommu_data *data;
448-
struct iommu_group *group;
449448

450449
if (!fwspec || fwspec->ops != &mtk_iommu_ops)
451-
return -ENODEV; /* Not a iommu client device */
450+
return ERR_PTR(-ENODEV); /* Not a iommu client device */
452451

453452
data = dev_iommu_priv_get(dev);
454-
iommu_device_link(&data->iommu, dev);
455453

456-
group = iommu_group_get_for_dev(dev);
457-
if (IS_ERR(group))
458-
return PTR_ERR(group);
459-
460-
iommu_group_put(group);
461-
return 0;
454+
return &data->iommu;
462455
}
463456

464-
static void mtk_iommu_remove_device(struct device *dev)
457+
static void mtk_iommu_release_device(struct device *dev)
465458
{
466459
struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev);
467-
struct mtk_iommu_data *data;
468460

469461
if (!fwspec || fwspec->ops != &mtk_iommu_ops)
470462
return;
471463

472-
data = dev_iommu_priv_get(dev);
473-
iommu_device_unlink(&data->iommu, dev);
474-
475-
iommu_group_remove_device(dev);
476464
iommu_fwspec_free(dev);
477465
}
478466

@@ -526,8 +514,8 @@ static const struct iommu_ops mtk_iommu_ops = {
526514
.flush_iotlb_all = mtk_iommu_flush_iotlb_all,
527515
.iotlb_sync = mtk_iommu_iotlb_sync,
528516
.iova_to_phys = mtk_iommu_iova_to_phys,
529-
.add_device = mtk_iommu_add_device,
530-
.remove_device = mtk_iommu_remove_device,
517+
.probe_device = mtk_iommu_probe_device,
518+
.release_device = mtk_iommu_release_device,
531519
.device_group = mtk_iommu_device_group,
532520
.of_xlate = mtk_iommu_of_xlate,
533521
.pgsize_bitmap = SZ_4K | SZ_64K | SZ_1M | SZ_16M,

0 commit comments

Comments
 (0)