From: Bart Van Assche <bvanassche@acm.org>
To: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Leon Romanovsky <leonro@mellanox.com>,
linux-rdma@vger.kernel.org, Bart Van Assche <bvanassche@acm.org>
Subject: [PATCH 4/4] RDMA/srp: Use the attribute group mechanism for sysfs attributes
Date: Thu, 25 Aug 2022 14:39:00 -0700 [thread overview]
Message-ID: <20220825213900.864587-5-bvanassche@acm.org> (raw)
In-Reply-To: <20220825213900.864587-1-bvanassche@acm.org>
Simplify the SRP driver by using the attribute group mechanism instead
of calling device_create_file() explicitly.
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
drivers/infiniband/ulp/srp/ib_srp.c | 18 ++++++++++++------
1 file 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;
next prev parent reply other threads:[~2022-08-25 21:39 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-25 21:38 [PATCH 0/4] RDMA/srp: Handle dev_set_name() failure Bart Van Assche
2022-08-25 21:38 ` [PATCH 1/4] RDMA/srp: Rework the srp_add_port() error path Bart Van Assche
2022-08-25 21:38 ` [PATCH 2/4] RDMA/srp: Remove the srp_host.released completion Bart Van Assche
2022-08-25 21:38 ` [PATCH 3/4] RDMA/srp: Handle dev_set_name() failure Bart Van Assche
2022-08-25 21:39 ` Bart Van Assche [this message]
2022-08-28 10:04 ` [PATCH 0/4] " Leon Romanovsky
2022-08-28 19:50 ` Bart Van Assche
2022-08-29 5:41 ` Leon Romanovsky
2022-08-30 18:10 ` Jason Gunthorpe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220825213900.864587-5-bvanassche@acm.org \
--to=bvanassche@acm.org \
--cc=jgg@ziepe.ca \
--cc=leonro@mellanox.com \
--cc=linux-rdma@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox