From patchwork Tue Nov 17 19:40:48 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ralph Campbell X-Patchwork-Id: 60776 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 nAHJeolW006550 for ; Tue, 17 Nov 2009 19:40:51 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754236AbZKQTkn (ORCPT ); Tue, 17 Nov 2009 14:40:43 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754690AbZKQTkn (ORCPT ); Tue, 17 Nov 2009 14:40:43 -0500 Received: from avexch1.qlogic.com ([198.70.193.115]:4019 "EHLO avexch1.qlogic.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754236AbZKQTkn (ORCPT ); Tue, 17 Nov 2009 14:40:43 -0500 Received: from avexcashub1.qlogic.org ([10.1.4.112]) by avexch1.qlogic.com with Microsoft SMTPSVC(6.0.3790.1830); Tue, 17 Nov 2009 11:39:38 -0800 Received: from avexcashub2.qlogic.org (10.1.4.116) by avexcashub1.qlogic.org (10.1.4.161) with Microsoft SMTP Server (TLS) id 8.1.375.2; Tue, 17 Nov 2009 11:39:38 -0800 Received: from [10.29.2.82] (10.29.2.82) by avexcashub2.qlogic.org (10.1.4.162) with Microsoft SMTP Server id 8.1.375.2; Tue, 17 Nov 2009 11:39:38 -0800 Subject: [PATCH v2] IB/core: allow HCAs to create IB port sysfs files From: Ralph Campbell To: Roland Dreier CC: linux-rdma Organization: QLogic Date: Tue, 17 Nov 2009 11:40:48 -0800 Message-ID: <1258486848.992.407.camel@chromite.mv.qlogic.com> MIME-Version: 1.0 X-Mailer: Evolution 2.22.3.1 (2.22.3.1-1.fc9) X-OriginalArrivalTime: 17 Nov 2009 19:39:38.0916 (UTC) FILETIME=[B35CBE40:01CA67BD] Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c index 158a214..1be3c3f 100644 --- a/drivers/infiniband/core/sysfs.c +++ b/drivers/infiniband/core/sysfs.c @@ -857,3 +857,22 @@ void ib_sysfs_cleanup(void) { class_unregister(&ib_class); } + +int ib_sysfs_create_port_files(struct ib_device *device, + int (*create)(struct ib_device *dev, u8 port_num, + struct kobject *kobj)) +{ + struct kobject *p; + struct ib_port *port; + int ret = 0; + + list_for_each_entry(p, &device->port_list, entry) { + port = container_of(p, struct ib_port, kobj); + ret = create(device, port->port_num, &port->kobj); + if (ret) + break; + } + + return ret; +} +EXPORT_SYMBOL(ib_sysfs_create_port_files); diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index c179318..a662486 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h @@ -1186,6 +1186,15 @@ static inline int ib_copy_to_udata(struct ib_udata *udata, void *src, size_t len } /** + * ib_sysfs_create_port_files - iterate over port sysfs directories + * @device: the IB device + * @create: a function to create sysfs files in each port directory + */ +int ib_sysfs_create_port_files(struct ib_device *device, + int (*create)(struct ib_device *dev, u8 port_num, + struct kobject *kobj)); + +/** * ib_modify_qp_is_ok - Check that the supplied attribute mask * contains all required attributes and no attributes not allowed for * the given QP state transition.