Reform link_layer_show() and ib_uverbs_query_port() with management helpers.

Cc: Jason Gunthorpe <jguntho...@obsidianresearch.com>
Cc: Doug Ledford <dledf...@redhat.com>
Cc: Ira Weiny <ira.we...@intel.com>
Cc: Sean Hefty <sean.he...@intel.com>
Signed-off-by: Michael Wang <yun.w...@profitbricks.com>
---
 drivers/infiniband/core/sysfs.c      | 8 ++------
 drivers/infiniband/core/uverbs_cmd.c | 6 ++++--
 2 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c
index cbd0383..aa53e40 100644
--- a/drivers/infiniband/core/sysfs.c
+++ b/drivers/infiniband/core/sysfs.c
@@ -248,14 +248,10 @@ static ssize_t phys_state_show(struct ib_port *p, struct 
port_attribute *unused,
 static ssize_t link_layer_show(struct ib_port *p, struct port_attribute 
*unused,
                               char *buf)
 {
-       switch (rdma_port_get_link_layer(p->ibdev, p->port_num)) {
-       case IB_LINK_LAYER_INFINIBAND:
+       if (rdma_transport_ib(p->ibdev, p->port_num))
                return sprintf(buf, "%s\n", "InfiniBand");
-       case IB_LINK_LAYER_ETHERNET:
+       else
                return sprintf(buf, "%s\n", "Ethernet");
-       default:
-               return sprintf(buf, "%s\n", "Unknown");
-       }
 }
 
 static PORT_ATTR_RO(state);
diff --git a/drivers/infiniband/core/uverbs_cmd.c 
b/drivers/infiniband/core/uverbs_cmd.c
index a9f0489..3eb6eb5 100644
--- a/drivers/infiniband/core/uverbs_cmd.c
+++ b/drivers/infiniband/core/uverbs_cmd.c
@@ -515,8 +515,10 @@ ssize_t ib_uverbs_query_port(struct ib_uverbs_file *file,
        resp.active_width    = attr.active_width;
        resp.active_speed    = attr.active_speed;
        resp.phys_state      = attr.phys_state;
-       resp.link_layer      = rdma_port_get_link_layer(file->device->ib_dev,
-                                                       cmd.port_num);
+       resp.link_layer      = rdma_transport_ib(file->device->ib_dev,
+                                                       cmd.port_num) ?
+                              IB_LINK_LAYER_INFINIBAND :
+                              IB_LINK_LAYER_ETHERNET;
 
        if (copy_to_user((void __user *) (unsigned long) cmd.response,
                         &resp, sizeof resp))
-- 
2.1.0
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to