aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/core
diff options
context:
space:
mode:
authorParav Pandit <parav@mellanox.com>2017-11-14 14:52:05 +0200
committerJason Gunthorpe <jgg@mellanox.com>2017-12-18 15:37:08 -0700
commit151ed9d7009769207cd71065f64f58e7d73add65 (patch)
tree0a28daeba9b9f4ebc82f3349367b1c38d1c3b349 /drivers/infiniband/core
parentIB/core: Avoid unnecessary type cast (diff)
downloadlinux-dev-151ed9d7009769207cd71065f64f58e7d73add65.tar.xz
linux-dev-151ed9d7009769207cd71065f64f58e7d73add65.zip
IB/core: Refactor to avoid unnecessary check on GID lookup miss
Currently on every gid entry comparison miss found variable is checked; which is not needed as those two comparison fail already indicate that GID is not found yet. So refactor to avoid such check and copy the GID index when found. Signed-off-by: Parav Pandit <parav@mellanox.com> Reviewed-by: Daniel Jurgens <danielj@mellanox.com> Signed-off-by: Leon Romanovsky <leon@kernel.org> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Diffstat (limited to 'drivers/infiniband/core')
-rw-r--r--drivers/infiniband/core/cache.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/drivers/infiniband/core/cache.c b/drivers/infiniband/core/cache.c
index 77515638c55c..43300b8e6341 100644
--- a/drivers/infiniband/core/cache.c
+++ b/drivers/infiniband/core/cache.c
@@ -573,27 +573,24 @@ static int ib_cache_gid_find_by_filter(struct ib_device *ib_dev,
struct ib_gid_attr attr;
if (table->data_vec[i].props & GID_TABLE_ENTRY_INVALID)
- goto next;
+ continue;
if (memcmp(gid, &table->data_vec[i].gid, sizeof(*gid)))
- goto next;
+ continue;
memcpy(&attr, &table->data_vec[i].attr, sizeof(attr));
- if (filter(gid, &attr, context))
+ if (filter(gid, &attr, context)) {
found = true;
-
-next:
- if (found)
+ if (index)
+ *index = i;
break;
+ }
}
read_unlock_irqrestore(&table->rwlock, flags);
if (!found)
return -ENOENT;
-
- if (index)
- *index = i;
return 0;
}