From patchwork Thu Apr 8 23:36:26 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ralph Campbell X-Patchwork-Id: 91557 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o38NaTht017143 for ; Thu, 8 Apr 2010 23:36:29 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758215Ab0DHXg2 (ORCPT ); Thu, 8 Apr 2010 19:36:28 -0400 Received: from avexcashub1.qlogic.com ([198.70.193.61]:2274 "EHLO avexcashub1.qlogic.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757349Ab0DHXg2 (ORCPT ); Thu, 8 Apr 2010 19:36:28 -0400 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; Thu, 8 Apr 2010 16:36:27 -0700 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; Thu, 8 Apr 2010 16:36:26 -0700 Subject: Re: [PATCH v2] IB/core: allow HCAs to create IB port sysfs files From: Ralph Campbell To: Roland Dreier CC: linux-rdma In-Reply-To: References: <1258486848.992.407.camel@chromite.mv.qlogic.com> Organization: QLogic Date: Thu, 8 Apr 2010 16:36:26 -0700 Message-ID: <1270769786.2278.38.camel@chromite.mv.qlogic.com> MIME-Version: 1.0 X-Mailer: Evolution 2.28.3 (2.28.3-1.fc12) Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Thu, 08 Apr 2010 23:36:30 +0000 (UTC) diff --git a/drivers/infiniband/core/core_priv.h b/drivers/infiniband/core/core_priv.h index 05ac36e..e70c809 100644 --- a/drivers/infiniband/core/core_priv.h +++ b/drivers/infiniband/core/core_priv.h @@ -38,7 +38,7 @@ #include -int ib_device_register_sysfs(struct ib_device *device); +int ib_device_register_sysfs(struct ib_device *device, sysfs_cb cb); void ib_device_unregister_sysfs(struct ib_device *device); int ib_sysfs_setup(void); diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c index d1fba41..9ef8093 100644 --- a/drivers/infiniband/core/device.c +++ b/drivers/infiniband/core/device.c @@ -267,7 +267,7 @@ out: * callback for each device that is added. @device must be allocated * with ib_alloc_device(). */ -int ib_register_device(struct ib_device *device) +int ib_register_device(struct ib_device *device, sysfs_cb cb) { int ret; @@ -296,7 +296,7 @@ int ib_register_device(struct ib_device *device) goto out; } - ret = ib_device_register_sysfs(device); + ret = ib_device_register_sysfs(device, cb); if (ret) { printk(KERN_WARNING "Couldn't register device %s with driver model\n", device->name); diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c index f901957..a47bac8 100644 --- a/drivers/infiniband/core/sysfs.c +++ b/drivers/infiniband/core/sysfs.c @@ -754,7 +754,23 @@ static struct attribute_group iw_stats_group = { .attrs = iw_proto_stats_attrs, }; -int ib_device_register_sysfs(struct ib_device *device) +static int sysfs_create_port_files(struct ib_device *device, sysfs_cb cb) +{ + 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 = cb(device, port->port_num, &port->kobj); + if (ret) + break; + } + + return ret; +} + +int ib_device_register_sysfs(struct ib_device *device, sysfs_cb cb) { struct device *class_dev = &device->dev; int ret; @@ -802,6 +818,12 @@ int ib_device_register_sysfs(struct ib_device *device) goto err_put; } + if (cb) { + ret = sysfs_create_port_files(device, cb); + if (ret) + goto err_put; + } + return 0; err_put: diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index 6ecd85c..4e446e4 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h @@ -1189,7 +1189,10 @@ struct ib_client { struct ib_device *ib_alloc_device(size_t size); void ib_dealloc_device(struct ib_device *device); -int ib_register_device (struct ib_device *device); +typedef int (*sysfs_cb)(struct ib_device *dev, u8 port_num, + struct kobject *kobj); + +int ib_register_device (struct ib_device *device, sysfs_cb cb); void ib_unregister_device(struct ib_device *device); int ib_register_client (struct ib_client *client);