xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] xen: simplify balloon_first_page() with list_first_entry_or_null()
@ 2013-11-13 11:44 Jeff Liu
  2013-11-13 12:09 ` David Vrabel
  0 siblings, 1 reply; 3+ messages in thread
From: Jeff Liu @ 2013-11-13 11:44 UTC (permalink / raw)
  To: xen-devel; +Cc: "

From: Jie Liu <jeff.liu@oracle.com>

Simplify the code logic of balloon_first_page() by replacing
the combination of list_empty() and list_first_entry() with
list_first_entry_or_null().  As a net win, we can change this
routine to inline as now it's one line.

Signed-off-by: Jie Liu <jeff.liu@oracle.com>

---
 drivers/xen/balloon.c |    7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c
index b232908..0e4ca20 100644
--- a/drivers/xen/balloon.c
+++ b/drivers/xen/balloon.c
@@ -157,11 +157,10 @@ static struct page *balloon_retrieve(bool prefer_highmem)
 	return page;
 }
 
-static struct page *balloon_first_page(void)
+static inline struct page *balloon_first_page(void)
 {
-	if (list_empty(&ballooned_pages))
-		return NULL;
-	return list_entry(ballooned_pages.next, struct page, lru);
+	return list_first_entry_or_null(&ballooned_pages,
+					struct page, lru);
 }
 
 static struct page *balloon_next_page(struct page *page)
-- 
1.7.9.5

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

end of thread, other threads:[~2013-11-13 12:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-13 11:44 [PATCH] xen: simplify balloon_first_page() with list_first_entry_or_null() Jeff Liu
2013-11-13 12:09 ` David Vrabel
2013-11-13 12:54   ` Jeff Liu

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).