From 19cb6e3579f4d93b8a4373cd05212effab756f15 Mon Sep 17 00:00:00 2001 From: Simon Xue Date: Tue, 7 Sep 2021 14:50:55 +0800 Subject: [PATCH] iommu: rockchip: optimise getting clocks Use devm_clk_bulk_get_all instead of devm_clk_bulk_get. So we don't need the complicated operation. Change-Id: Idbe7668bd26b744f8d8b7d79d5eb99fa891bd0be Signed-off-by: Simon Xue --- drivers/iommu/rockchip-iommu.c | 40 ++++------------------------------ 1 file changed, 4 insertions(+), 36 deletions(-) diff --git a/drivers/iommu/rockchip-iommu.c b/drivers/iommu/rockchip-iommu.c index 723b8d2f18de..fc7d67b318b3 100644 --- a/drivers/iommu/rockchip-iommu.c +++ b/drivers/iommu/rockchip-iommu.c @@ -124,11 +124,6 @@ struct rockchip_iommu_data { u32 version; }; -/* list of clocks required by IOMMU */ -static const char * const rk_iommu_clocks[] = { - "aclk", "iface", -}; - struct rk_iommu { struct device *dev; void __iomem **bases; @@ -1732,45 +1727,18 @@ static int rk_iommu_probe(struct platform_device *pdev) "rockchip,enable-cmd-retry"); } - iommu->num_clocks = ARRAY_SIZE(rk_iommu_clocks); - iommu->clocks = devm_kcalloc(iommu->dev, iommu->num_clocks, - sizeof(*iommu->clocks), GFP_KERNEL); - if (!iommu->clocks) - return -ENOMEM; - - /* RK1808 isp iommu has an extra sclk */ - err = of_property_match_string(dev->of_node, "clock-names", "sclk"); - if (err >= 0) - iommu->num_clocks++; - - for (i = 0; i < iommu->num_clocks; ++i) { - if (i == 2) { - iommu->clocks[i].id = "sclk"; - } else { - err = of_property_match_string(dev->of_node, - "clock-names", - rk_iommu_clocks[i]); - if (err < 0) { - if (!strcmp(rk_iommu_clocks[i], "iface")) { - iommu->clocks[i].id = "hclk"; - dev_warn(dev, "iommu hclk need to update to iface\n"); - } - } else { - iommu->clocks[i].id = rk_iommu_clocks[i]; - } - } - } - /* * iommu clocks should be present for all new devices and devicetrees * but there are older devicetrees without clocks out in the wild. * So clocks as optional for the time being. */ - err = devm_clk_bulk_get(iommu->dev, iommu->num_clocks, iommu->clocks); + err = devm_clk_bulk_get_all(dev, &iommu->clocks); if (err == -ENOENT) iommu->num_clocks = 0; - else if (err) + else if (err < 0) return err; + else + iommu->num_clocks = err; err = clk_bulk_prepare(iommu->num_clocks, iommu->clocks); if (err)