Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e82153b5 authored by Krishna Kumar's avatar Krishna Kumar Committed by Roland Dreier
Browse files

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: default avatarKrishna Kumar <krkumar2@in.ibm.com>
Acked-by: default avatarSean Hefty <sean.hefty@intel.com>
Signed-off-by: default avatarRoland Dreier <rolandd@cisco.com>
parent 0215ffb0
Loading
Loading
Loading
Loading
+7 −8
Original line number Original line Diff line number Diff line
@@ -1481,19 +1481,18 @@ static int cma_bind_loopback(struct rdma_id_private *id_priv)
	u8 p;
	u8 p;


	mutex_lock(&lock);
	mutex_lock(&lock);
	if (list_empty(&dev_list)) {
		ret = -ENODEV;
		goto out;
	}
	list_for_each_entry(cma_dev, &dev_list, list)
	list_for_each_entry(cma_dev, &dev_list, list)
		for (p = 1; p <= cma_dev->device->phys_port_cnt; ++p)
		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)
			    port_attr.state == IB_PORT_ACTIVE)
				goto port_found;
				goto port_found;


	if (!list_empty(&dev_list)) {
	p = 1;
	p = 1;
	cma_dev = list_entry(dev_list.next, struct cma_device, list);
	cma_dev = list_entry(dev_list.next, struct cma_device, list);
	} else {
		ret = -ENODEV;
		goto out;
	}


port_found:
port_found:
	ret = ib_get_cached_gid(cma_dev->device, p, 0, &gid);
	ret = ib_get_cached_gid(cma_dev->device, p, 0, &gid);