* [PATCH] 6lowpan: use rb_entry()
@ 2017-01-20 14:36 Geliang Tang
2017-01-20 14:36 ` [PATCH] net/mlx4: " Geliang Tang
2017-01-22 21:47 ` [PATCH] 6lowpan: " David Miller
0 siblings, 2 replies; 8+ messages in thread
From: Geliang Tang @ 2017-01-20 14:36 UTC (permalink / raw)
To: Alexander Aring, Jukka Rissanen, David S. Miller
Cc: Geliang Tang, linux-bluetooth, linux-wpan, netdev, linux-kernel
To make the code clearer, use rb_entry() instead of container_of() to
deal with rbtree.
Signed-off-by: Geliang Tang <geliangtang@gmail.com>
---
net/6lowpan/nhc.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/net/6lowpan/nhc.c b/net/6lowpan/nhc.c
index 7008d53..4fa2fdd 100644
--- a/net/6lowpan/nhc.c
+++ b/net/6lowpan/nhc.c
@@ -27,8 +27,8 @@ static int lowpan_nhc_insert(struct lowpan_nhc *nhc)
/* Figure out where to put new node */
while (*new) {
- struct lowpan_nhc *this = container_of(*new, struct lowpan_nhc,
- node);
+ struct lowpan_nhc *this = rb_entry(*new, struct lowpan_nhc,
+ node);
int result, len_dif, len;
len_dif = nhc->idlen - this->idlen;
@@ -69,8 +69,8 @@ static struct lowpan_nhc *lowpan_nhc_by_nhcid(const struct sk_buff *skb)
const u8 *nhcid_skb_ptr = skb->data;
while (node) {
- struct lowpan_nhc *nhc = container_of(node, struct lowpan_nhc,
- node);
+ struct lowpan_nhc *nhc = rb_entry(node, struct lowpan_nhc,
+ node);
u8 nhcid_skb_ptr_masked[LOWPAN_NHC_MAX_ID_LEN];
int result, i;
--
2.9.3
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH] net/mlx4: use rb_entry()
2017-01-20 14:36 [PATCH] 6lowpan: use rb_entry() Geliang Tang
@ 2017-01-20 14:36 ` Geliang Tang
2017-01-22 7:48 ` Leon Romanovsky
2017-01-22 21:48 ` David Miller
2017-01-22 21:47 ` [PATCH] 6lowpan: " David Miller
1 sibling, 2 replies; 8+ messages in thread
From: Geliang Tang @ 2017-01-20 14:36 UTC (permalink / raw)
To: Yishai Hadas; +Cc: Geliang Tang, netdev, linux-rdma, linux-kernel
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(-)
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
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH] net/mlx4: use rb_entry()
2017-01-20 14:36 ` [PATCH] net/mlx4: " Geliang Tang
@ 2017-01-22 7:48 ` Leon Romanovsky
2017-01-22 14:42 ` Geliang Tang
2017-01-22 21:48 ` David Miller
2017-01-22 21:48 ` David Miller
1 sibling, 2 replies; 8+ messages in thread
From: Leon Romanovsky @ 2017-01-22 7:48 UTC (permalink / raw)
To: Geliang Tang; +Cc: Yishai Hadas, netdev, linux-rdma, linux-kernel
[-- 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 --]
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH] net/mlx4: use rb_entry()
2017-01-22 7:48 ` Leon Romanovsky
@ 2017-01-22 14:42 ` Geliang Tang
2017-01-22 19:05 ` Leon Romanovsky
2017-01-22 21:48 ` David Miller
1 sibling, 1 reply; 8+ messages in thread
From: Geliang Tang @ 2017-01-22 14:42 UTC (permalink / raw)
To: Leon Romanovsky; +Cc: Yishai Hadas, netdev, linux-rdma, linux-kernel
On Sun, Jan 22, 2017 at 09:48:39AM +0200, Leon Romanovsky wrote:
> 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?
>
There are several *_entry macros which are defined in kernel data
structures, like list_entry, hlist_entry, rb_entry, etc. Each of them is
just another name for container_of. We use different *_entry so that we
could identify the specific type of data structure that we are dealing
with.
-Geliang
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] net/mlx4: use rb_entry()
2017-01-22 14:42 ` Geliang Tang
@ 2017-01-22 19:05 ` Leon Romanovsky
0 siblings, 0 replies; 8+ messages in thread
From: Leon Romanovsky @ 2017-01-22 19:05 UTC (permalink / raw)
To: Geliang Tang; +Cc: Yishai Hadas, netdev, linux-rdma, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1186 bytes --]
On Sun, Jan 22, 2017 at 10:42:25PM +0800, Geliang Tang wrote:
> On Sun, Jan 22, 2017 at 09:48:39AM +0200, Leon Romanovsky wrote:
> > 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?
> >
>
> There are several *_entry macros which are defined in kernel data
> structures, like list_entry, hlist_entry, rb_entry, etc. Each of them is
> just another name for container_of. We use different *_entry so that we
> could identify the specific type of data structure that we are dealing
> with.
Your proposed patch doesn't support the importance of such knowledge for
rb_entry. The list_entry case is totally different, because you perform
operation on it.
Anyway, It doesn't matter.
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] net/mlx4: use rb_entry()
2017-01-22 7:48 ` Leon Romanovsky
2017-01-22 14:42 ` Geliang Tang
@ 2017-01-22 21:48 ` David Miller
1 sibling, 0 replies; 8+ messages in thread
From: David Miller @ 2017-01-22 21:48 UTC (permalink / raw)
To: leon; +Cc: geliangtang, yishaih, netdev, linux-rdma, linux-kernel
From: Leon Romanovsky <leon@kernel.org>
Date: Sun, 22 Jan 2017 09:48:39 +0200
> I don't understand completely the rationale behind this conversion.
> rb_entry == container_of, why do we need another name for it?
Because it's an annotation.
Either you agree that the macro exists and it should be used in
every spot where those types are being used, or you don't and
therefore argue for the macro and it's usage completely.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] net/mlx4: use rb_entry()
2017-01-20 14:36 ` [PATCH] net/mlx4: " Geliang Tang
2017-01-22 7:48 ` Leon Romanovsky
@ 2017-01-22 21:48 ` David Miller
1 sibling, 0 replies; 8+ messages in thread
From: David Miller @ 2017-01-22 21:48 UTC (permalink / raw)
To: geliangtang; +Cc: yishaih, netdev, linux-rdma, linux-kernel
From: Geliang Tang <geliangtang@gmail.com>
Date: Fri, 20 Jan 2017 22:36:57 +0800
> To make the code clearer, use rb_entry() instead of container_of() to
> deal with rbtree.
>
> Signed-off-by: Geliang Tang <geliangtang@gmail.com>
Applied.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] 6lowpan: use rb_entry()
2017-01-20 14:36 [PATCH] 6lowpan: use rb_entry() Geliang Tang
2017-01-20 14:36 ` [PATCH] net/mlx4: " Geliang Tang
@ 2017-01-22 21:47 ` David Miller
1 sibling, 0 replies; 8+ messages in thread
From: David Miller @ 2017-01-22 21:47 UTC (permalink / raw)
To: geliangtang
Cc: aar, jukka.rissanen, linux-bluetooth, linux-wpan, netdev,
linux-kernel
From: Geliang Tang <geliangtang@gmail.com>
Date: Fri, 20 Jan 2017 22:36:53 +0800
> To make the code clearer, use rb_entry() instead of container_of() to
> deal with rbtree.
>
> Signed-off-by: Geliang Tang <geliangtang@gmail.com>
Applied.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2017-01-22 21:48 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-20 14:36 [PATCH] 6lowpan: use rb_entry() Geliang Tang
2017-01-20 14:36 ` [PATCH] net/mlx4: " Geliang Tang
2017-01-22 7:48 ` Leon Romanovsky
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-22 21:47 ` [PATCH] 6lowpan: " David Miller
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).