[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <ce9bc88496a04e6495320b041a0de4e0155b76a9.1482205355.git.geliangtang@gmail.com>
Date: Tue, 20 Dec 2016 22:02:19 +0800
From: Geliang Tang <geliangtang@...il.com>
To: Konrad Rzeszutek Wilk <konrad.wilk@...cle.com>,
Roger Pau Monné <roger.pau@...rix.com>
Cc: Geliang Tang <geliangtang@...il.com>,
xen-devel@...ts.xenproject.org, linux-kernel@...r.kernel.org
Subject: [PATCH] xen/blkback: use rb_entry()
To make the code clearer, use rb_entry() instead of container_of() to
deal with rbtree.
Signed-off-by: Geliang Tang <geliangtang@...il.com>
---
drivers/block/xen-blkback/blkback.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/block/xen-blkback/blkback.c b/drivers/block/xen-blkback/blkback.c
index 726c32e..7e59fae 100644
--- a/drivers/block/xen-blkback/blkback.c
+++ b/drivers/block/xen-blkback/blkback.c
@@ -191,10 +191,10 @@ static void make_response(struct xen_blkif_ring *ring, u64 id,
unsigned short op, int st);
#define foreach_grant_safe(pos, n, rbtree, node) \
- for ((pos) = container_of(rb_first((rbtree)), typeof(*(pos)), node), \
+ for ((pos) = rb_entry(rb_first((rbtree)), typeof(*(pos)), node), \
(n) = (&(pos)->node != NULL) ? rb_next(&(pos)->node) : NULL; \
&(pos)->node != NULL; \
- (pos) = container_of(n, typeof(*(pos)), node), \
+ (pos) = rb_entry(n, typeof(*(pos)), node), \
(n) = (&(pos)->node != NULL) ? rb_next(&(pos)->node) : NULL)
@@ -223,7 +223,7 @@ static int add_persistent_gnt(struct xen_blkif_ring *ring,
/* Figure out where to put new node */
new = &ring->persistent_gnts.rb_node;
while (*new) {
- this = container_of(*new, struct persistent_gnt, node);
+ this = rb_entry(*new, struct persistent_gnt, node);
parent = *new;
if (persistent_gnt->gnt < this->gnt)
@@ -254,7 +254,7 @@ static struct persistent_gnt *get_persistent_gnt(struct xen_blkif_ring *ring,
node = ring->persistent_gnts.rb_node;
while (node) {
- data = container_of(node, struct persistent_gnt, node);
+ data = rb_entry(node, struct persistent_gnt, node);
if (gref < data->gnt)
node = node->rb_left;
--
2.9.3
Powered by blists - more mailing lists