Skip to content

Commit 18d8c74

Browse files
YongWu-HFjoergroedel
authored andcommitted
iommu/mediatek: Allow building as module
The IOMMU in many SoC depends on the MM clocks and power-domain which are device_initcall normally, thus the subsys_init here is not helpful. This patch switches it to module_platform_driver which also allow the driver built as module. Correspondingly switch the config to tristate, and update the iommu_ops's owner. Signed-off-by: Yong Wu <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Joerg Roedel <[email protected]>
1 parent 8de000c commit 18d8c74

File tree

2 files changed

+6
-13
lines changed

2 files changed

+6
-13
lines changed

drivers/iommu/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ config S390_AP_IOMMU
349349
is not implemented as it is not necessary for VFIO.
350350

351351
config MTK_IOMMU
352-
bool "MTK IOMMU Support"
352+
tristate "MediaTek IOMMU Support"
353353
depends on ARCH_MEDIATEK || COMPILE_TEST
354354
select ARM_DMA_USE_IOMMU
355355
select IOMMU_API

drivers/iommu/mtk_iommu.c

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <linux/iopoll.h>
1818
#include <linux/list.h>
1919
#include <linux/mfd/syscon.h>
20+
#include <linux/module.h>
2021
#include <linux/of_address.h>
2122
#include <linux/of_iommu.h>
2223
#include <linux/of_irq.h>
@@ -683,6 +684,7 @@ static const struct iommu_ops mtk_iommu_ops = {
683684
.get_resv_regions = mtk_iommu_get_resv_regions,
684685
.put_resv_regions = generic_iommu_put_resv_regions,
685686
.pgsize_bitmap = SZ_4K | SZ_64K | SZ_1M | SZ_16M,
687+
.owner = THIS_MODULE,
686688
};
687689

688690
static int mtk_iommu_hw_init(const struct mtk_iommu_data *data)
@@ -1079,16 +1081,7 @@ static struct platform_driver mtk_iommu_driver = {
10791081
.pm = &mtk_iommu_pm_ops,
10801082
}
10811083
};
1084+
module_platform_driver(mtk_iommu_driver);
10821085

1083-
static int __init mtk_iommu_init(void)
1084-
{
1085-
int ret;
1086-
1087-
ret = platform_driver_register(&mtk_iommu_driver);
1088-
if (ret != 0)
1089-
pr_err("Failed to register MTK IOMMU driver\n");
1090-
1091-
return ret;
1092-
}
1093-
1094-
subsys_initcall(mtk_iommu_init)
1086+
MODULE_DESCRIPTION("IOMMU API for MediaTek M4U implementations");
1087+
MODULE_LICENSE("GPL v2");

0 commit comments

Comments
 (0)