All of lore.kernel.org
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Geliang Tang <geliangtang@gmail.com>
Cc: Yishai Hadas <yishaih@mellanox.com>,
	netdev@vger.kernel.org, linux-rdma@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] net/mlx4: use rb_entry()
Date: Sun, 22 Jan 2017 09:48:39 +0200	[thread overview]
Message-ID: <20170122074839.GD28570@mtr-leonro.local> (raw)
In-Reply-To: <6c1c772de8f70113580dade04f89a377174d8c88.1484817025.git.geliangtang@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1750 bytes --]

On Fri, Jan 20, 2017 at 10:36:57PM +0800, Geliang Tang wrote:
> 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/net/ethernet/mellanox/mlx4/resource_tracker.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)

I don't understand completely the rationale behind this conversion.
rb_entry == container_of, why do we need another name for it?

>
> diff --git a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
> index 1822382..6da6e01 100644
> --- a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
> +++ b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
> @@ -236,8 +236,8 @@ static void *res_tracker_lookup(struct rb_root *root, u64 res_id)
>  	struct rb_node *node = root->rb_node;
>
>  	while (node) {
> -		struct res_common *res = container_of(node, struct res_common,
> -						      node);
> +		struct res_common *res = rb_entry(node, struct res_common,
> +						  node);
>
>  		if (res_id < res->res_id)
>  			node = node->rb_left;
> @@ -255,8 +255,8 @@ static int res_tracker_insert(struct rb_root *root, struct res_common *res)
>
>  	/* Figure out where to put new node */
>  	while (*new) {
> -		struct res_common *this = container_of(*new, struct res_common,
> -						       node);
> +		struct res_common *this = rb_entry(*new, struct res_common,
> +						   node);
>
>  		parent = *new;
>  		if (res->res_id < this->res_id)
> --
> 2.9.3
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2017-01-22  7:48 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-20 14:36 [PATCH] 6lowpan: use rb_entry() Geliang Tang
2017-01-20 14:36 ` [PATCH] dm bio prison: " Geliang Tang
2017-01-20 15:12   ` Coly Li
2017-05-06 15:39     ` [PATCH v2] " Geliang Tang
2017-01-20 14:36 ` [PATCH] drm/i915/error: " Geliang Tang
2017-01-20 14:36   ` Geliang Tang
2017-01-23  9:10   ` [Intel-gfx] " Chris Wilson
2017-01-23  9:10     ` Chris Wilson
2017-01-20 14:36 ` [PATCH] drm/nouveau/client: " Geliang Tang
2017-01-20 14:36   ` Geliang Tang
     [not found]   ` <22da087ad757fafdb206fd0c57d286449302acdb.1484816560.git.geliangtang-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-01-21  0:14     ` Ben Skeggs
2017-01-20 14:36 ` [PATCH] net/mlx4: " Geliang Tang
2017-01-22  7:48   ` Leon Romanovsky [this message]
2017-01-22 14:42     ` Geliang Tang
2017-01-22 19:05       ` Leon Romanovsky
2017-01-22 21:48     ` David Miller
2017-01-22 21:48   ` David Miller
2017-01-20 15:24 ` ✗ Fi.CI.BAT: failure for drm/i915/error: " Patchwork
2017-01-22 21:47 ` [PATCH] 6lowpan: " David Miller

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=20170122074839.GD28570@mtr-leonro.local \
    --to=leon@kernel.org \
    --cc=geliangtang@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=yishaih@mellanox.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.