aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/ulp
diff options
context:
space:
mode:
authorBart Van Assche <bvanassche@acm.org>2022-08-25 14:39:00 -0700
committerLeon Romanovsky <leonro@nvidia.com>2022-08-28 13:02:28 +0300
commitb8a9c18c2f39bd84b8240b744b666114f7d62054 (patch)
tree9a7d7a746e658c4622255c7aa94051bfbb59b82e /drivers/infiniband/ulp
parentRDMA/srp: Handle dev_set_name() failure (diff)
downloadlinux-dev-b8a9c18c2f39bd84b8240b744b666114f7d62054.tar.xz
linux-dev-b8a9c18c2f39bd84b8240b744b666114f7d62054.zip
RDMA/srp: Use the attribute group mechanism for sysfs attributes
Simplify the SRP driver by using the attribute group mechanism instead of calling device_create_file() explicitly. Link: https://lore.kernel.org/r/20220825213900.864587-5-bvanassche@acm.org Signed-off-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Leon Romanovsky <leon@kernel.org>
Diffstat (limited to 'drivers/infiniband/ulp')
-rw-r--r--drivers/infiniband/ulp/srp/ib_srp.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
index 3f31a0eef1ef..1e777b2043d6 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.c
+++ b/drivers/infiniband/ulp/srp/ib_srp.c
@@ -3181,8 +3181,13 @@ static void srp_release_dev(struct device *dev)
kfree(host);
}
+static struct attribute *srp_class_attrs[];
+
+ATTRIBUTE_GROUPS(srp_class);
+
static struct class srp_class = {
.name = "infiniband_srp",
+ .dev_groups = srp_class_groups,
.dev_release = srp_release_dev
};
@@ -3888,6 +3893,13 @@ static ssize_t port_show(struct device *dev, struct device_attribute *attr,
static DEVICE_ATTR_RO(port);
+static struct attribute *srp_class_attrs[] = {
+ &dev_attr_add_target.attr,
+ &dev_attr_ibdev.attr,
+ &dev_attr_port.attr,
+ NULL
+};
+
static struct srp_host *srp_add_port(struct srp_device *device, u8 port)
{
struct srp_host *host;
@@ -3910,12 +3922,6 @@ static struct srp_host *srp_add_port(struct srp_device *device, u8 port)
goto put_host;
if (device_add(&host->dev))
goto put_host;
- if (device_create_file(&host->dev, &dev_attr_add_target))
- goto put_host;
- if (device_create_file(&host->dev, &dev_attr_ibdev))
- goto put_host;
- if (device_create_file(&host->dev, &dev_attr_port))
- goto put_host;
return host;