All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] lib/logic_iomem: replace usage of found with dedicated list iterator variable
@ 2022-03-24  7:14 Jakob Koschel
  0 siblings, 0 replies; only message in thread
From: Jakob Koschel @ 2022-03-24  7:14 UTC (permalink / raw)
  To: Richard Weinberger
  Cc: Johannes Berg, Al Viro, linux-kernel, Mike Rapoport,
	Brian Johannesmeyer, Cristiano Giuffrida, Bos, H.J.,
	Jakob Koschel

To move the list iterator variable into the list_for_each_entry_*()
macro in the future it should be avoided to use the list iterator
variable after the loop body.

To *never* use the list iterator variable after the loop it was
concluded to use a separate iterator variable instead of a
found boolean [1].

This removes the need to use a found variable and simply checking if
the variable was set, can determine if the break/goto was hit.

Link: https://lore.kernel.org/all/CAHk-=wgRr_D8CB-D9Kg-c=EHreAsk5SqXPwr9Y7k9sA6cWXJ6w@mail.gmail.com/
Signed-off-by: Jakob Koschel <jakobkoschel@gmail.com>
---
 lib/logic_iomem.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/lib/logic_iomem.c b/lib/logic_iomem.c
index 8c3365f26e51..62426a6f8103 100644
--- a/lib/logic_iomem.c
+++ b/lib/logic_iomem.c
@@ -86,20 +86,20 @@ static void real_iounmap(volatile void __iomem *addr)
 void __iomem *ioremap(phys_addr_t offset, size_t size)
 {
 	void __iomem *ret = NULL;
-	struct logic_iomem_region *rreg, *found = NULL;
+	struct logic_iomem_region *rreg = NULL, *iter;
 	int i;
 
 	mutex_lock(&regions_mtx);
-	list_for_each_entry(rreg, &regions_list, list) {
-		if (rreg->res->start > offset)
+	list_for_each_entry(iter, &regions_list, list) {
+		if (iter->res->start > offset)
 			continue;
-		if (rreg->res->end < offset + size - 1)
+		if (iter->res->end < offset + size - 1)
 			continue;
-		found = rreg;
+		rreg = iter;
 		break;
 	}
 
-	if (!found)
+	if (!rreg)
 		goto out;
 
 	for (i = 0; i < MAX_AREAS; i++) {
@@ -108,7 +108,7 @@ void __iomem *ioremap(phys_addr_t offset, size_t size)
 		if (mapped_areas[i].ops)
 			continue;
 
-		offs = rreg->ops->map(offset - found->res->start,
+		offs = rreg->ops->map(offset - rreg->res->start,
 				      size, &mapped_areas[i].ops,
 				      &mapped_areas[i].priv);
 		if (offs < 0) {

base-commit: f443e374ae131c168a065ea1748feac6b2e76613
-- 
2.25.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2022-03-24  7:14 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-24  7:14 [PATCH] lib/logic_iomem: replace usage of found with dedicated list iterator variable Jakob Koschel

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.