Commit 4ae8a5c5 authored by Kefeng Wang's avatar Kefeng Wang Committed by Will Deacon

iommu/io-pgtable-arm: Use for_each_set_bit to simplify the code

We can use for_each_set_bit() to simplify the code slightly in the
ARM io-pgtable self tests.
Reviewed-by: default avatarRobin Murphy <robin.murphy@arm.com>
Signed-off-by: default avatarKefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
parent a25f0944
...@@ -793,8 +793,7 @@ static int __init arm_v7s_do_selftests(void) ...@@ -793,8 +793,7 @@ static int __init arm_v7s_do_selftests(void)
* Distinct mappings of different granule sizes. * Distinct mappings of different granule sizes.
*/ */
iova = 0; iova = 0;
i = find_first_bit(&cfg.pgsize_bitmap, BITS_PER_LONG); for_each_set_bit(i, &cfg.pgsize_bitmap, BITS_PER_LONG) {
while (i != BITS_PER_LONG) {
size = 1UL << i; size = 1UL << i;
if (ops->map(ops, iova, iova, size, IOMMU_READ | if (ops->map(ops, iova, iova, size, IOMMU_READ |
IOMMU_WRITE | IOMMU_WRITE |
...@@ -811,8 +810,6 @@ static int __init arm_v7s_do_selftests(void) ...@@ -811,8 +810,6 @@ static int __init arm_v7s_do_selftests(void)
return __FAIL(ops); return __FAIL(ops);
iova += SZ_16M; iova += SZ_16M;
i++;
i = find_next_bit(&cfg.pgsize_bitmap, BITS_PER_LONG, i);
loopnr++; loopnr++;
} }
......
...@@ -980,8 +980,7 @@ static int __init arm_lpae_run_tests(struct io_pgtable_cfg *cfg) ...@@ -980,8 +980,7 @@ static int __init arm_lpae_run_tests(struct io_pgtable_cfg *cfg)
* Distinct mappings of different granule sizes. * Distinct mappings of different granule sizes.
*/ */
iova = 0; iova = 0;
j = find_first_bit(&cfg->pgsize_bitmap, BITS_PER_LONG); for_each_set_bit(j, &cfg->pgsize_bitmap, BITS_PER_LONG) {
while (j != BITS_PER_LONG) {
size = 1UL << j; size = 1UL << j;
if (ops->map(ops, iova, iova, size, IOMMU_READ | if (ops->map(ops, iova, iova, size, IOMMU_READ |
...@@ -999,8 +998,6 @@ static int __init arm_lpae_run_tests(struct io_pgtable_cfg *cfg) ...@@ -999,8 +998,6 @@ static int __init arm_lpae_run_tests(struct io_pgtable_cfg *cfg)
return __FAIL(ops, i); return __FAIL(ops, i);
iova += SZ_1G; iova += SZ_1G;
j++;
j = find_next_bit(&cfg->pgsize_bitmap, BITS_PER_LONG, j);
} }
/* Partial unmap */ /* Partial unmap */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment