summaryrefslogtreecommitdiff
path: root/drivers/infiniband/core/sysfs.c
diff options
context:
space:
mode:
authorJason Gunthorpe <jgg@mellanox.com>2019-02-12 21:12:47 -0700
committerJason Gunthorpe <jgg@mellanox.com>2019-02-19 10:13:39 -0700
commitea1075edcbab7d92f4e4ccf5490043f796bf78be (patch)
tree618fb95aa42e446d18020d6851bab321be2c3b4b /drivers/infiniband/core/sysfs.c
parentf2a0e45f36b0a210ff2388ed5fa89f81019c07a1 (diff)
RDMA: Add and use rdma_for_each_port
We have many loops iterating over all of the end port numbers on a struct ib_device, simplify them with a for_each helper. Reviewed-by: Parav Pandit <parav@mellanox.com> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Diffstat (limited to 'drivers/infiniband/core/sysfs.c')
-rw-r--r--drivers/infiniband/core/sysfs.c12
1 files changed, 3 insertions, 9 deletions
diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c
index 9335b15c2e38..9b6a065bdfa5 100644
--- a/drivers/infiniband/core/sysfs.c
+++ b/drivers/infiniband/core/sysfs.c
@@ -1308,23 +1308,17 @@ static void ib_free_port_attrs(struct ib_device *device)
static int ib_setup_port_attrs(struct ib_device *device)
{
+ unsigned int port;
int ret;
- int i;
device->ports_kobj = kobject_create_and_add("ports", &device->dev.kobj);
if (!device->ports_kobj)
return -ENOMEM;
- if (rdma_cap_ib_switch(device)) {
- ret = add_port(device, 0);
+ rdma_for_each_port (device, port) {
+ ret = add_port(device, port);
if (ret)
goto err_put;
- } else {
- for (i = 1; i <= device->phys_port_cnt; ++i) {
- ret = add_port(device, i);
- if (ret)
- goto err_put;
- }
}
return 0;