From e0492807e6b91becccbcab6eca1df27da55d726b Mon Sep 17 00:00:00 2001 From: ZhengShunQian Date: Sat, 19 Mar 2016 10:32:10 +0800 Subject: [PATCH] iommu/rockchip: fix bool operation error and probe warning Bool type true is exactly BIT(0), so bool enable = true; enable &= BIT(2); enable will be false, which isn't the result we expected in this case. Change bool type to u32. The other fix is checking the res in probe() to skip the irq resource. Change-Id: I2947c9f1e15cb92f03096d26a44759c107bfacd1 Reported-by: Simon Suggested-by: Simon Signed-off-by: ZhengShunQian --- drivers/iommu/rockchip-iommu.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/iommu/rockchip-iommu.c b/drivers/iommu/rockchip-iommu.c index a6f593a0a29e..7f848a202d1f 100644 --- a/drivers/iommu/rockchip-iommu.c +++ b/drivers/iommu/rockchip-iommu.c @@ -311,24 +311,22 @@ static void rk_iommu_zap_lines(struct rk_iommu *iommu, dma_addr_t iova, static bool rk_iommu_is_stall_active(struct rk_iommu *iommu) { - bool active = true; + u32 active = RK_MMU_STATUS_STALL_ACTIVE; int i; for (i = 0; i < iommu->num_mmu; i++) - active &= rk_iommu_read(iommu->bases[i], RK_MMU_STATUS) & - RK_MMU_STATUS_STALL_ACTIVE; + active &= rk_iommu_read(iommu->bases[i], RK_MMU_STATUS); return active; } static bool rk_iommu_is_paging_enabled(struct rk_iommu *iommu) { - bool enable = true; + u32 enable = RK_MMU_STATUS_PAGING_ENABLED; int i; for (i = 0; i < iommu->num_mmu; i++) - enable &= rk_iommu_read(iommu->bases[i], RK_MMU_STATUS) & - RK_MMU_STATUS_PAGING_ENABLED; + enable &= rk_iommu_read(iommu->bases[i], RK_MMU_STATUS); return enable; } @@ -1049,9 +1047,9 @@ static int rk_iommu_probe(struct platform_device *pdev) for (i = 0; i < pdev->num_resources; i++) { res = platform_get_resource(pdev, IORESOURCE_MEM, i); - iommu->bases[i] = devm_ioremap_resource(&pdev->dev, res); - if (IS_ERR(iommu->bases[i])) + if (!res) continue; + iommu->bases[i] = devm_ioremap_resource(&pdev->dev, res); iommu->num_mmu++; } if (iommu->num_mmu == 0) -- 2.34.1