From: Alexander Aring <alex.aring@gmail.com>
To: barebox@lists.infradead.org
Subject: [PATCH 2/3] memtest: cleanup requests of regions
Date: Thu, 10 Apr 2014 14:04:05 +0200 [thread overview]
Message-ID: <1397131446-4816-3-git-send-email-alex.aring@gmail.com> (raw)
In-Reply-To: <1397131446-4816-1-git-send-email-alex.aring@gmail.com>
This patch removes the first and last entry check inside the loop.
There should be no functional changes there.
Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
commands/memtest.c | 66 +++++++++++++++++++++++-------------------------------
1 file changed, 28 insertions(+), 38 deletions(-)
diff --git a/commands/memtest.c b/commands/memtest.c
index dc05e9e..5854375 100644
--- a/commands/memtest.c
+++ b/commands/memtest.c
@@ -74,34 +74,25 @@ static int request_memtest_regions(struct list_head *list)
continue;
}
+ r = list_first_entry(&bank->res->children,
+ struct resource, sibling);
+ start = PAGE_ALIGN(bank->res->start);
+ end = PAGE_ALIGN_DOWN(r->start);
+ r_prev = r;
+ if (start != end) {
+ size = end - start;
+ ret = alloc_memtest_region(list, start, size);
+ if (ret < 0)
+ return ret;
+ }
/*
* We assume that the regions are sorted in this list
* So the first element has start boundary on bank->res->start
- * and the last element hast end boundary on bank->res->end
+ * and the last element hast end boundary on bank->res->end.
+ *
+ * Between used regions. Start from second entry.
*/
- list_for_each_entry(r, &bank->res->children, sibling) {
- /*
- * Do on head element for bank boundary
- */
- if (r->sibling.prev == &bank->res->children) {
- /*
- * remember last used element
- */
- start = PAGE_ALIGN(bank->res->start);
- end = PAGE_ALIGN_DOWN(r->start);
- r_prev = r;
- if (start == end)
- continue;
- size = end - start;
-
- ret = alloc_memtest_region(list, start, size);
- if (ret < 0)
- return ret;
- continue;
- }
- /*
- * Between used regions
- */
+ list_for_each_entry_from(r, &bank->res->children, sibling) {
start = PAGE_ALIGN(r_prev->end);
end = PAGE_ALIGN_DOWN(r->start);
r_prev = r;
@@ -112,21 +103,20 @@ static int request_memtest_regions(struct list_head *list)
ret = alloc_memtest_region(list, start, size);
if (ret < 0)
return ret;
+ }
- if (list_is_last(&r->sibling, &bank->res->children)) {
- /*
- * Do on head element for bank boundary
- */
- start = PAGE_ALIGN(r->end);
- end = PAGE_ALIGN_DOWN(bank->res->end) - 1;
- size = end - start + 1;
- if (start >= end)
- continue;
-
- ret = alloc_memtest_region(list, start, size);
- if (ret < 0)
- return ret;
- }
+ /*
+ * Do on head element for bank boundary.
+ */
+ r = list_last_entry(&bank->res->children,
+ struct resource, sibling);
+ start = PAGE_ALIGN(r->end);
+ end = PAGE_ALIGN_DOWN(bank->res->end) - 1;
+ size = end - start + 1;
+ if (start < end) {
+ ret = alloc_memtest_region(list, start, size);
+ if (ret < 0)
+ return ret;
}
}
--
1.9.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2014-04-10 17:51 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-10 12:04 [PATCH 0/3] memtest: small cleanup Alexander Aring
2014-04-10 12:04 ` [PATCH 1/3] memtest: cleanup error handling Alexander Aring
2014-04-10 12:04 ` Alexander Aring [this message]
2014-04-10 12:04 ` [PATCH 3/3] memtest: copyright to UPPER case and fix typo Alexander Aring
2014-04-23 10:25 ` [PATCH 0/3] memtest: small cleanup Sascha Hauer
2014-04-23 12:02 ` Alexander Aring
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1397131446-4816-3-git-send-email-alex.aring@gmail.com \
--to=alex.aring@gmail.com \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox