summaryrefslogtreecommitdiffstats
path: root/drivers/infiniband
diff options
context:
space:
mode:
authorKrishna Kumar <krkumar2@in.ibm.com>2006-10-16 06:39:01 +0200
committerRoland Dreier <rolandd@cisco.com>2006-11-30 00:33:04 +0100
commite82153b54d75af31d5d4a84efe441e5719f34cfc (patch)
treecf4fad6438d0d8affa229af1fd02a754bf88450a /drivers/infiniband
parentLinux 2.6.19 (diff)
downloadlinux-e82153b54d75af31d5d4a84efe441e5719f34cfc.tar.xz
linux-e82153b54d75af31d5d4a84efe441e5719f34cfc.zip
RDMA/cma: Optimize cma_bind_loopback() to check for empty list
Optimize to test for an empty list first. This ends up simplifying the code too. Signed-off-by: Krishna Kumar <krkumar2@in.ibm.com> Acked-by: Sean Hefty <sean.hefty@intel.com> Signed-off-by: Roland Dreier <rolandd@cisco.com>
Diffstat (limited to 'drivers/infiniband')
-rw-r--r--drivers/infiniband/core/cma.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index 845090b0859c..4975d8154a78 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -1481,19 +1481,18 @@ static int cma_bind_loopback(struct rdma_id_private *id_priv)
u8 p;
mutex_lock(&lock);
+ if (list_empty(&dev_list)) {
+ ret = -ENODEV;
+ goto out;
+ }
list_for_each_entry(cma_dev, &dev_list, list)
for (p = 1; p <= cma_dev->device->phys_port_cnt; ++p)
- if (!ib_query_port (cma_dev->device, p, &port_attr) &&
+ if (!ib_query_port(cma_dev->device, p, &port_attr) &&
port_attr.state == IB_PORT_ACTIVE)
goto port_found;
- if (!list_empty(&dev_list)) {
- p = 1;
- cma_dev = list_entry(dev_list.next, struct cma_device, list);
- } else {
- ret = -ENODEV;
- goto out;
- }
+ p = 1;
+ cma_dev = list_entry(dev_list.next, struct cma_device, list);
port_found:
ret = ib_get_cached_gid(cma_dev->device, p, 0, &gid);