LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] iommu/io-pgtable-arm: Use for_each_set_bit to simplify code
@ 2018-04-26  4:49 YueHaibing
  2018-05-03 13:31 ` Joerg Roedel
  0 siblings, 1 reply; 2+ messages in thread
From: YueHaibing @ 2018-04-26  4:49 UTC (permalink / raw)
  To: will.deacon, robin.murphy, joro
  Cc: linux-arm-kernel, iommu, linux-kernel, YueHaibing

We can use for_each_set_bit() to simplify code slightly in the
ARM io-pgtable self tests while unmapping.

Signed-off-by: YueHaibing <yuehaibing@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 10e4a3d..50e3a9f 100644
--- a/drivers/iommu/io-pgtable-arm-v7s.c
+++ b/drivers/iommu/io-pgtable-arm-v7s.c
@@ -898,8 +898,7 @@ static int __init arm_v7s_do_selftests(void)
 
 	/* Full unmap */
 	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->unmap(ops, iova, size) != size)
@@ -916,8 +915,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);
 	}
 
 	free_io_pgtable_ops(ops);
diff --git a/drivers/iommu/io-pgtable-arm.c b/drivers/iommu/io-pgtable-arm.c
index 39c2a05..4ffdd88 100644
--- a/drivers/iommu/io-pgtable-arm.c
+++ b/drivers/iommu/io-pgtable-arm.c
@@ -1120,8 +1120,7 @@ static int __init arm_lpae_run_tests(struct io_pgtable_cfg *cfg)
 
 		/* Full unmap */
 		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->unmap(ops, iova, size) != size)
@@ -1138,8 +1137,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);
 		}
 
 		free_io_pgtable_ops(ops);
-- 
2.7.0

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] iommu/io-pgtable-arm: Use for_each_set_bit to simplify code
  2018-04-26  4:49 [PATCH] iommu/io-pgtable-arm: Use for_each_set_bit to simplify code YueHaibing
@ 2018-05-03 13:31 ` Joerg Roedel
  0 siblings, 0 replies; 2+ messages in thread
From: Joerg Roedel @ 2018-05-03 13:31 UTC (permalink / raw)
  To: YueHaibing
  Cc: will.deacon, robin.murphy, linux-arm-kernel, iommu, linux-kernel

On Thu, Apr 26, 2018 at 12:49:29PM +0800, YueHaibing wrote:
> We can use for_each_set_bit() to simplify code slightly in the
> ARM io-pgtable self tests while unmapping.
> 
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
> ---
>  drivers/iommu/io-pgtable-arm-v7s.c | 5 +----
>  drivers/iommu/io-pgtable-arm.c     | 5 +----
>  2 files changed, 2 insertions(+), 8 deletions(-)

Applied, thanks.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-05-03 13:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-26  4:49 [PATCH] iommu/io-pgtable-arm: Use for_each_set_bit to simplify code YueHaibing
2018-05-03 13:31 ` Joerg Roedel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).