@@ -1264,16 +1264,13 @@ static int mtk_iommu_probe(struct platform_device *pdev)
}
banks_num = data->plat_data->banks_num;
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- if (!res)
- return -EINVAL;
+ base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
+ if (IS_ERR(base))
+ return PTR_ERR(base);
if (resource_size(res) < banks_num * MTK_IOMMU_BANK_SZ) {
dev_err(dev, "banknr %d. res %pR is not enough.\n", banks_num, res);
return -EINVAL;
}
- base = devm_ioremap_resource(dev, res);
- if (IS_ERR(base))
- return PTR_ERR(base);
ioaddr = res->start;
data->bank = devm_kmalloc(dev, banks_num * sizeof(*data->bank), GFP_KERNEL);
@@ -610,7 +610,6 @@ static int mtk_iommu_v1_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct mtk_iommu_v1_data *data;
- struct resource *res;
struct component_match *match = NULL;
void *protect;
int larb_nr, ret, i;
@@ -628,8 +627,7 @@ static int mtk_iommu_v1_probe(struct platform_device *pdev)
return -ENOMEM;
data->protect_base = ALIGN(virt_to_phys(protect), MTK_PROTECT_PA_ALIGN);
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- data->base = devm_ioremap_resource(dev, res);
+ data->base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(data->base))
return PTR_ERR(data->base);
Use devm_platform_ioremap_resource() and devm_platform_get_and_ioremap_resource() to simplify code. Signed-off-by: Yangtao Li <frank.li@vivo.com> --- drivers/iommu/mtk_iommu.c | 9 +++------ drivers/iommu/mtk_iommu_v1.c | 4 +--- 2 files changed, 4 insertions(+), 9 deletions(-)