Skip to content

Commit f925815

Browse files
mmindjoergroedel
authored andcommitted
iommu/rockchip: Don't use platform_get_irq to implicitly count irqs
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: 7723f4c ("driver core: platform: Add an error message to platform_get_irq*()") Signed-off-by: Heiko Stuebner <[email protected]> Tested-by: Enric Balletbo i Serra <[email protected]> Signed-off-by: Joerg Roedel <[email protected]>
1 parent a52e197 commit f925815

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

drivers/iommu/rockchip-iommu.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ struct rk_iommu {
100100
struct device *dev;
101101
void __iomem **bases;
102102
int num_mmu;
103+
int num_irq;
103104
struct clk_bulk_data *clocks;
104105
int num_clocks;
105106
bool reset_disabled;
@@ -1136,7 +1137,7 @@ static int rk_iommu_probe(struct platform_device *pdev)
11361137
struct rk_iommu *iommu;
11371138
struct resource *res;
11381139
int num_res = pdev->num_resources;
1139-
int err, i, irq;
1140+
int err, i;
11401141

11411142
iommu = devm_kzalloc(dev, sizeof(*iommu), GFP_KERNEL);
11421143
if (!iommu)
@@ -1163,6 +1164,10 @@ static int rk_iommu_probe(struct platform_device *pdev)
11631164
if (iommu->num_mmu == 0)
11641165
return PTR_ERR(iommu->bases[0]);
11651166

1167+
iommu->num_irq = platform_irq_count(pdev);
1168+
if (iommu->num_irq < 0)
1169+
return iommu->num_irq;
1170+
11661171
iommu->reset_disabled = device_property_read_bool(dev,
11671172
"rockchip,disable-mmu-reset");
11681173

@@ -1219,8 +1224,9 @@ static int rk_iommu_probe(struct platform_device *pdev)
12191224

12201225
pm_runtime_enable(dev);
12211226

1222-
i = 0;
1223-
while ((irq = platform_get_irq(pdev, i++)) != -ENXIO) {
1227+
for (i = 0; i < iommu->num_irq; i++) {
1228+
int irq = platform_get_irq(pdev, i);
1229+
12241230
if (irq < 0)
12251231
return irq;
12261232

@@ -1245,10 +1251,13 @@ static int rk_iommu_probe(struct platform_device *pdev)
12451251
static void rk_iommu_shutdown(struct platform_device *pdev)
12461252
{
12471253
struct rk_iommu *iommu = platform_get_drvdata(pdev);
1248-
int i = 0, irq;
1254+
int i;
1255+
1256+
for (i = 0; i < iommu->num_irq; i++) {
1257+
int irq = platform_get_irq(pdev, i);
12491258

1250-
while ((irq = platform_get_irq(pdev, i++)) != -ENXIO)
12511259
devm_free_irq(iommu->dev, irq, iommu);
1260+
}
12521261

12531262
pm_runtime_force_suspend(&pdev->dev);
12541263
}

0 commit comments

Comments
 (0)