From patchwork Tue Nov 10 22:01:35 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ira Weiny X-Patchwork-Id: 59176 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id nAAM4qCj025635 for ; Tue, 10 Nov 2009 22:04:52 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757989AbZKJWEb (ORCPT ); Tue, 10 Nov 2009 17:04:31 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1757961AbZKJWEb (ORCPT ); Tue, 10 Nov 2009 17:04:31 -0500 Received: from nspiron-2.llnl.gov ([128.115.41.82]:57494 "EHLO nspiron-2.llnl.gov" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757989AbZKJWEa (ORCPT ); Tue, 10 Nov 2009 17:04:30 -0500 X-Attachments: None Received: from mail-2.llnl.gov ([128.115.41.181]) by nspiron-2.llnl.gov with ESMTP; 10 Nov 2009 14:04:36 -0800 Received: from jeepcj7.llnl.gov (jeepcj7.llnl.gov [134.9.93.67]) by mail-2.llnl.gov (8.13.1/8.12.3/LLNL evision: 1.7 $) with SMTP id nAAM4TRm030776; Tue, 10 Nov 2009 14:04:29 -0800 Date: Tue, 10 Nov 2009 14:01:35 -0800 From: Ira Weiny To: Sasha Khapyorsky Cc: "linux-rdma@vger.kernel.org" Subject: [PATCH 2/2] infiniband-diags/libibnetdisc: Remove nearly duplicate "get_node_info" function Message-Id: <20091110140135.0853ca2d.weiny2@llnl.gov> X-Mailer: Sylpheed 2.6.0 (GTK+ 2.10.4; x86_64-unknown-linux-gnu) Mime-Version: 1.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org diff --git a/infiniband-diags/libibnetdisc/src/ibnetdisc.c b/infiniband-diags/libibnetdisc/src/ibnetdisc.c index 3f62f3f..688382a 100644 --- a/infiniband-diags/libibnetdisc/src/ibnetdisc.c +++ b/infiniband-diags/libibnetdisc/src/ibnetdisc.c @@ -60,32 +60,20 @@ int ibdebug; int query_port_info(struct ibmad_port *ibmad_port, ib_portid_t * portid, int portnum, ibnd_port_t * port) { + char width[64], speed[64]; + int iwidth; + int ispeed; + if (!smp_query_via(port->info, portid, IB_ATTR_PORT_INFO, portnum, 0, ibmad_port)) return -1; port->base_lid = (uint16_t) mad_get_field(port->info, 0, IB_PORT_LID_F); port->lmc = (uint8_t) mad_get_field(port->info, 0, IB_PORT_LMC_F); - - return 0; -} - -static int get_port_info(struct ibmad_port *ibmad_port, - ibnd_fabric_t * fabric, ibnd_port_t * port, - int portnum, ib_portid_t * portid) -{ - int rc = 0; - char width[64], speed[64]; - int iwidth; - int ispeed; - port->portnum = portnum; + iwidth = mad_get_field(port->info, 0, IB_PORT_LINK_WIDTH_ACTIVE_F); ispeed = mad_get_field(port->info, 0, IB_PORT_LINK_SPEED_ACTIVE_F); - - if ((rc = query_port_info(ibmad_port, portid, portnum, port)) != 0) - return rc; - IBND_DEBUG ("portid %s portnum %d: base lid %d state %d physstate %d %s %s\n", portid2str(portid), portnum, port->base_lid, @@ -93,6 +81,7 @@ static int get_port_info(struct ibmad_port *ibmad_port, mad_get_field(port->info, 0, IB_PORT_PHYS_STATE_F), mad_dump_val(IB_PORT_LINK_WIDTH_ACTIVE_F, width, 64, &iwidth), mad_dump_val(IB_PORT_LINK_SPEED_ACTIVE_F, speed, 64, &ispeed)); + return 0; } @@ -122,15 +111,15 @@ static int query_node(struct ibmad_port *ibmad_port, ibnd_fabric_t * fabric, if ((rc = query_node_info(ibmad_port, fabric, node, portid)) != 0) return rc; - port->portnum = mad_get_field(node->info, 0, IB_NODE_LOCAL_PORT_F); - port->guid = mad_get_field64(node->info, 0, IB_NODE_PORT_GUID_F); - if (!smp_query_via(nd, portid, IB_ATTR_NODE_DESC, 0, 0, ibmad_port)) return -1; if ((rc = query_port_info(ibmad_port, portid, 0, port)) != 0) return rc; + port->portnum = mad_get_field(node->info, 0, IB_NODE_LOCAL_PORT_F); + port->guid = mad_get_field64(node->info, 0, IB_NODE_PORT_GUID_F); + if (node->type != IB_NODE_SWITCH) return 0; @@ -563,8 +552,8 @@ ibnd_fabric_t *ibnd_discover_fabric(struct ibmad_port * ibmad_port, IB_NODE_LOCAL_PORT_F)) continue; - if (get_port_info(ibmad_port, fabric, - &port_buf, i, path)) { + if (query_port_info(ibmad_port, path, i, + &port_buf)) { IBND_ERROR ("can't reach node %s port %d\n", portid2str(path), i);