linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Geliang Tang <geliangtang@gmail.com>
To: "Konrad Rzeszutek Wilk" <konrad.wilk@oracle.com>,
	"Roger Pau Monné" <roger.pau@citrix.com>
Cc: Geliang Tang <geliangtang@gmail.com>,
	xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org
Subject: [PATCH] xen/blkback: use rb_entry()
Date: Tue, 20 Dec 2016 22:02:19 +0800	[thread overview]
Message-ID: <ce9bc88496a04e6495320b041a0de4e0155b76a9.1482205355.git.geliangtang@gmail.com> (raw)
In-Reply-To: <ddabc96c798df194791134d8e070d728e2a7b59f.1482203698.git.geliangtang@gmail.com>

To make the code clearer, use rb_entry() instead of container_of() to
deal with rbtree.

Signed-off-by: Geliang Tang <geliangtang@gmail.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

  parent reply	other threads:[~2016-12-20 14:03 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-20 14:02 [PATCH] dm bufio: use rb_entry() Geliang Tang
2016-12-20 14:02 ` [PATCH] drm/nouveau/dma: " Geliang Tang
2016-12-21 23:22   ` [Nouveau] " Ben Skeggs
2016-12-20 14:02 ` [PATCH] IB/qib: " Geliang Tang
2016-12-20 14:21   ` Leon Romanovsky
2016-12-20 15:01   ` Dennis Dalessandro
2016-12-20 19:34   ` Marciniszyn, Mike
2017-01-12 17:09   ` Doug Ledford
2016-12-20 14:02 ` [PATCH] netfilter: xt_connlimit: " Geliang Tang
2017-01-05 12:26   ` Pablo Neira Ayuso
2016-12-20 14:02 ` [PATCH] net/mlx5: " Geliang Tang
2016-12-20 14:19   ` Leon Romanovsky
2016-12-20 19:23   ` David Miller
2016-12-20 14:02 ` [PATCH] net_sched: sch_fq: " Geliang Tang
2016-12-20 16:38   ` Eric Dumazet
2016-12-20 19:23   ` David Miller
2016-12-20 14:02 ` [PATCH] net_sched: sch_netem: " Geliang Tang
2016-12-20 19:23   ` David Miller
2016-12-20 14:02 ` [PATCH] powerpc/perf/24x7: use rb_entry Geliang Tang
2019-07-08  1:19   ` Michael Ellerman
2016-12-20 14:02 ` [PATCH] RDS: use rb_entry() Geliang Tang
2016-12-20 14:20   ` Leon Romanovsky
2016-12-20 16:34   ` Santosh Shilimkar
2016-12-20 19:23   ` David Miller
2016-12-22  3:33   ` Doug Ledford
2016-12-20 14:02 ` Geliang Tang [this message]
2016-12-20 16:47   ` [PATCH] xen/blkback: " Konrad Rzeszutek Wilk
2016-12-20 17:44     ` Roger Pau Monné
2016-12-20 17:51       ` Konrad Rzeszutek Wilk
2016-12-20 21:53         ` Eric Dumazet
2016-12-20 22:07           ` Konrad Rzeszutek Wilk
2016-12-20 14:02 ` [PATCH] xen/evtchn: " Geliang Tang
2016-12-20 16:20   ` Juergen Gross
2016-12-22  9:07   ` Juergen Gross

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=ce9bc88496a04e6495320b041a0de4e0155b76a9.1482205355.git.geliangtang@gmail.com \
    --to=geliangtang@gmail.com \
    --cc=konrad.wilk@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=roger.pau@citrix.com \
    --cc=xen-devel@lists.xenproject.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;
as well as URLs for NNTP newsgroup(s).