* [PATCH] iommu/io-pgtable-arm: Using for_each_set_bit to simplify the code
@ 2016-09-21 5:41 Kefeng Wang
2016-09-21 10:35 ` Robin Murphy
0 siblings, 1 reply; 2+ messages in thread
From: Kefeng Wang @ 2016-09-21 5:41 UTC (permalink / raw)
To: linux-arm-kernel
Using for_each_set_bit() to simplify the code.
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
drivers/iommu/io-pgtable-arm-v7s.c | 5 +----
drivers/iommu/io-pgtable-arm.c | 5 +----
2 files changed, 2 insertions(+), 8 deletions(-)
diff --git a/drivers/iommu/io-pgtable-arm-v7s.c b/drivers/iommu/io-pgtable-arm-v7s.c
index def8ca1..f23821b 100644
--- a/drivers/iommu/io-pgtable-arm-v7s.c
+++ b/drivers/iommu/io-pgtable-arm-v7s.c
@@ -789,8 +789,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 |
@@ -807,8 +806,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++;
}
diff --git a/drivers/iommu/io-pgtable-arm.c b/drivers/iommu/io-pgtable-arm.c
index f5c90e1..8c3dfb7 100644
--- a/drivers/iommu/io-pgtable-arm.c
+++ b/drivers/iommu/io-pgtable-arm.c
@@ -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 */
--
1.7.12.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH] iommu/io-pgtable-arm: Using for_each_set_bit to simplify the code
2016-09-21 5:41 [PATCH] iommu/io-pgtable-arm: Using for_each_set_bit to simplify the code Kefeng Wang
@ 2016-09-21 10:35 ` Robin Murphy
0 siblings, 0 replies; 2+ messages in thread
From: Robin Murphy @ 2016-09-21 10:35 UTC (permalink / raw)
To: linux-arm-kernel
On 21/09/16 06:41, Kefeng Wang wrote:
> Using for_each_set_bit() to simplify the code.
Reviewed-by: Robin Murphy <robin.murphy@arm.com>
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
> ---
> drivers/iommu/io-pgtable-arm-v7s.c | 5 +----
> drivers/iommu/io-pgtable-arm.c | 5 +----
> 2 files changed, 2 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/iommu/io-pgtable-arm-v7s.c b/drivers/iommu/io-pgtable-arm-v7s.c
> index def8ca1..f23821b 100644
> --- a/drivers/iommu/io-pgtable-arm-v7s.c
> +++ b/drivers/iommu/io-pgtable-arm-v7s.c
> @@ -789,8 +789,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 |
> @@ -807,8 +806,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++;
> }
>
> diff --git a/drivers/iommu/io-pgtable-arm.c b/drivers/iommu/io-pgtable-arm.c
> index f5c90e1..8c3dfb7 100644
> --- a/drivers/iommu/io-pgtable-arm.c
> +++ b/drivers/iommu/io-pgtable-arm.c
> @@ -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 */
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-09-21 10:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-21 5:41 [PATCH] iommu/io-pgtable-arm: Using for_each_set_bit to simplify the code Kefeng Wang
2016-09-21 10:35 ` Robin Murphy
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.