| From 7634019e80ccc6ffcd9502d8644d249b91703e54 Mon Sep 17 00:00:00 2001 |
| From: Heiko Stuebner <heiko@sntech.de> |
| Date: Wed, 25 Sep 2019 20:43:46 +0200 |
| Subject: [PATCH] iommu/rockchip: Don't use platform_get_irq to implicitly |
| count irqs |
| |
| commit f9258156c73c2b2aa96731cd78bc23c4c4aac83d upstream. |
| |
| Till now the Rockchip iommu driver walked through the irq list via |
| platform_get_irq() until it encountered an ENXIO error. With the |
| recent change to add a central error message, this always results |
| in such an error for each iommu on probe and shutdown. |
| |
| To not confuse people, switch to platform_count_irqs() to get the |
| actual number of interrupts before walking through them. |
| |
| Fixes: 7723f4c5ecdb ("driver core: platform: Add an error message to platform_get_irq*()") |
| Signed-off-by: Heiko Stuebner <heiko@sntech.de> |
| Tested-by: Enric Balletbo i Serra <enric.balletbo@collabora.com> |
| Signed-off-by: Joerg Roedel <jroedel@suse.de> |
| Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com> |
| |
| diff --git a/drivers/iommu/rockchip-iommu.c b/drivers/iommu/rockchip-iommu.c |
| index 16e056d1407c..9a94af7bfd0f 100644 |
| --- a/drivers/iommu/rockchip-iommu.c |
| +++ b/drivers/iommu/rockchip-iommu.c |
| @@ -100,6 +100,7 @@ struct rk_iommu { |
| struct device *dev; |
| void __iomem **bases; |
| int num_mmu; |
| + int num_irq; |
| struct clk_bulk_data *clocks; |
| int num_clocks; |
| bool reset_disabled; |
| @@ -1139,7 +1140,7 @@ static int rk_iommu_probe(struct platform_device *pdev) |
| struct rk_iommu *iommu; |
| struct resource *res; |
| int num_res = pdev->num_resources; |
| - int err, i, irq; |
| + int err, i; |
| |
| iommu = devm_kzalloc(dev, sizeof(*iommu), GFP_KERNEL); |
| if (!iommu) |
| @@ -1166,6 +1167,10 @@ static int rk_iommu_probe(struct platform_device *pdev) |
| if (iommu->num_mmu == 0) |
| return PTR_ERR(iommu->bases[0]); |
| |
| + iommu->num_irq = platform_irq_count(pdev); |
| + if (iommu->num_irq < 0) |
| + return iommu->num_irq; |
| + |
| iommu->reset_disabled = device_property_read_bool(dev, |
| "rockchip,disable-mmu-reset"); |
| |
| @@ -1222,8 +1227,9 @@ static int rk_iommu_probe(struct platform_device *pdev) |
| |
| pm_runtime_enable(dev); |
| |
| - i = 0; |
| - while ((irq = platform_get_irq(pdev, i++)) != -ENXIO) { |
| + for (i = 0; i < iommu->num_irq; i++) { |
| + int irq = platform_get_irq(pdev, i); |
| + |
| if (irq < 0) |
| return irq; |
| |
| @@ -1248,10 +1254,13 @@ static int rk_iommu_probe(struct platform_device *pdev) |
| static void rk_iommu_shutdown(struct platform_device *pdev) |
| { |
| struct rk_iommu *iommu = platform_get_drvdata(pdev); |
| - int i = 0, irq; |
| + int i; |
| + |
| + for (i = 0; i < iommu->num_irq; i++) { |
| + int irq = platform_get_irq(pdev, i); |
| |
| - while ((irq = platform_get_irq(pdev, i++)) != -ENXIO) |
| devm_free_irq(iommu->dev, irq, iommu); |
| + } |
| |
| pm_runtime_force_suspend(&pdev->dev); |
| } |
| -- |
| 2.7.4 |
| |