iommu/rockchip: fix bool operation error and probe warning
authorZhengShunQian <zhengsq@rock-chips.com>
Sat, 19 Mar 2016 02:32:10 +0000 (10:32 +0800)
committerGerrit Code Review <gerrit@rock-chips.com>
Tue, 22 Mar 2016 03:19:31 +0000 (11:19 +0800)
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 <xxm@rock-chips.com>
Suggested-by: Simon <xxm@rock-chips.com>
Signed-off-by: ZhengShunQian <zhengsq@rock-chips.com>
drivers/iommu/rockchip-iommu.c

index a6f593a0a29eda65c1f383dbe1700c13a8e9be27..7f848a202d1f51c9c9a26d2a4b89d877e83366c5 100644 (file)
@@ -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)