Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934388AbcLTODy (ORCPT ); Tue, 20 Dec 2016 09:03:54 -0500 Received: from mail-pg0-f65.google.com ([74.125.83.65]:36831 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934560AbcLTODn (ORCPT ); Tue, 20 Dec 2016 09:03:43 -0500 From: Geliang Tang To: Konrad Rzeszutek Wilk , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Cc: Geliang Tang , 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 Message-Id: X-Mailer: git-send-email 2.9.3 In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1727 Lines: 45 To make the code clearer, use rb_entry() instead of container_of() to deal with rbtree. Signed-off-by: Geliang Tang --- 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