Skip to contentSkip to conversation

PM/Hibernate: use rb_entry

PATCH Superseded Davidlohr Bueso 2 participants 3 messages Mar 18, 2012 – May 27, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PM/Hibernate: use rb_entry

From: Davidlohr Bueso <[email protected]>

Since the software suspend extents are organized in an rbtree, use rb_entry instead of container_of, as it is semantically more appropriate in order to get a node as it is iterated.

---
 kernel/power/swap.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
kernel/power/swap.c +2 -2
index 8742fd0..1529b83 100644
@@ -109,7 +109,7 @@ static int swsusp_extents_insert(unsigned long swap_offset)
 
 	/* Figure out where to put the new node */
 	while (*new) {
-		ext = container_of(*new, struct swsusp_extent, node);
+		ext = rb_entry(*new, struct swsusp_extent, node);
 		parent = *new;
 		if (swap_offset < ext->start) {
 			/* Try to merge */
@@ -175,7 +175,7 @@ void free_all_swap_pages(int swap)
 		struct swsusp_extent *ext;
 		unsigned long offset;
 
-		ext = container_of(node, struct swsusp_extent, node);
+		ext = rb_entry(node, struct swsusp_extent, node);
 		rb_erase(node, &swsusp_extents);
 		for (offset = ext->start; offset <= ext->end; offset++)
 			swap_free(swp_entry(swap, offset));
Signature · 1 line
1.7.4.1
#1 lore raw
Quoted 7 lines · Davidlohr Bueso

From: Davidlohr Bueso <[email protected]>

Since the software suspend extents are organized in an rbtree, use rb_entry instead of container_of, as it is semantically more appropriate in order to get a node as it is iterated.

ACK.

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#2 lore raw
Quoted 10 lines · Pavel Machek
Quoted 7 lines · Davidlohr Bueso

From: Davidlohr Bueso <[email protected]>

Since the software suspend extents are organized in an rbtree, use rb_entry instead of container_of, as it is semantically more appropriate in order to get a node as it is iterated.

ACK.

ping about this...

thanks.