]> git.karo-electronics.de Git - linux-beck.git/commitdiff
iommu/io-pgtable-arm: Use for_each_set_bit to simplify the code
authorKefeng Wang <wangkefeng.wang@huawei.com>
Wed, 21 Sep 2016 05:41:31 +0000 (13:41 +0800)
committerWill Deacon <will.deacon@arm.com>
Tue, 29 Nov 2016 15:57:40 +0000 (15:57 +0000)
We can use for_each_set_bit() to simplify the code slightly in the
ARM io-pgtable self tests.

Reviewed-by: Robin Murphy <robin.murphy@arm.com>
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
drivers/iommu/io-pgtable-arm-v7s.c
drivers/iommu/io-pgtable-arm.c

index f50e51c1a9c88630b03ca9095a2d6e732f671aee..0769276c0537c8157f3845dcb4d577998ebb5d77 100644 (file)
@@ -793,8 +793,7 @@ static int __init arm_v7s_do_selftests(void)
         * Distinct mappings of different granule sizes.
         */
        iova = 0;
-       i = find_first_bit(&cfg.pgsize_bitmap, BITS_PER_LONG);
-       while (i != BITS_PER_LONG) {
+       for_each_set_bit(i, &cfg.pgsize_bitmap, BITS_PER_LONG) {
                size = 1UL << i;
                if (ops->map(ops, iova, iova, size, IOMMU_READ |
                                                    IOMMU_WRITE |
@@ -811,8 +810,6 @@ static int __init arm_v7s_do_selftests(void)
                        return __FAIL(ops);
 
                iova += SZ_16M;
-               i++;
-               i = find_next_bit(&cfg.pgsize_bitmap, BITS_PER_LONG, i);
                loopnr++;
        }
 
index f5c90e1366ce030249d1ae6d392762c6ea1834ef..8c3dfb7497c1ecc9f2d3eed27b5bb64bd0e22559 100644 (file)
@@ -980,8 +980,7 @@ static int __init arm_lpae_run_tests(struct io_pgtable_cfg *cfg)
                 * Distinct mappings of different granule sizes.
                 */
                iova = 0;
-               j = find_first_bit(&cfg->pgsize_bitmap, BITS_PER_LONG);
-               while (j != BITS_PER_LONG) {
+               for_each_set_bit(j, &cfg->pgsize_bitmap, BITS_PER_LONG) {
                        size = 1UL << j;
 
                        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)
                                return __FAIL(ops, i);
 
                        iova += SZ_1G;
-                       j++;
-                       j = find_next_bit(&cfg->pgsize_bitmap, BITS_PER_LONG, j);
                }
 
                /* Partial unmap */