iommu/rockchip: Fix "is stall active" check
authorJohn Keeping <john@metanate.com>
Tue, 5 Apr 2016 14:05:46 +0000 (15:05 +0100)
committerJoerg Roedel <jroedel@suse.de>
Thu, 7 Apr 2016 12:50:18 +0000 (14:50 +0200)
Since commit cd6438c5f844 ("iommu/rockchip: Reconstruct to support multi
slaves") rk_iommu_is_stall_active() always returns false because the
bitwise AND operates on the boolean flag promoted to an integer and a
value that is either zero or BIT(2).

Explicitly convert the right-hand value to a boolean so that both sides
are guaranteed to be either zero or one.

rk_iommu_is_paging_enabled() does not suffer from the same problem since
RK_MMU_STATUS_PAGING_ENABLED is BIT(0), but let's apply the same change
for consistency and to make it clear that it's correct without needing
to lookup the value.

Fixes: cd6438c5f844 ("iommu/rockchip: Reconstruct to support multi slaves")
Signed-off-by: John Keeping <john@metanate.com>
Reviewed-by: Heiko Stuebner <heiko@sntech.de>
Tested-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Signed-off-by: Joerg Roedel <jroedel@suse.de>
drivers/iommu/rockchip-iommu.c

index a6f593a0a29eda65c1f383dbe1700c13a8e9be27..5710a06c30498e1b40f4c645f56f1c9b2a49eb4e 100644 (file)
@@ -315,8 +315,8 @@ static bool rk_iommu_is_stall_active(struct rk_iommu *iommu)
        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) &
+                                          RK_MMU_STATUS_STALL_ACTIVE);
 
        return active;
 }
@@ -327,8 +327,8 @@ static bool rk_iommu_is_paging_enabled(struct rk_iommu *iommu)
        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) &
+                                          RK_MMU_STATUS_PAGING_ENABLED);
 
        return enable;
 }