All of lore.kernel.org
 help / color / mirror / Atom feed
From: Julian Wiedmann <jwi@linux.ibm.com>
To: "Martin K. Petersen" <martin.petersen@oracle.com>,
	"James E.J. Bottomley" <jejb@linux.ibm.com>
Cc: linux-scsi <linux-scsi@vger.kernel.org>,
	Julian Wiedmann <jwi@linux.ibm.com>,
	Lee Duncan <lduncan@suse.com>, Chris Leech <cleech@redhat.com>
Subject: [PATCH 3/3] scsi: iscsi: let iface class declare its sysfs attributes
Date: Thu,  7 Jan 2021 17:02:31 +0100	[thread overview]
Message-ID: <20210107160231.101243-3-jwi@linux.ibm.com> (raw)
In-Reply-To: <20210107160231.101243-1-jwi@linux.ibm.com>

Have device_register() create the attributes for us automatically, before
the KOBJ_ADD uevent is raised.

Cc: Lee Duncan <lduncan@suse.com>
Cc: Chris Leech <cleech@redhat.com>
Signed-off-by: Julian Wiedmann <jwi@linux.ibm.com>
---
 drivers/scsi/scsi_transport_iscsi.c | 23 ++++++++---------------
 1 file changed, 8 insertions(+), 15 deletions(-)

diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
index e3d57ba7ca19..d467ae3e46ee 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -286,12 +286,6 @@ static void iscsi_iface_release(struct device *dev)
 	put_device(parent);
 }
 
-
-static struct class iscsi_iface_class = {
-	.name = "iscsi_iface",
-	.dev_release = iscsi_iface_release,
-};
-
 #define ISCSI_IFACE_ATTR(_prefix, _name, _mode, _show, _store)	\
 struct device_attribute dev_attr_##_prefix##_##_name =		\
 	__ATTR(_name, _mode, _show, _store)
@@ -689,6 +683,14 @@ static struct attribute_group iscsi_iface_group = {
 	.is_visible = iscsi_iface_attr_is_visible,
 };
 
+__ATTRIBUTE_GROUPS(iscsi_iface);
+
+static struct class iscsi_iface_class = {
+	.name = "iscsi_iface",
+	.dev_groups = iscsi_iface_groups,
+	.dev_release = iscsi_iface_release,
+};
+
 /* convert iscsi_ipaddress_state values to ascii string name */
 static const struct {
 	enum iscsi_ipaddress_state	value;
@@ -773,18 +775,10 @@ iscsi_create_iface(struct Scsi_Host *shost, struct iscsi_transport *transport,
 	if (err)
 		goto free_iface;
 
-	err = sysfs_create_group(&iface->dev.kobj, &iscsi_iface_group);
-	if (err)
-		goto unreg_iface;
-
 	if (dd_size)
 		iface->dd_data = &iface[1];
 	return iface;
 
-unreg_iface:
-	device_unregister(&iface->dev);
-	return NULL;
-
 free_iface:
 	put_device(iface->dev.parent);
 	kfree(iface);
@@ -794,7 +788,6 @@ EXPORT_SYMBOL_GPL(iscsi_create_iface);
 
 void iscsi_destroy_iface(struct iscsi_iface *iface)
 {
-	sysfs_remove_group(&iface->dev.kobj, &iscsi_iface_group);
 	device_unregister(&iface->dev);
 }
 EXPORT_SYMBOL_GPL(iscsi_destroy_iface);
-- 
2.17.1


      parent reply	other threads:[~2021-01-07 16:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-07 16:02 [PATCH 1/3] scsi: iscsi: let endpoint class declare its sysfs attributes Julian Wiedmann
2021-01-07 16:02 ` [PATCH 2/3] scsi: iscsi: let transport " Julian Wiedmann
2021-01-07 16:02 ` Julian Wiedmann [this message]

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=20210107160231.101243-3-jwi@linux.ibm.com \
    --to=jwi@linux.ibm.com \
    --cc=cleech@redhat.com \
    --cc=jejb@linux.ibm.com \
    --cc=lduncan@suse.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.