Message ID | 20230822033539.3692453-1-ruanjinjie@huawei.com (mailing list archive) |
---|---|
State | Accepted |
Headers | show |
Series | [-next,v2] RDMA/hfi1: Use list_for_each_entry() helper | expand |
On 8/21/23 11:35 PM, Jinjie Ruan wrote: > Convert list_for_each() to list_for_each_entry() so that the pos list_head > pointer and list_entry() call are no longer needed, which can > reduce a few lines of code. No functional changed. > > Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com> > --- > v2: > - Update the commit message to clarify the purpose of the patch. > --- > drivers/infiniband/hw/hfi1/affinity.c | 4 +--- > 1 file changed, 1 insertion(+), 3 deletions(-) > > diff --git a/drivers/infiniband/hw/hfi1/affinity.c b/drivers/infiniband/hw/hfi1/affinity.c > index 77ee77d4000f..bbc957c578e1 100644 > --- a/drivers/infiniband/hw/hfi1/affinity.c > +++ b/drivers/infiniband/hw/hfi1/affinity.c > @@ -230,11 +230,9 @@ static void node_affinity_add_tail(struct hfi1_affinity_node *entry) > /* It must be called with node_affinity.lock held */ > static struct hfi1_affinity_node *node_affinity_lookup(int node) > { > - struct list_head *pos; > struct hfi1_affinity_node *entry; > > - list_for_each(pos, &node_affinity.list) { > - entry = list_entry(pos, struct hfi1_affinity_node, list); > + list_for_each_entry(entry, &node_affinity.list, list) { > if (entry->node == node) > return entry; > } Acked-by: Dennis Dalessandro <dennis.dalessandro@cornelisnetworks.com>
On Tue, 22 Aug 2023 11:35:38 +0800, Jinjie Ruan wrote: > Convert list_for_each() to list_for_each_entry() so that the pos list_head > pointer and list_entry() call are no longer needed, which can > reduce a few lines of code. No functional changed. > > Applied, thanks! [1/1] RDMA/hfi1: Use list_for_each_entry() helper https://git.kernel.org/rdma/rdma/c/3d91dfe72aac33 Best regards,
diff --git a/drivers/infiniband/hw/hfi1/affinity.c b/drivers/infiniband/hw/hfi1/affinity.c index 77ee77d4000f..bbc957c578e1 100644 --- a/drivers/infiniband/hw/hfi1/affinity.c +++ b/drivers/infiniband/hw/hfi1/affinity.c @@ -230,11 +230,9 @@ static void node_affinity_add_tail(struct hfi1_affinity_node *entry) /* It must be called with node_affinity.lock held */ static struct hfi1_affinity_node *node_affinity_lookup(int node) { - struct list_head *pos; struct hfi1_affinity_node *entry; - list_for_each(pos, &node_affinity.list) { - entry = list_entry(pos, struct hfi1_affinity_node, list); + list_for_each_entry(entry, &node_affinity.list, list) { if (entry->node == node) return entry; }
Convert list_for_each() to list_for_each_entry() so that the pos list_head pointer and list_entry() call are no longer needed, which can reduce a few lines of code. No functional changed. Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com> --- v2: - Update the commit message to clarify the purpose of the patch. --- drivers/infiniband/hw/hfi1/affinity.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)