From: Valentine Fatiev <valentinef@nvidia.com>
Subject: [PATCH] BACKPORT: drivers/infiniband/core/sysfs.c

Change-Id: I8d8892785f9d33eaad8a05a47c39a5f094f61ad6
---
 drivers/infiniband/core/sysfs.c | 29 +++++++++++++++--------------
 1 file changed, 15 insertions(+), 14 deletions(-)

--- a/drivers/infiniband/core/sysfs.c
+++ b/drivers/infiniband/core/sysfs.c
@@ -115,19 +115,6 @@ static ssize_t port_attr_show(struct kob
 	return port_attr->show(p->ibdev, p->port_num, port_attr, buf);
 }
 
-static ssize_t port_attr_store(struct kobject *kobj,
-			       struct attribute *attr,
-			       const char *buf, size_t count)
-{
-	struct ib_port_attribute *port_attr =
-		container_of(attr, struct ib_port_attribute, attr);
-	struct ib_port *p = container_of(kobj, struct ib_port, kobj);
-
-	if (!port_attr->store)
-		return -EIO;
-	return port_attr->store(p->ibdev, p->port_num, port_attr, buf, count);
-}
-
 struct ib_device *ib_port_sysfs_get_ibdev_kobj(struct kobject *kobj,
 					       u32 *port_num)
 {
@@ -138,9 +125,12 @@ struct ib_device *ib_port_sysfs_get_ibde
 }
 EXPORT_SYMBOL(ib_port_sysfs_get_ibdev_kobj);
 
+#ifdef CONFIG_COMPAT_IS_CONST_KOBJECT_SYSFS_OPS
 static const struct sysfs_ops port_sysfs_ops = {
+#else
+static struct sysfs_ops port_sysfs_ops = {
+#endif
 	.show	= port_attr_show,
-	.store	= port_attr_store
 };
 
 static ssize_t hw_stat_device_show(struct device *dev,
@@ -206,7 +196,11 @@ static ssize_t gid_attr_show(struct kobj
 	return port_attr->show(p->ibdev, p->port_num, port_attr, buf);
 }
 
+#ifdef CONFIG_COMPAT_IS_CONST_KOBJECT_SYSFS_OPS
 static const struct sysfs_ops gid_attr_sysfs_ops = {
+#else
+static struct sysfs_ops gid_attr_sysfs_ops = {
+#endif
 	.show = gid_attr_show
 };
 
@@ -455,7 +449,10 @@ static struct attribute *port_default_at
 	&ib_port_attr_link_layer.attr,
 	NULL
 };
+
+#ifdef HAVE_KOBJ_TYPE_DEFAULT_GROUPS
 ATTRIBUTE_GROUPS(port_default);
+#endif
 
 static ssize_t print_ndev(const struct ib_gid_attr *gid_attr, char *buf)
 {
@@ -805,7 +802,11 @@ static void ib_port_gid_attr_release(str
 static struct kobj_type port_type = {
 	.release       = ib_port_release,
 	.sysfs_ops     = &port_sysfs_ops,
+#ifdef HAVE_KOBJ_TYPE_DEFAULT_GROUPS
 	.default_groups = port_default_groups,
+#else
+	.default_attrs = port_default_attrs
+#endif
 };
 
 static struct kobj_type gid_attr_type = {
